using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Comm.Control; using System.Collections; using Infragistics.Win.UltraWinGrid; using Core.StlMes.Client.SaleComm; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; namespace Core.StlMes.Client.SaleOrder { public partial class frmBasePrdcrDept : FrmBase { public frmBasePrdcrDept() { InitializeComponent(); } private int _num = 1; string pdeptno = ""; public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": this.Query(); break; case "doAdd": this.Save(); break; case "doDelete": this.doDelete(); break; case "doClose": this.Close(); break; } } public void doDelete() { ArrayList parent = new ArrayList(); ArrayList child = new ArrayList(); ultraGrid1.UpdateData(); int flag = 0; foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") { parent.Add(row.Cells["PDEPT_NO"].Value.ToString()); flag += 1; } foreach (UltraGridRow crow in row.ChildBands[0].Rows) { if (crow.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") { ArrayList list = new ArrayList(); list.Add(crow.Cells["PDEPT_NO"].Value.ToString()); list.Add(crow.Cells["PDEPT_NO_SQE"].Value.ToString()); child.Add(list); flag += 1; } } } if (flag == 0) { MessageUtil.ShowWarning("请选择您要删除的记录"); return; } if (MessageBox.Show("数据删除将无法恢复!是否要进行删除操作?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int count = ServerHelper.SetData("com.steering.pss.sale.base.CoreBasePrdcrDept.delete", new object[] { parent, child }, this.ob); if (count > 0) { MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Query(); } } public void Save() { ultraGrid1.UpdateData(); ArrayList addList = new ArrayList(); ArrayList updateList = new ArrayList(); ArrayList addListc = new ArrayList(); ArrayList updateListc = new ArrayList(); int flag = 0; foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") //勾选了主表 { ArrayList list = new ArrayList(); if (row.Cells["PDEPT_NO"].Value.ToString().Contains("A")) //新增 { if (row.Cells["PDEPT_NAME"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制单位!"); return; } list.Add(row.Cells["PDEPT_NO"].Value.ToString()); list.Add(row.Cells["PDEPT_NAME"].Value.ToString()); list.Add(row.Cells["PHONE"].Value.ToString()); list.Add(row.Cells["PDEPT_FILE"].Value.ToString()); list.Add(row.Cells["MEMO"].Value.ToString()); addList.Add(list); } else //修改 以D开头的编号 { if (row.Cells["PDEPT_NAME"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制单位!"); return; } list.Add(row.Cells["PDEPT_NO"].Value.ToString()); list.Add(row.Cells["PDEPT_NAME"].Value.ToString()); list.Add(row.Cells["PHONE"].Value.ToString()); list.Add(row.Cells["PDEPT_FILE"].Value.ToString()); list.Add(row.Cells["MEMO"].Value.ToString()); updateList.Add(list); } flag += 1; } foreach (UltraGridRow crow in row.ChildBands[0].Rows) { if (crow.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") //勾选了子表 { ArrayList list = new ArrayList(); if (crow.Cells["PDEPT_NO"].Value.ToString().Contains("A") && row.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") //新增 { if (crow.Cells["NAME_"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制人姓名!"); return; } if (crow.Cells["PHONE"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制人电话号码!"); return; } list.Add(crow.Cells["PDEPT_NO"].Value.ToString()); list.Add(row.Cells["PDEPT_NAME"].Value.ToString()); list.Add(crow.Cells["NAME_"].Value.ToString()); list.Add(crow.Cells["SEX_"].Value.ToString()); list.Add(crow.Cells["AGE_"].Value.ToString()); list.Add(crow.Cells["PHONE"].Value.ToString()); list.Add(crow.Cells["MEMO"].Value.ToString()); addListc.Add(list); } else //修改 以D开头的编号 { if (crow.Cells["PDEPT_NO_SQE"].Value.ToString() == "") //新增 { if (crow.Cells["NAME_"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制人姓名!"); return; } if (crow.Cells["PHONE"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制人电话号码!"); return; } list.Add(crow.Cells["PDEPT_NO"].Value.ToString()); list.Add(row.Cells["PDEPT_NAME"].Value.ToString()); list.Add(crow.Cells["NAME_"].Value.ToString()); list.Add(crow.Cells["SEX_"].Value.ToString()); list.Add(crow.Cells["AGE_"].Value.ToString()); list.Add(crow.Cells["PHONE"].Value.ToString()); list.Add(crow.Cells["MEMO"].Value.ToString()); addListc.Add(list); } else { if (crow.Cells["NAME_"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制人姓名!"); return; } if (crow.Cells["PHONE"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入监制人电话号码!"); return; } //list.Add(row.Cells["PDEPT_NO"].Value.ToString()); list.Add(crow.Cells["PDEPT_NO_SQE"].Value.ToString()); list.Add(row.Cells["PDEPT_NAME"].Value.ToString()); list.Add(crow.Cells["NAME_"].Value.ToString()); list.Add(crow.Cells["SEX_"].Value.ToString()); list.Add(crow.Cells["AGE_"].Value.ToString()); list.Add(crow.Cells["PHONE"].Value.ToString()); list.Add(crow.Cells["MEMO"].Value.ToString()); updateListc.Add(list); } } flag += 1; } } } if (flag == 0) { MessageUtil.ShowWarning("请选择您要保存的记录!"); return; } int count = ServerHelper.SetData("com.steering.pss.sale.base.CoreBasePrdcrDept.save", new object[] { addList, addListc, updateList, updateListc, UserInfo.GetUserName() }, this.ob); if (count > 0) { MessageUtil.ShowTips("保存成功!"); Query(); } } public void Query() { DataTable dt = Globals.GetData("com.steering.pss.sale.base.CoreBasePrdcrDept.baseDeptMainQuery", new Object[] { }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.DeptMain, true); DataTable ds = Globals.GetData("com.steering.pss.sale.base.CoreBasePrdcrDept.baseDeptTailQuery", new Object[] { }, this.ob); GridHelper.CopyDataToDatatable(ref ds, ref this.DeptTail, true); for (int i = 0; i < ultraGrid1.Rows.Count; i++) { ultraGrid1.Rows[i].Cells["PHONE"].Activation = Activation.ActivateOnly; ultraGrid1.Rows[i].Cells["PDEPT_FILE"].Activation = Activation.ActivateOnly; ultraGrid1.Rows[i].Cells["MEMO"].Activation = Activation.ActivateOnly; ultraGrid1.Rows[i].Cells["PDEPT_NAME"].Activation = Activation.ActivateOnly; } } private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { ultraGrid1.UpdateData(); if (e.Cell.Column.Key.Equals("XZ")) { if (e.Cell.Row.HasParent()) { if (Convert.ToBoolean(e.Cell.Value)) { e.Cell.Row.Cells["NAME_"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["SEX_"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["AGE_"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["PHONE"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["MEMO"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["PDEPT_NO"].Activation = Activation.AllowEdit; } else { e.Cell.Row.Cells["NAME_"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["SEX_"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["AGE_"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["PHONE"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["MEMO"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["PDEPT_NO"].Activation = Activation.ActivateOnly; } } else { if (Convert.ToBoolean(e.Cell.Value)) { e.Cell.Row.Cells["PHONE"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["PDEPT_FILE"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["MEMO"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["PDEPT_NAME"].Activation = Activation.AllowEdit; } else { e.Cell.Row.Cells["PHONE"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["PDEPT_FILE"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["MEMO"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["PDEPT_NAME"].Activation = Activation.ActivateOnly; } } } } private void txtPrdcrFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (e.Button.Key == "DownLoad")//下载 { frmOrderDeptinfo stu = new frmOrderDeptinfo(); stu.oPbc = this.ob; stu.index = ultraGrid1.ActiveRow.Cells["PDEPT_NO"].Text; stu.ShowDialog(); } else//上传 { string sFileName = "Image/pss/sale/order/ORD_PK/ORD_LN_PK/Dept/" + ultraGrid1.ActiveRow.Cells["PDEPT_NO"].Text; this.txtPrdcrFile.Text = sFileName; FlileUploadcomm.FlileUpload(sFileName); } } private void frmBasePrdcrDept_Load(object sender, EventArgs e) { ClsBaseInfo.SetComboItemHeight(ultraComboSex); } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGrid1.ActiveRow; if (ugr.HasParent()) { if (ugr.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") { ugr.Cells["SEX_"].Activation = Activation.AllowEdit; ugr.Cells["NAME_"].Activation = Activation.AllowEdit; ugr.Cells["AGE_"].Activation = Activation.AllowEdit; ugr.Cells["PHONE"].Activation = Activation.AllowEdit; ugr.Cells["MEMO"].Activation = Activation.AllowEdit; } else { ugr.Cells["SEX_"].Activation = Activation.ActivateOnly; ugr.Cells["NAME_"].Activation = Activation.ActivateOnly; ugr.Cells["AGE_"].Activation = Activation.ActivateOnly; ugr.Cells["PHONE"].Activation = Activation.ActivateOnly; ugr.Cells["MEMO"].Activation = Activation.ActivateOnly; } } } private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e) { ultraGrid1.UpdateData(); string pdeptnoStr = ""; if (!e.Row.HasChild() && !e.Row.HasParent()) { if (!pdeptno.Equals("")) { int number = int.Parse(pdeptno.Substring(1, 4)); pdeptnoStr = "A" + string.Format("{0:0000}", number + 1); _num = number + 1; } else { pdeptnoStr = "A" + string.Format("{0:0000}", _num); _num = _num + 1; } e.Row.Cells["PDEPT_NO"].Value = pdeptnoStr; pdeptno = pdeptnoStr; } ultraGrid1.UpdateData(); } } }