| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- 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();
- }
- }
- }
|