| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;using Pur.Entity;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using CoreFS.SF01;
- using Pur.Pop_upWindow;
- using Pur.configure;
- using Pur.PublicTools;
- namespace Pur.require_plan
- {
- public partial class FrmPurOilCardBudget : FrmPmsBase
- {
- public FrmPurOilCardBudget()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- private void FrmPurOilCardBudget_Load(object sender, EventArgs e)
- {
- Init();
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { });
- PublicPur.InitCellEdit(new UltraGrid[] { ultraGrid1 }, new string[] { "CHK","M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12","REMARK"});
- PublicPur.InitCellPositionRight(new UltraGrid[] { ultraGrid1 }, new string[] { "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12" });
- PublicPur.InitColumnShowLength(new UltraGrid[] { ultraGrid1 }, 0, new string[] { "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12" }, 0, false);
- PublicPur.SetupSummaryHeade(new String[] { "Count", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum", "Sum" }, new String[] { "共{0}条", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}", "{0}" }, new string[] { "CARDDID", "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12" }, this.ultraGrid1.DisplayLayout.Bands[0], SummaryDisplayAreas.BottomFixed);
- PublicPur.SetupSummaryHeade(new String[] { "Count" }, new String[] { "共{0}条" }, new string[] { "Id" }, this.ultraGrid2.DisplayLayout.Bands[0], SummaryDisplayAreas.BottomFixed);
- Qstatus.SelectedIndex = 0;
- txt_type1_M.SelectedIndex = 0;
- ck_is_all.Checked = false;
- }
- string errMsg = "";
- public List<CoreAppDepartment> _dtOrg = new List<CoreAppDepartment>();
- DataTable dt1;//部门信息
- #region toolbar工具栏
- /// <summary>
- /// toolbar
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- Query();
- break;
- case "Save":
- DoSave();
- break;
- //case "Delete":
- // DeleteOrResume(true);
- // break;
- //case "Resume":
- // DeleteOrResume(false);
- // break;
- case "Refresh":
- doQuery_d("");
- break;
- case "Close":
- this.Close();
- break;
- case "Copy":
- CopyData();
- break;
- case "UltraGridToExcel":
- UltraGridToExcel();
- break;
- }
- }
- private void UltraGridToExcel()
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraGrid1.Rows.Count <= 0)
- {
- MessageUtil.ShowTips("无可导出的充值标准!");
- return;
- }
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid1);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("充值标准");
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "充值标准明细");
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- #endregion
- #region toolbar事件
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="Tips"></param>
- private void Query()
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- cardM.Clear();
- dataSet1.Clear();
- OilCardM cardM1 = new OilCardM();
- cardM1.OilCardMId = txt_Card_No_M.Text.Trim();
- cardM1.UserOrgName = txt_org_name.Text.Trim();
- if (txt_type1_M.SelectedIndex != -1)
- {
- cardM1.Type = txt_type1_M.Value.ToString().Trim();
- }
- cardM1.DeleteUserid = txt_cardMD_no.Text.Trim();
- cardM1.UpdateUserid = txt_User_name1.Text.Trim();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.OilCardMService", "find_CardM", new object[] { cardM1 });
- if (dt != null)
- {
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("加载数据失败;" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- ///// <summary>
- ///// 作废和恢复
- ///// </summary>
- ///// <param name="tips"></param>
- //private void DeleteOrResume(bool tips)
- //{
- // ultraGrid1.UpdateData();
- // ArrayList list = new ArrayList();
- // //作废
- // if(tips==true)
- // {
- // foreach (UltraGridRow row in ultraGrid1.Rows)
- // {
- // if (Convert.ToBoolean(row.Cells["CHK"].Value))
- // {
- // OilBudget res = new OilBudget();
- // String strId=row.Cells["ID"].Value.ToString().Trim();
- // String strValidFlag = "0";
- // res.Id = strId;
- // res.Validflag = strValidFlag;
- // res.DeleteName = UserInfo.GetUserName();
- // res.DeleteTime = new DateTime();
- // res.DeleteUserid = UserInfo.GetUserID();
- // if (!String.IsNullOrEmpty(strId))
- // {
- // list.Add(res);
- // }
- // }
- // }
- // if (list.Count <=0)
- // {
- // MessageUtil.ShowWarning("请选择需要操作的记录! PS:主键为空的油卡表示未维护该用户年度每月充值标准");
- // return;
- // }
- // if (MessageBox.Show("是否确认作废数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- // return;
- // CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.OilBudgetService", "doDeleteOrResume", new object[] { list, 0, 0 });
- // if (re.Resultcode == 0)
- // {
- // MessageUtil.ShowTips("操作成功!");
- // Query();
- // OilBudget strbdg = (OilBudget)list[0];
- // string stroldId = strbdg.Id;
- // ConfigureClassCommon.doActiveSelRow(ultraGrid2, "ID", stroldId);
- // }
- // else
- // {
- // MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
- // }
- // }
- // //恢复
- // if(tips==false)
- // {
- // foreach (UltraGridRow row in ultraGrid1.Rows)
- // {
- // if (Convert.ToBoolean(row.Cells["CHK"].Value))
- // {
- // OilBudget res = new OilBudget();
- // String strId = row.Cells["ID"].Value.ToString().Trim();
- // String strValidFlag = "1";
- // res.Id = strId;
- // res.Validflag = strValidFlag;
- // res.UpdateName = UserInfo.GetUserName();
- // res.UpdateTime = new DateTime();
- // res.UpdateUserid = UserInfo.GetUserID();
- // if (!String.IsNullOrEmpty(strId))
- // {
- // list.Add(res);
- // }
- // }
- // }
- // if (list.Count <= 0)
- // {
- // MessageUtil.ShowWarning("请选择需要操作的记录! PS:主键为空的油卡表示未维护该用户年度月充值标准)");
- // return;
- // }
- // if (MessageBox.Show("是否确认恢复数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- // return;
- // CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.OilBudgetService", "doDeleteOrResume", new object[] { list, 0, 0 });
- // if (re.Resultcode == 0)
- // {
- // MessageUtil.ShowTips("操作成功!");
- // Query();
- // OilBudget strbdg = (OilBudget)list[0];
- // string stroldId = strbdg.Id;
- // ConfigureClassCommon.doActiveSelRow(ultraGrid2, "ID", stroldId);
- // }
- // else
- // {
- // MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
- // }
- // }
- //}
- /// <summary>
- /// 保存
- /// </summary>
- private void DoSave()
- {
- try
- {
- ultraGrid1.UpdateData();
- int i = 0;
- ArrayList list = new ArrayList();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- i++;
- OilBudget res = new OilBudget();
- String strDId = row.Cells["DID"].Value.ToString().Trim();
- String strId = row.Cells["ID"].Value.ToString().Trim();
- String strYEAR = Qyear.Text.Trim();
- String strM1 = row.Cells["M1"].Value.ToString().Trim() == "" ? "0" : row.Cells["M1"].Value.ToString().Trim();
- String strM2 = row.Cells["M2"].Value.ToString().Trim() == "" ? "0" : row.Cells["M2"].Value.ToString().Trim();
- String strM3 = row.Cells["M3"].Value.ToString().Trim() == "" ? "0" : row.Cells["M3"].Value.ToString().Trim();
- String strM4 = row.Cells["M4"].Value.ToString().Trim() == "" ? "0" : row.Cells["M4"].Value.ToString().Trim();
- String strM5 = row.Cells["M5"].Value.ToString().Trim() == "" ? "0" : row.Cells["M5"].Value.ToString().Trim();
- String strM6 = row.Cells["M6"].Value.ToString().Trim() == "" ? "0" : row.Cells["M6"].Value.ToString().Trim();
- String strM7 = row.Cells["M7"].Value.ToString().Trim() == "" ? "0" : row.Cells["M7"].Value.ToString().Trim();
- String strM8 = row.Cells["M8"].Value.ToString().Trim() == "" ? "0" : row.Cells["M8"].Value.ToString().Trim();
- String strM9 = row.Cells["M9"].Value.ToString().Trim() == "" ? "0" : row.Cells["M9"].Value.ToString().Trim();
- String strM10 = row.Cells["M10"].Value.ToString().Trim() == "" ? "0" : row.Cells["M10"].Value.ToString().Trim();
- String strM11 = row.Cells["M11"].Value.ToString().Trim() == "" ? "0" : row.Cells["M11"].Value.ToString().Trim();
- String strM12 = row.Cells["M12"].Value.ToString().Trim() == "" ? "0" : row.Cells["M12"].Value.ToString().Trim();
- String strREMARK = row.Cells["REMARK"].Value.ToString().Trim();
- String strVALIDFLAG = row.Cells["VALIDFLAG"].Value.ToString().Trim();
- res.Did = strDId;
- res.Id = strId;
- res.Year = strYEAR;
- res.M1 = Convert.ToDouble(strM1);
- res.M2 = Convert.ToDouble(strM2);
- res.M3 = Convert.ToDouble(strM3);
- res.M4 = Convert.ToDouble(strM4);
- res.M5 = Convert.ToDouble(strM5);
- res.M6 = Convert.ToDouble(strM6);
- res.M7 = Convert.ToDouble(strM7);
- res.M8 = Convert.ToDouble(strM8);
- res.M9 = Convert.ToDouble(strM9);
- res.M10 = Convert.ToDouble(strM10);
- res.M11 = Convert.ToDouble(strM11);
- res.M12 = Convert.ToDouble(strM12);
- res.Validflag = strVALIDFLAG;
- res.Remark = strREMARK;
- if (res == null)
- return;
- if (!TestData(res))
- {
- MessageUtil.ShowWarning(errMsg);
- return;
- }
- if (res.Id.Equals(""))
- {
- res.CreateName = UserInfo.GetUserName();
- res.CreateTime = DateTime.Now;
- res.CreateUserid = UserInfo.GetUserID();
- }
- else
- {
- res.UpdateName = UserInfo.GetUserName();
- res.UpdateTime = DateTime.Now;
- res.UpdateUserid = UserInfo.GetUserID();
- }
- list.Add(res);
- }
- }
- if (i == 0)
- {
- MessageUtil.ShowWarning("请选择需要操作的记录!");
- return;
- }
- if (MessageBox.Show("是否确认保存数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.OilBudgetService", "doSave", new object[] { list, 0, 0 });
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("数据保存成功!");
- Query();
- OilBudget strbdg = (OilBudget)list[0];
- string stroldId = strbdg.Id;
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ID", stroldId);
- }
- else
- {
- MessageUtil.ShowTips("保存失败:" + re.Resultmsg);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("保存失败:"+ex);
- }
- }
- /// <summary>
- /// 复制旧数据到指定年份
- /// </summary>
- private void CopyData()//复制旧数据
- {
- try
- {
- //不能有重复的部门
- //不能有指定年份的数据
- ultraGrid1.UpdateData();
- int i = 0;
- ArrayList list = new ArrayList();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- i++;
- OilBudget res = new OilBudget();
- String strId = row.Cells["ID"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strId))
- {
- continue;
- }
- res.Id = strId;
- res.UpdateName = UserInfo.GetUserName();
- res.UpdateTime = DateTime.Now;
- res.UpdateUserid = UserInfo.GetUserID();
- list.Add(res);
- }
- }
- if (i == 0)
- {
- MessageUtil.ShowWarning("请选择需要操作的记录!");
- return;
- }
- FrmPopCopyBudgetData frm = new FrmPopCopyBudgetData(this.ob, list,"0");
- frm.ShowDialog();
- //CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doSave", new object[] { list, 0, 0 });
- //if (re.Resultcode == 0)
- //{
- // MessageUtil.ShowTips("数据保存成功!");
- // Query(true);
- // ConfigureOrgBudget strbdg = (ConfigureOrgBudget)list[0];
- // string stroldId = strbdg.Id;
- // ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ID", stroldId);
- //}
- //else
- //{
- // MessageUtil.ShowTips("保存失败:" + re.Resultmsg);
- //}
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("保存失败:" + ex);
- }
- }
- /// <summary>
- /// 按月复制
- /// </summary>
- private void CopyDataMouth()
- {
- MessageUtil.ShowTips("权限未开放");
- return;
- //获取计算哪个月的充值金额
- frmPop_selectDate frm = new frmPop_selectDate(this.ob,"1");
- frm.ShowDialog();
- if (frm.tips == "1")
- {
- DateTime date = frm.date;
- if (date == null)
- {
- MessageUtil.ShowTips("选择的月份为空");
- }
- OilBudget res = new OilBudget();
- res.DeleteTime = date;
- res.CreateName = UserInfo.GetUserName();
- res.CreateTime = DateTime.Now;
- res.CreateUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.OilBudgetService", "doCopyByMouth", new object[] { res });
- if (crt.Resultcode == 0)
- {
- MessageUtil.ShowTips("操作成功!");
- }
- else
- {
- MessageUtil.ShowTips("操作成功:" + crt.Resultmsg);
- doQuery_d("");
- }
- }
- }
-
- #endregion
-
- #region 界面初始化
- /// <summary>
- /// 初始化控件数据
- /// </summary>
- private void Init()
- {
- //绑定年份数据
- DataTable dt1 = new DataTable();
- dt1.Columns.Add("YEAR", Type.GetType("System.Int32"));
- for (int i = DateTime.Now.AddYears(-3).Year; i <= DateTime.Now.AddYears(3).Year; i++)
- dt1.Rows.Add(new object[] { i });
- Qyear.DataSource = dt1;
- Qyear.ValueMember = "YEAR";
- Qyear.DisplayMember = "YEAR";
- Qyear.Value = DateTime.Now.Year.ToString();
- //设置界面不可编辑列
- SetColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] {"MID","DID", "VALIDFLAG", "CREATENAME", "CREATETIME", "CREATEUSERID" });
- Qstatus.SelectedIndex = 0;
- }
- #endregion
- #region 公共函数
- /// <summary>
- /// 校验保存填写数据是否满足要求
- /// </summary>
- /// <param name="res"></param>
- /// <returns></returns>
- private bool TestData(OilBudget res)
- {
- try
- {
- if (res.Validflag.ToString() != "" && res.Validflag.ToString() != "有效" && res.Validflag.ToString() != "未维护")
- {
- errMsg = "无效数据无法保存!";
- return false;
- }
- if (res.Did.ToString() == "")
- {
- errMsg = "副卡编号为空!";
- return false;
- }
- if (res.Year.ToString() == "")
- {
- errMsg = "请选择年份!";
- return false;
- }
- if (!IsNum(res.M1.ToString()))
- {
- errMsg = "1月充值标准请输入数字!";
- return false;
- }
- if(isrightRange(res.M1.ToString())==false)
- {
- errMsg = "1月" + errMsg;
- return false;
- }
- if (!IsNum(res.M2.ToString()))
- {
- errMsg = "2月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M2.ToString()) == false)
- {
- errMsg = "2月" + errMsg;
- return false;
- }
- if (!IsNum(res.M3.ToString()))
- {
- errMsg = "3月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M3.ToString()) == false)
- {
- errMsg = "3月" + errMsg;
- return false;
- }
- if (!IsNum(res.M4.ToString()))
- {
- errMsg = "4月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M4.ToString()) == false)
- {
- errMsg = "4月" + errMsg;
- return false;
- }
- if (!IsNum(res.M5.ToString()))
- {
- errMsg = "5月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M5.ToString()) == false)
- {
- errMsg = "5月" + errMsg;
- return false;
- }
- if (!IsNum(res.M6.ToString()))
- {
- errMsg = "6月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M6.ToString()) == false)
- {
- errMsg = "6月" + errMsg;
- return false;
- }
- if (!IsNum(res.M7.ToString()))
- {
- errMsg = "7月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M7.ToString()) == false)
- {
- errMsg = "7月" + errMsg;
- return false;
- }
- if (!IsNum(res.M8.ToString()))
- {
- errMsg = "8月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M8.ToString()) == false)
- {
- errMsg = "8月" + errMsg;
- return false;
- }
- if (!IsNum(res.M9.ToString()))
- {
- errMsg = "9月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M9.ToString()) == false)
- {
- errMsg = "9月" + errMsg;
- return false;
- }
- if (!IsNum(res.M10.ToString()))
- {
- errMsg = "10月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M10.ToString()) == false)
- {
- errMsg = "10月" + errMsg;
- return false;
- }
- if (!IsNum(res.M11.ToString()))
- {
- errMsg = "11月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M11.ToString()) == false)
- {
- errMsg = "11月" + errMsg;
- return false;
- }
- if (!IsNum(res.M12.ToString()))
- {
- errMsg = "12月充值标准请输入数字!";
- return false;
- }
- if (isrightRange(res.M12.ToString()) == false)
- {
- errMsg = "12月" + errMsg;
- return false;
- }
- if (res.Id.ToString() == "") //新增
- {
- OilBudget bdg = new OilBudget();
- bdg.Did = res.Did;
- bdg.Year = res.Year;
- int count = this.execute<int>("com.hnshituo.pur.requireplan.service.OilBudgetService", "count", new object[] { bdg });
- if (count > 0)
- {
- errMsg = "副卡编号:" + res.Did + ",年份:" + res.Year + " 对应的年度月充值标准信息已经存在!";
- return false;
- }
- }
- else //修改
- {
- OilBudget bdg = new OilBudget();
- bdg.Did = res.Did;
- bdg.Year = res.Year;
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.OilBudgetService", "find", new object[] { bdg, 0, 0 });
- if (dt != null && dt.Rows.Count > 0)
- {
- DataRow[] rows = dt.Select("id<>'" + res.Id + "'");
- if (rows.Count() >0)
- {
- errMsg = "副卡编号:" + res.Did + ",年份:" + res.Year + " 对应的年度月充值标准信息已经存在!";
- return false;
- }
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- errMsg = ex + "";
- //MessageUtil.ShowError(""+ex);
- return false;
- }
- }
- /// <summary>
- /// 判断是否为正数数字
- /// </summary>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool IsNum(string str)
- {
- if (str != "")
- {
- return StringUtil.IsNumber(str);
- }
- return true;
- }
- private bool isrightRange(String str)
- {
- if (Convert.ToDouble(str) >= 200000 || Convert.ToDouble(str) <= -200000)
- {
- errMsg = "超出每月充值标准最大上限20万!";
- return false;
- }
- return true;
- }
- /// <summary>
- /// 字符串转是否能转换成非负数
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public static bool Is_Below_zero(string str)
- {
- try
- {
- if (str.Equals(""))
- {
- return true;
- }
- else
- {
- if (StringUtil.IsDouble(str) && double.Parse(str) >= 0)
- return true;
- else
- return false;
- }
- }
- catch
- {
- return false;
- }
- }
-
- /// <summary>
- /// 设置包含在指定列中的列只读
- /// </summary>
- /// <param name="band"></param>
- /// <param name="columnKeys"></param>
- public static void SetColumnsActive(UltraGridBand band, params string[] columnKeys)
- {
- foreach (UltraGridColumn gridColumn in band.Columns)
- {
- if (columnKeys.Contains(gridColumn.Key) == true)
- {
- gridColumn.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// 初始化Combox数据,加入数据筛选
- /// </summary>
- /// <param name="cmbx">ComboBox控件</param>
- /// <param name="dt">DataTable</param>
- /// <param name="filterCondition">RowFilter条件</param>
- public static void FillComboxItems(UltraComboEditor cmbx, DataTable dt, string valueCol, string textCol, string filterCondition)
- {
- if (dt != null && dt.Rows.Count > 0)
- {
- DataView dvw = dt.DefaultView;
- dvw.RowFilter = filterCondition;
- ArrayList aryTmp = new ArrayList();
- aryTmp.Add(new ValueListItem(" ", " "));
- for (int i = 0; i < dvw.Count; i++)
- {
- aryTmp.Add(new ValueListItem(dvw[i][valueCol].ToString(), dvw[i][textCol].ToString()));
- }
- cmbx.DataSource = aryTmp;
- cmbx.DisplayMember = "DisplayText";
- cmbx.ValueMember = "DataValue";
- }
- }
- /// <summary>
- /// 查询定额行
- /// </summary>
- private void doQuery_d(String CardNo)
- {
- try
- {
- dataTable1.Clear();
- if (ultraGrid2.ActiveRow == null)
- {
- return;
- }
- String strMid = ultraGrid2.ActiveRow.GetCellValue("ID").ToString().Trim();
- if (String.IsNullOrEmpty(strMid))
- {
- MessageUtil.ShowTips("主卡编号为空");
- return;
- }
- OilBudget cardD = new OilBudget();
- if (!ck_is_all.Checked)
- {
- cardD.Mid = strMid;
- }
- cardD.UserName = String.IsNullOrEmpty(QUse_Name.Text.Trim()) ? txt_User_name1.Text.Trim() : QUse_Name.Text.Trim();
- cardD.CardDId = String.IsNullOrEmpty(Qcard_d_no.Text.Trim()) ? txt_cardMD_no.Text.Trim() : Qcard_d_no.Text.Trim();
- if(Qyear.SelectedIndex==-1)
- {
- MessageUtil.ShowTips("请选择年份");
- return;
- }
- if (Qyear.Text.Trim().Length < 4)
- {
- MessageUtil.ShowTips("请选择的年份格式不正确");
- return;
- }
- cardD.Year=Qyear.Text.Trim();
- if (Qstatus.SelectedIndex != -1)
- {
- cardD.Status = Qstatus.Value.ToString().Trim();
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.OilBudgetService", "cardD_Budget", new object[] { cardD });
- if (dt != null)
- {
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- if (String.IsNullOrEmpty(CardNo))
- {
- publicPms.doActiveSelRow(ultraGrid1, "OILCARDID", CardNo);
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("加载数据失败;" + ex);
- }
- }
- #endregion
- #region 界面事件
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- doQuery_d("");
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["status"].Value.ToString().Equals("暂停"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else if (e.Row.Cells["status"].Value.ToString().Equals("注销"))
- {
- e.Row.Appearance.ForeColor = Color.Gray;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- ultraGrid1.Update();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- if (!Convert.ToBoolean(ugr.Cells["CHK"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("CHK"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- else
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- ugr.Cells[i].Activation = Activation.AllowEdit;
- }
- }
- }
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- ultraGrid1.Update();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (!Convert.ToBoolean(ugr.Cells["CHK"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("CHK"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- else
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- ugr.Cells[i].Activation = Activation.AllowEdit;
- }
- }
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key.Equals("M1")||e.Cell.Column.Key.Equals("M2")||e.Cell.Column.Key.Equals("M3")||e.Cell.Column.Key.Equals("M4")||e.Cell.Column.Key.Equals("M5")||e.Cell.Column.Key.Equals("M6")||e.Cell.Column.Key.Equals("M7")||e.Cell.Column.Key.Equals("M8")||e.Cell.Column.Key.Equals("M9")||e.Cell.Column.Key.Equals("M10")||e.Cell.Column.Key.Equals("M11")||e.Cell.Column.Key.Equals("M12"))
- {
- String sreNumOld = e.Cell.Value.ToString();
- ultraGrid1.UpdateData();
- String sreNumNew = e.Cell.Value.ToString();
- if (!Is_Below_zero(sreNumNew))
- {
- e.Cell.Value = sreNumOld;
- }
- }
- }
- #endregion
- #region 行按钮
- private void btn_refresh_Click(object sender, EventArgs e)
- {
- doQuery_d("");
- }
- #endregion
- }
- }
|