| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Qcm.model;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class FrmResBaseResourceAllocation : FrmBase
- {
- public FrmResBaseResourceAllocation()
- {
- InitializeComponent();
- }
- private void FrmResBaseResourceAllocation_Load(object sender, EventArgs e)
- {
- Init();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- Query(true);
- break;
- case "Query1":
- Query(false);
- break;
- case "Save":
- DoSave();
- break;
- case "Delete":
- DeleteOrResume(true);
- break;
- case "Resume":
- DeleteOrResume(false);
- break;
- case "Refresh":
- Init();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
- {
- EntityHelper.ShowGridCaption<ResBaseResourceAllocationEntity>(e.Layout.Bands[0]);
- // GridHelper.RefreshAndAutoSize(ultraGrid1);
- }
- private void Init()
- {
- UltraComboEditor uce = new UltraComboEditor();
- DataTable dt = new DataTable();
- dt.Columns.Add("YEAR", Type.GetType("System.Int32"));
- for (int i = 2000; i <= 2060; i++)
- dt.Rows.Add(new object[] { i });
- uce.DataSource = dt;
- uce.ValueMember = "YEAR";
- uce.DisplayMember = "YEAR";
- this.Controls.Add(uce);
- uce.Visible = false;
- ultraGrid1.DisplayLayout.Bands[0].Columns["YEAR"].EditorComponent = uce;
- ultraGrid1.DisplayLayout.Bands[0].Columns["YEAR"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- UltraComboEditor uceSale = new UltraComboEditor();
- UltraComboEditor uceProcess = new UltraComboEditor();
- QcmBaseCommon.InitDrop(uceSale, "com.steering.pss.qcm.CoreResBaseResourceAllocation.getSaleOrg", "BASENAME", "BASECODE", true, this.ob);
- QcmBaseCommon.InitDrop(uceProcess, "com.steering.pss.qcm.CoreResBaseResourceAllocation.getProcess", "PROCESS_DESC", "PROCESS_CODE", true, this.ob);
- this.Controls.Add(uceSale);
- this.Controls.Add(uceProcess);
- uceSale.Visible = false;
- uceProcess.Visible = false;
- ClsBaseInfo.SetComboItemHeight(uceSale);
- ClsBaseInfo.SetComboItemHeight(uceProcess);
- ultraGrid1.DisplayLayout.Bands[0].Columns["SaleOrg"].EditorComponent = uceSale;
- ultraGrid1.DisplayLayout.Bands[0].Columns["SaleOrg"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- ultraGrid1.DisplayLayout.Bands[0].Columns["ProcessCode"].EditorComponent = uceProcess;
- ultraGrid1.DisplayLayout.Bands[0].Columns["ProcessCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- }
- private void Query(bool flag)
- {
- List<ResBaseResourceAllocationEntity> list = EntityHelper.GetData<ResBaseResourceAllocationEntity>("com.steering.pss.qcm.CoreResBaseResourceAllocation.queryResourceData", new object[] { flag }, this.ob);
- resBaseResourceAllocationEntityBindingSource.DataSource = list;
- // GridHelper.RefreshAndAutoSize(ultraGrid1);
- }
- string errMsg = "";
- private void DoSave()
- {
- ultraGrid1.UpdateData();
- int i = 0;
- ArrayList list = new ArrayList();
- //ResBaseResourceAllocationEntity res = (ResBaseResourceAllocationEntity)ultraGrid1.ActiveRow.ListObject;
- //MessageUtil.ShowWarning(res.SaleOrg.ToString());
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- i++;
- ResBaseResourceAllocationEntity res = (ResBaseResourceAllocationEntity)row.ListObject;
- if (res == null)
- return;
- if (!TestData(res))
- {
- MessageUtil.ShowWarning(errMsg);
- return;
- }
- res.CreateName = UserInfo.GetUserName();
- res.UpdateName = UserInfo.GetUserName();
- list.Add(JSONFormat.Format(res));
- }
- }
- if (i == 0)
- {
- MessageUtil.ShowWarning("请选择需要操作的记录!");
- return;
- }
- if (MessageBox.Show("是否确认保存数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreResBaseResourceAllocation.save", new object[] { list }, this.ob);
- if (count > 0)
- {
- MessageUtil.ShowTips("数据保存成功!");
- Query(true);
- }
- }
- private bool TestData(ResBaseResourceAllocationEntity res)
- {
- if (res.Validflag.ToString() != "" && res.Validflag.ToString() != "有效")
- {
- errMsg = "无效数据无法保存!";
- return false;
- }
- if (res.SaleOrg.ToString() == "")
- {
- errMsg = "请选择销售组织!";
- return false;
- }
- if (res.ProcessCode.ToString() == "")
- {
- errMsg = "请选择工序名称!";
- return false;
- }
- if (res.Year.ToString() == "")
- {
- errMsg = "请选择年份!";
- return false;
- }
- if (!IsNum(res.Month1.ToString()))
- {
- errMsg = "1月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month2.ToString()))
- {
- errMsg = "2月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month3.ToString()))
- {
- errMsg = "3月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month4.ToString()))
- {
- errMsg = "4月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month5.ToString()))
- {
- errMsg = "5月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month6.ToString()))
- {
- errMsg = "6月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month7.ToString()))
- {
- errMsg = "7月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month8.ToString()))
- {
- errMsg = "8月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month9.ToString()))
- {
- errMsg = "9月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month10.ToString()))
- {
- errMsg = "10月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month11.ToString()))
- {
- errMsg = "11月资源量请输入数字!";
- return false;
- }
- if (!IsNum(res.Month12.ToString()))
- {
- errMsg = "12月资源量请输入数字!";
- return false;
- }
- if (res.Validflag.ToString() == "") //新增
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreResBaseResourceAllocation.isReapt", new object[] { res.SaleOrg.ToString(), res.ProcessCode.ToString(), res.Year.ToString() }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- errMsg = "销售组织:" + res.SaleOrgDesc + ",工序名称:" + res.ProcessDesc + ",年份:" + res.Year + " 对应的记录已经存在!";
- return false;
- }
- }
- else //修改
- {
- if (res.SaleOrg.ToString() != res.SaleOrgOld.ToString() || res.ProcessCode.ToString() != res.ProcessCodeOld.ToString()
- || res.Year.ToString() != res.YearOld.ToString())
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreResBaseResourceAllocation.isReapt", new object[] { res.SaleOrg.ToString(), res.ProcessCode.ToString(), res.Year.ToString() }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- errMsg = "销售组织:" + res.SaleOrgDesc + ",工序名称:" + res.ProcessDesc + ",年份:" + res.Year + " 对应的记录已经存在!";
- return false;
- }
- }
- }
- return true;
- }
- private bool IsNum(string str)
- {
- if (str != "")
- {
- return StringUtil.IsNumber(str);
- }
- return true;
- }
- private void DeleteOrResume(bool flag)
- {
- ultraGrid1.UpdateData();
- ArrayList list = new ArrayList();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- if (flag && row.Cells["VALIDFLAG"].Value.ToString() != "有效")
- {
- MessageUtil.ShowWarning("非有效记录无法作废!");
- return;
- }
- else if (flag == false && row.Cells["VALIDFLAG"].Value.ToString() != "无效")
- {
- MessageUtil.ShowWarning("非无效记录无法恢复!");
- return;
- }
- ResBaseResourceAllocationEntity res = (ResBaseResourceAllocationEntity)row.ListObject;
- res.DeleteName = UserInfo.GetUserName();
- list.Add(JSONFormat.Format(res));
- }
- }
- if (GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" }).Length <= 0)
- {
- MessageUtil.ShowWarning("请选择需要操作的记录!");
- return;
- }
- if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "所选的记录", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreResBaseResourceAllocation.deleteOrResume", new object[] { list, flag }, this.ob);
- if (count > 0)
- {
- MessageUtil.ShowWarning("数据" + (flag ? "作废" : "恢复") + "成功!");
- Query(true);
- }
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- ResBaseResourceAllocationEntity res = (ResBaseResourceAllocationEntity)ugr.ListObject;
- if (e.Cell.Column.Key.Equals("SaleOrg"))
- {
- res.SaleOrgDesc = e.Cell.Text;
- }
- else if (e.Cell.Column.Key.Equals("ProcessCode"))
- {
- res.ProcessDesc = e.Cell.Text;
- }
- else if (e.Cell.Column.Key.Equals("CHK"))
- {
- if (!Convert.ToBoolean(e.Cell.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_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- 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;
- }
- }
- }
- }
- }
|