| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- 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
- {
- /// <summary>
- /// 产品规范管理
- /// </summary>
- public partial class FrmStandard1 : FrmBase
- {
- //提示信息
- private string errMessage = "";
- //动态生成科室
- private Dictionary<string, UltraComboEditor> departments = null;
- //定位标准基础
- private string _std = "";
- //定位产品规范
- private string _psc = "";
- //定位最终客户
- private string _cust = "";
- //判断是否勾选
- private int isSelectData = -1;
- private int distance = 0;
- private int disWidth = 0;
- private UltraComboEditor[] uces = new UltraComboEditor[7];
- public FrmStandard1()
- {
- IsLoadUserView = true;
- InitializeComponent();
- }
- /// <summary>
- /// 隐藏页面
- /// </summary>
- private void Distinguish()
- {
- if (this.CustomInfo == "1")
- {
- splitContainer1.Panel2Collapsed = true;
- ultraGrid2.Enabled = false;
- }
- if (this.CustomInfo == "2")
- {
- splitContainer1.Panel2Collapsed = true;
- splitContainer2.Panel2Collapsed = true;
- }
- if (this.CustomInfo == "3")
- {
- splitContainer2.Panel2Collapsed = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["DEPARTMENT_CODE"].CellAppearance.BackColor = Color.Empty;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["UNIT_CODE"].CellAppearance.BackColor = Color.Empty;
- // LightGray
- }
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- DoQuery();
- break;
- case "doSave":
- DoSave();
- break;
- case "doDelete":
- this.DoDeleteOrResume(true);
- break;
- case "doResume":
- this.DoDeleteOrResume(false);
- break;
- case "Refresh":
- InitComBoEditor();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmStandard1_Load(object sender, EventArgs e)
- {
- Distinguish();
- InitComBoEditor();
- CreateDepartments();
- }
- /// <summary>
- /// 初始化下拉框
- /// </summary>
- private void InitComBoEditor()
- {
- for (int i = 0; i < uces.Length; i++)
- {
- uces[i] = new UltraComboEditor();
- Controls.Add(uces[i]);
- uces[i].Visible = false;
- }
- UltraGridBand ugb1 = ultraGrid1.DisplayLayout.Bands[0];
- UltraGridBand ugb2 = ultraGrid2.DisplayLayout.Bands[0];
- UltraGridBand ugb3 = ultraGrid3.DisplayLayout.Bands[0];
- //初始化标准类型
- QcmBaseQuery.NitializeStandardType(uces[0], false, this.ob);
- if (CustomInfo == "1")
- {
- ((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE IN ('G', 'X')";
- }
- if (CustomInfo == "2")
- {
- ((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE NOT IN ('G', 'X','K')";
- }
- if (CustomInfo == "3")
- {
- ((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE IN ('K')";
- }
- QcmBaseQuery.BindColumn(uces[0], "STDSTYLE", ugb1);
- //初始化标准协会
- QcmBaseQuery.NitializeSociety(uces[1], true, this.ob);
- QcmBaseQuery.BindColumn(uces[1], "STD_STYLE", ugb1);
- //初始化管理部门
- QcmBaseQuery.NitializeDepartment(uces[2], false, this.ob);
- QcmBaseQuery.BindColumn(uces[2], "DEPARTMENT_CODE", ugb1);
- QcmBaseQuery.BindColumn(uces[2], "DEPARTMENT_CODE", ugb2);
- //品名描述
- QcmBaseQuery.NitializeProducName(uces[3], false, this.ob);
- QcmBaseQuery.BindColumn(uces[3], "PRODUCCODE", ugb2);
- //初始化标准类别
- QcmBaseQuery.NitializeStdStyle(uces[4], true, this.ob);
- QcmBaseQuery.BindColumn(uces[4], "STD_STYLE", ugb2);
- //初始化钢级牌号
- QcmBaseQuery.NitializeSteel(uces[5], true, this.ob);
- QcmBaseQuery.BindColumn(uces[5], "STEELCODE", ugb2);
- //初始化最终客户
- QcmBaseQuery.NitializeCustomer(uces[6], true, this.ob);
- QcmBaseQuery.BindColumn(uces[6], "CUST_CODE", ugb3);
- }
- /// <summary>
- /// 动态绑定数据源 管理科室
- /// </summary>
- private void BandDepartments(InitializeRowEventArgs e)
- {
- string pid = e.Row.Cells["DEPARTMENT_CODE"].Value.ToString();
- if (departments.ContainsKey(pid))
- {
- e.Row.Cells["UNIT_CODE"].EditorComponent = departments[pid];
- }
- else
- {
- e.Row.Cells["UNIT_CODE"].EditorComponent = departments["noValue"];
- }
- }
- /// <summary>
- /// 根据部门生成科室
- /// </summary>
- private void CreateDepartments()
- {
- int count = uces[2].Items.Count;
- departments = new Dictionary<string, UltraComboEditor>(count + 1);
- departments.Add("noValue", new UltraComboEditor());
- for (int i = 0; i < count; i++)
- {
- string pid = uces[2].Items[i].DataValue.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getSection", new object[] { }, this.ob);
- dt.DefaultView.RowFilter = "PID='" + pid + "'";
- UltraComboEditor uce = new UltraComboEditor();
- uce.DataSource = dt;
- uce.DisplayMember = "DEPARTNAME";
- uce.ValueMember = "DEPARTID";
- uce.Visible = false;
- departments.Add(pid, uce);
- Controls.Add(uce);
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- //查询条件
- string valid = "1";
- if (ChcValid.Checked)
- valid = "0";
- string std = "";
- if (ChcStd.Checked)
- std = TextStd.Text.Trim();
- //CoreStandard标准基础表
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComBaseStd", new Object[] { valid, std }, this.ob);
- if (CustomInfo == "1")
- {
- DataRow[] rows = dt.Select("STDSTYLE<>'订货标准' AND STDSTYLE<>'协议标准'");
- foreach (DataRow dr in rows)
- {
- dt.Rows.Remove(dr);
- }
- }
- else if (CustomInfo == "3")
- {
- DataRow[] rows = dt.Select("STDSTYLE<>'Alpha'");
- foreach (DataRow dr in rows)
- {
- dt.Rows.Remove(dr);
- }
- }
- else
- {
- DataRow[] rows = dt.Select("STDSTYLE='协议标准' or STDSTYLE='订货标准' or STDSTYLE='Alpha'");
- foreach (DataRow dr in rows)
- {
- dt.Rows.Remove(dr);
- }
- }
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //定位
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME" }, new string[] { _std });
- if (rows1.Length > 0)
- rows1[0].Activate();
- UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] };
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
- isSelectData = -1;
- }
- /// <summary>
- /// 保存
- /// </summary>
- private void DoSave()
- {
- ultraGrid1.UpdateData();
- ultraGrid2.UpdateData();
- ultraGrid3.UpdateData();
- if (isSelectData == -1)
- {
- MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //标准基础
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHC" }, new string[] { "True" });
- ArrayList stdAdd = new ArrayList();
- ArrayList stdUpdate = new ArrayList();
- if (rows.Length > 0)
- {
- foreach (UltraGridRow row in rows)
- {
- ArrayList stdList = GetStdData(row);
- if (stdList == null)
- {
- MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //标准名称
- string stdName = row.Cells["STD_NAME"].Value.ToString().Trim();
- string stdType = row.Cells["STDSTYLE"].Value.ToString();
- _std = stdName;
- //标准代码
- string stdCode = row.Cells["STD_CODE"].Value.ToString().Trim();
- //如果创建人为空,则新增,否则修改
- if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
- {
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME", "STDSTYLE" }, new string[] { stdName, stdType });
- if (rows1.Length > 1)
- {
- MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //验证标准名称是否重复
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkStdName", new Object[] { stdName, stdType }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- stdAdd.Add(stdList);
- }
- else
- {
- //验证标准名称是否重复
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkStdName",
- new Object[] { stdName, stdCode, stdType }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- stdList.Add(stdCode);
- stdUpdate.Add(stdList);
- }
- }
- }
- //产品规范
- ArrayList pscAdd = new ArrayList();
- ArrayList pscUpdate = new ArrayList();
- rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "CHC" }, new string[] { "True" });
- if (rows.Length > 0)
- {
- foreach (UltraGridRow row in rows)
- {
- string psc = row.Cells["PSC"].Value.ToString();
- string pscDesc = row.Cells["PSC_DESC"].Value.ToString();
- _psc = pscDesc;
- ArrayList pscList = GetPscData(row);
- if (pscList == null)
- {
- MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
- {
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "PSC_DESC" }, new string[] { pscDesc });
- if (rows1.Length > 1)
- {
- MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //验证产品规范描述是否重复
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkPSC", new Object[] { pscDesc }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- pscAdd.Add(pscList);
- }
- else
- {
- //验证产品规范描述是否重复
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkPSC", new Object[] { pscDesc, psc }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- pscList.Add(psc);
- pscUpdate.Add(pscList);
- }
- }
- }
- //客户
- ArrayList custerAdd = new ArrayList();
- ArrayList custerUpdate = new ArrayList();
- rows = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CHC" }, new string[] { "True" });
- if (rows.Length > 0)
- {
- foreach (UltraGridRow row in rows)
- {
- ArrayList custList = GetcustData(row);
- if (custList == null)
- {
- MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- string stdCode = row.Cells["STD_CODE"].Value.ToString();
- string custName = row.Cells["CUST_NAME"].Text.ToString();
- //用于定位客户
- _cust = custName;
- string custCode = row.Cells["CUST_CODE"].Value.ToString();
- if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
- {
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CUST_CODE" }, new string[] { custCode });
- if (rows1.Length > 1)
- {
- MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //验证最终客户是否重复
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkCust", new Object[] { custCode, stdCode }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- custerAdd.Add(custList);
- }
- else
- {
- //验证最终客户是否重复
- if (!custCode.Equals(row.Cells["OLD_CUST_CODE"].Value.ToString()))
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkCust1", new Object[] { custCode, stdCode }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- }
- custList.Add(stdCode);
- custList.Add(custCode);
- custerUpdate.Add(custList);
- }
- }
- }
- if (MessageBox.Show("是否保存记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- if (stdAdd.Count > 0 || pscAdd.Count > 0 || custerAdd.Count > 0 || stdUpdate.Count > 0 || pscUpdate.Count > 0 || custerUpdate.Count > 0)
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreStandard1.saveCoreStandard1",
- new Object[] { stdAdd, stdUpdate, pscAdd, pscUpdate, custerAdd, custerUpdate }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- DoQuery();
- }
- }
- }
- /// <summary>
- /// 作废与恢复
- /// </summary>
- /// <param name="flag"></param>
- private void DoDeleteOrResume(Boolean flag)
- {
- if (isSelectData == -1)
- {
- MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //标准基础
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHC" }, new string[] { "True" });
- ArrayList stdList = new ArrayList();
- ArrayList pscList = new ArrayList();
- ArrayList custList = new ArrayList();
- if (rows.Length > 0)
- {
- foreach (UltraGridRow row in rows)
- {
- ArrayList std = new ArrayList();
- //如果作废标准基础,就同时此标准基础下作废产品规范和客户
- if (flag)
- {
- std.Add(UserInfo.GetUserName());
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- ArrayList psc = new ArrayList();
- psc.Add(UserInfo.GetUserName());
- psc.Add(ultraGrid2.Rows[i].Cells["PSC"].Value.ToString());
- pscList.Add(psc);
- }
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- {
- ArrayList cust = new ArrayList();
- cust.Add(UserInfo.GetUserName());
- cust.Add(ultraGrid3.Rows[i].Cells["STD_CODE"].Value.ToString());
- cust.Add(ultraGrid3.Rows[i].Cells["CUST_CODE"].Value.ToString());
- custList.Add(cust);
- }
- }
- else
- std.Add("");
- std.Add(row.Cells["STD_CODE"].Value.ToString());
- stdList.Add(std);
- //用于定位
- _std = row.Cells["STD_NAME"].Value.ToString();
- }
- }
- //产品规范
- rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "CHC" }, new string[] { "True" });
- if (rows.Length > 0)
- {
- foreach (UltraGridRow row in rows)
- {
- ArrayList psc = new ArrayList();
- if (flag)
- psc.Add(UserInfo.GetUserName());
- else
- psc.Add("");
- psc.Add(row.Cells["PSC"].Value.ToString());
- pscList.Add(psc);
- //用于定位
- _psc = row.Cells["PSC_DESC"].Value.ToString();
- }
- }
- //最终客户
- rows = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CHC" }, new string[] { "True" });
- if (rows.Length > 0)
- {
- foreach (UltraGridRow row in rows)
- {
- ArrayList cust = new ArrayList();
- if (flag)
- cust.Add(UserInfo.GetUserName());
- else
- {
- //恢复客户,如果所对应的标准名称没有恢复,且不能恢复
- string stdName = row.Cells["STD_NAME"].Value.ToString();
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME" }, new string[] { stdName });
- if (rows1.Length > 0 && rows1[0].Cells["VALIDFLAG"].Value.Equals("无效"))
- {
- MessageBox.Show("请先恢复标准名称:" + stdName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- cust.Add("");
- }
- cust.Add(row.Cells["STD_CODE"].Value.ToString());
- cust.Add(row.Cells["CUST_CODE"].Value.ToString());
- custList.Add(cust);
- _cust = row.Cells["CUST_NAME"].Value.ToString();
- }
- }
- if (flag)
- {
- if (MessageBox.Show("是否作废记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- else
- {
- if (MessageBox.Show("是否恢复记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- if (stdList.Count > 0 || pscList.Count > 0 || custList.Count > 0)
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreStandard1.deleteOrResume",
- new Object[] { stdList, pscList, custList, flag }, this.ob);
- if (count > 0)
- {
- if (flag)
- MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- else
- MessageBox.Show("恢复成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- DoQuery();
- }
- }
- }
- /// <summary>
- /// 查询区
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ChcStd_CheckedChanged(object sender, EventArgs e)
- {
- if (ChcStd.Checked)
- TextStd.Enabled = true;
- else
- TextStd.Enabled = false;
- }
- /// <summary>
- /// 将ultraGrid2选择全部不勾选
- /// </summary>
- /// <param name="ug"></param>
- private void changeUltraGirdChc(UltraGrid ug)
- {
- for (int i = 0; i < ug.Rows.Count; i++)
- ug.Rows[i].Cells["CHC"].Value = false;
- }
- //--------------------------------ultraGrid1-------------------------------
- /// <summary>
- /// 标准行增加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- //增加一行,自动获取最大的标准代码,然后加1
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- int stdCode = 0;
- DataRow[] rows = dataTable1.Select("", "STD_CODE DESC");
- if (rows.Length > 0)
- stdCode = Convert.ToInt32(rows[0]["STD_CODE"].ToString().Substring(3, 7));
- ugr.Cells["STD_CODE"].Value = "STD" + string.Format("{0:0000000}", (stdCode + 1));
- //增加行如果没有勾选则不可编辑
- if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("CHC"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// ultraGrid1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- if (e.Cell.Column.Key.Equals("STD_NAME")) //标准名称
- {
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- { ultraGrid2.Rows[i].Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim(); }
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- { ultraGrid3.Rows[i].Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim(); }
- }
- if (e.Cell.Column.Key.Equals("STDSTYLE")) //标准类型
- {
- string stdstyle = ugr.Cells["STDSTYLE"].Text;
- if (stdstyle.Equals("订货标准") || stdstyle.Equals("协议标准"))
- {
- ultraGrid2.Enabled = true;
- changeUltraGirdChc(ultraGrid3);
- ultraGrid3.Enabled = false;
- if (stdstyle.Equals("订货标准"))
- {
- ugr.Cells["DEPARTMENT_DESC"].Value = "制造部";
- ugr.Cells["DEPARTMENT_CODE"].Value = "141106165400";
- ugr.Cells["UNIT_DESC"].Value = "标准科";
- ugr.Cells["UNIT_CODE"].Value = "141223091224";
- ;
- }
- if (stdstyle.Equals("协议标准"))
- {
- ugr.Cells["DEPARTMENT_DESC"].Value = "制造部";
- ugr.Cells["DEPARTMENT_CODE"].Value = "141106165400";
- ugr.Cells["UNIT_DESC"].Value = "工艺科";
- ugr.Cells["UNIT_CODE"].Value = "141106174134";
- ;
- }
- }
- else if (stdstyle.Equals("Alpha"))
- {
- changeUltraGirdChc(ultraGrid2);
- ultraGrid2.Enabled = false;
- ultraGrid3.Enabled = true;
- }
- else
- {
- changeUltraGirdChc(ultraGrid2);
- changeUltraGirdChc(ultraGrid3);
- ultraGrid2.Enabled = false;
- ultraGrid3.Enabled = false;
- }
- }
- if (e.Cell.Column.Key.Equals("STD_STYLE")) //标准协会
- {
- ugr.Cells["STD_STYLE_NAME"].Value = ugr.Cells["STD_STYLE"].Text;
- }
- if (e.Cell.Column.Key.Equals("DEPARTMENT_CODE")) //部门管理
- {
- ugr.Cells["DEPARTMENT_DESC"].Value = ugr.Cells["DEPARTMENT_CODE"].Text;
- ugr.Cells["UNIT_DESC"].Value = "";
- ugr.Cells["UNIT_CODE"].Value = "";
- }
- if (e.Cell.Column.Key.Equals("UNIT_CODE")) //科室管理
- {
- ugr.Cells["UNIT_DESC"].Value = ugr.Cells["UNIT_CODE"].Value.ToString();
- }
- if (e.Cell.Column.Key.Equals("CHC"))//选择
- {
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- isSelectData += 1;
- }
- else
- isSelectData -= 1;
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("CHC") && !cells[i].Column.Key.Equals("STD_NAME"))
- {
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- if (!e.Cell.Row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
- {
- if (ultraGrid2.Rows.Count > 0 || ultraGrid3.Rows.Count > 0)
- e.Cell.Row.Cells["STD_NAME"].Activation = Activation.ActivateOnly;
- else
- e.Cell.Row.Cells["STD_NAME"].Activation = activation;
- }
- else
- e.Cell.Row.Cells["STD_NAME"].Activation = activation;
- }
- }
- /// <summary>
- /// ultraGrid1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- BandDepartments(e);
- if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- /// <summary>
- /// 行激活事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- if (this.CustomInfo == "2")
- return;
- ultraGrid2.Enabled = true;
- ultraGrid3.Enabled = true;
- ultraGrid2.UpdateData();
- ultraGrid3.UpdateData();
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- string stdName = ugr.Cells["STD_NAME"].Value.ToString();
- _std = stdName;
- string stdStyle = ugr.Cells["STDSTYLE"].Text.ToString();
- //国标 产品规范码
- if (stdStyle.Equals("订货标准") || stdStyle.Equals("协议标准"))
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComPsc", new Object[] { stdName }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
- //激活操作的行
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "PSC_DESC" }, new string[] { _psc });
- if (rows.Length > 0)
- rows[0].Activate();
- _psc = "";
- UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
- dataTable3.Rows.Clear();
- ultraGrid3.Enabled = false;
- }
- //Alpha 客户
- else if (stdStyle.Equals("Alpha"))
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComBaseStdRCust", new Object[] { stdName }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
- //激活操作的行
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CUST_NAME" }, new string[] { _cust });
- if (rows1.Length > 0)
- rows1[0].Activate();
- _cust = "";
- //UltraGridColumn[] col1 = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["CHC"] };
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid3, null);
- dataTable2.Rows.Clear();
- ultraGrid2.Enabled = false;
- }
- else
- {
- dataTable3.Rows.Clear();
- dataTable2.Rows.Clear();
- ultraGrid2.Enabled = false;
- ultraGrid3.Enabled = false;
- }
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid2);
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid3);
- }
- //--------------------------------ultraGrid2-------------------------
- /// <summary>
- /// 行增加事件 ultraGrid2
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
- {
- //增加一行,自动获取最大的最大产品规范码,然后加1
- UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
- int psc = 0;
- DataRow[] rows = dataTable2.Select("", "PSC DESC");
- if (rows.Length > 0)
- psc = Convert.ToInt32(rows[0]["PSC"].ToString().Substring(4, 6));
- ugr.Cells["PSC"].Value = "PSC" + string.Format("{0:0000000}", (psc + 1));
- ugr.Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim();
- ugr.Cells["STD_CODE"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_CODE"].Value.ToString().Trim();
- ugr.Cells["DEPARTMENT_DESC"].Value = UserInfo.GetDepartment();
- ugr.Cells["DEPARTMENT_CODE"].Value = UserInfo.GetDeptid();
- //增加行如果没有勾选则不可编辑
- if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("CHC"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// ultraGrid2值变化事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid2.UpdateData();
- UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
- if (e.Cell.Column.Key.Equals("PRODUCCODE")) //品名描述
- {
- ugr.Cells["PRODUCNAME"].Value = ugr.Cells["PRODUCCODE"].Text;
- }
- if (e.Cell.Column.Key.Equals("STEELCODE")) //钢级(牌号)名称
- {
- ugr.Cells["STEELNAME"].Value = ugr.Cells["STEELCODE"].Text;
- }
- if (e.Cell.Column.Key.Equals("STD_STYLE")) //标准类别描述(PSL1....)
- {
- ugr.Cells["STD_STYLE_DESC"].Value = ugr.Cells["STD_STYLE"].Text;
- }
- //产品规范描述组成 =品名+标准类型+钢级+ 标准类别
- ugr.Cells["PSC_DESC"].Value = ugr.Cells["PRODUCNAME"].Text + "," + ugr.Cells["STD_NAME"].Text + "," +
- ugr.Cells["STEELNAME"].Text;
- //标准类别
- string stdStyleDesc = ugr.Cells["STD_STYLE_DESC"].Text;
- if (stdStyleDesc != null && !stdStyleDesc.Equals(""))
- ugr.Cells["PSC_DESC"].Value = ugr.Cells["PRODUCNAME"].Text + "," + ugr.Cells["STD_NAME"].Text + "," +
- ugr.Cells["STEELNAME"].Text + "+" + ugr.Cells["STD_STYLE_DESC"].Text;
- if (e.Cell.Column.Key.Equals("DEPARTMENT_CODE")) //部门管理
- {
- ugr.Cells["DEPARTMENT_DESC"].Value = ugr.Cells["DEPARTMENT_DESC"].Text;
- //根据部门号查询管理科室
- }
- if (e.Cell.Column.Key.Equals("UNIT_CODE")) //科室管理
- {
- ugr.Cells["UNIT_DESC"].Value = ugr.Cells["UNIT_CODE"].Text;
- }
- if (e.Cell.Column.Key.Equals("CHC"))//选择
- {
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- isSelectData += 1;
- }
- else
- isSelectData -= 1;
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("CHC"))
- {
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- }
- /// <summary>
- /// ultraGrid2
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- BandDepartments(e);
- if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- /// <summary>
- /// 获取标准类型数据
- /// </summary>
- /// <param name="ugr"></param>
- /// <returns></returns>
- private ArrayList GetStdData(UltraGridRow ugr)
- {
- ArrayList list = new ArrayList();
- string std_code = ugr.Cells["STD_CODE"].Value.ToString();
- string std_name = ugr.Cells["STD_NAME"].Value.ToString().Trim();
- if (std_name.Equals(""))
- {
- errMessage = "请输入标准名称";
- return null;
- }
- string stdstyle = ugr.Cells["STDSTYLE"].Value.ToString();
- string std_note = ugr.Cells["STD_NOTE"].Value.ToString();
- string std_style = ugr.Cells["STD_STYLE"].Value.ToString();
- string std_style_name = ugr.Cells["STD_STYLE_NAME"].Value.ToString();
- string std_version = ugr.Cells["STD_VERSION"].Value.ToString();
- string department_code = ugr.Cells["DEPARTMENT_CODE"].Value.ToString();
- string department_desc = ugr.Cells["DEPARTMENT_DESC"].Value.ToString();
- if (CustomInfo != "3" && department_desc.Equals(""))
- {
- errMessage = "请选择管理部门描述";
- return null;
- }
- string unit_code = ugr.Cells["UNIT_CODE"].Value.ToString();
- string unit_desc = ugr.Cells["UNIT_DESC"].Value.ToString();
- if (CustomInfo != "3" && unit_desc.Equals(""))
- {
- errMessage = "请选择管理科室描述";
- return null;
- }
- string userName = UserInfo.GetUserName();
- string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
- if (validflag.Equals("无效"))
- {
- errMessage = "无效记录不能保存";
- return null;
- }
- string memo = ugr.Cells["MEMO"].Value.ToString();
- list.Add(std_code);
- list.Add(std_name);
- list.Add(stdstyle);
- list.Add(std_note);
- list.Add(std_style);
- list.Add(std_style_name);
- list.Add(std_version);
- list.Add(department_code);
- list.Add(department_desc);
- list.Add(unit_code);
- list.Add(unit_desc);
- list.Add(userName);
- list.Add(memo);
- return list;
- }
- /// <summary>
- /// 获取产品规范数据
- /// </summary>
- /// <param name="ugr"></param>
- /// <returns></returns>
- private ArrayList GetPscData(UltraGridRow ugr)
- {
- ArrayList list = new ArrayList();
- string psc = ugr.Cells["PSC"].Value.ToString();
- string psc_desc = ugr.Cells["PSC_DESC"].Value.ToString();
- string produccode = ugr.Cells["PRODUCCODE"].Value.ToString();
- string producname = ugr.Cells["PRODUCNAME"].Value.ToString();
- if (producname.Equals(""))
- {
- errMessage = "请选择品名描述";
- return null;
- }
- string std_code = ugr.Cells["STD_CODE"].Value.ToString();
- string std_name = ugr.Cells["STD_NAME"].Value.ToString();
- string steelcode = ugr.Cells["STEELCODE"].Value.ToString();
- string steelname = ugr.Cells["STEELNAME"].Value.ToString();
- if (steelname.Equals(""))
- {
- errMessage = "请选择钢级牌号";
- return null;
- }
- string std_style = ugr.Cells["STD_STYLE"].Value.ToString();
- string std_style_desc = ugr.Cells["STD_STYLE_DESC"].Value.ToString();
- string new_proc_code = ugr.Cells["NEW_PROC_CODE"].Value.ToString();
- if (Convert.ToBoolean(new_proc_code))
- new_proc_code = "1";
- else
- new_proc_code = "0";
- string new_proc_desc = ugr.Cells["NEW_PROC_DESC"].Value.ToString();
- string department_code = ugr.Cells["DEPARTMENT_CODE"].Value.ToString();
- string department_desc = ugr.Cells["DEPARTMENT_DESC"].Value.ToString();
- if (department_desc.Equals(""))
- {
- errMessage = "请选择管理部门描述";
- return null;
- }
- string unit_code = ugr.Cells["UNIT_CODE"].Value.ToString();
- string autojudge = ugr.Cells["AUTOJUDGE"].Value.ToString();
- if (Convert.ToBoolean(autojudge))
- autojudge = "1";
- else
- autojudge = "0";
- string unit_desc = ugr.Cells["UNIT_DESC"].Value.ToString();
- string userName = UserInfo.GetUserName();
- string validflag = ugr.Cells["validflag"].Value.ToString();
- if (validflag.Equals("无效"))
- {
- errMessage = "无效记录不能保存";
- return null;
- }
- string memo = ugr.Cells["memo"].Value.ToString();
- //list.Add(psc);
- list.Add(psc_desc);
- list.Add(produccode);
- list.Add(producname);
- list.Add(std_code);
- list.Add(std_name);
- list.Add(steelcode);
- list.Add(steelname);
- list.Add(std_style);
- list.Add(std_style_desc);
- list.Add(new_proc_code);
- list.Add(new_proc_desc);
- list.Add(department_code);
- list.Add(department_desc);
- list.Add(unit_code);
- list.Add(autojudge);
- list.Add(unit_desc);
- list.Add(userName);
- list.Add(memo);
- return list;
- }
- /// <summary>
- /// 获取客户数据
- /// </summary>
- /// <param name="ugr"></param>
- /// <returns></returns>
- private ArrayList GetcustData(UltraGridRow ugr)
- {
- ArrayList list = new ArrayList();
- string std_code = ugr.Cells["STD_CODE"].Value.ToString();
- string std_name = ugr.Cells["STD_NAME"].Value.ToString();
- string cust_code = ugr.Cells["CUST_CODE"].Value.ToString();
- string cust_name = ugr.Cells["CUST_NAME"].Value.ToString();
- if (cust_name.Equals(""))
- {
- errMessage = "请选择最终客户";
- }
- string userName = UserInfo.GetUserName();
- string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
- if (validflag.Equals("无效"))
- {
- errMessage = "无效记录不能保存";
- return null;
- }
- string memo = "";
- list.Add(std_code);
- list.Add(std_name);
- list.Add(cust_code);
- list.Add(cust_name);
- list.Add(userName);
- list.Add(memo);
- return list;
- }
- //-----------------------------------------ultraGrid3
- private void ultraGrid3_AfterRowInsert(object sender, RowEventArgs e)
- {
- UltraGridRow ugr = ultraGrid3.DisplayLayout.ActiveRow;
- ugr.Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim();
- ugr.Cells["STD_CODE"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_CODE"].Value.ToString().Trim();
- }
- private void ultraGrid3_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid3.UpdateData();
- UltraGridRow ugr = ultraGrid3.DisplayLayout.ActiveRow;
- if (e.Cell.Column.Key.Equals("CUST_CODE")) //客户
- {
- ugr.Cells["CUST_NAME"].Value = ugr.Cells["CUST_CODE"].Text;
- }
- if (e.Cell.Column.Key.Equals("CHC"))//选择
- {
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- isSelectData += 1;
- }
- else
- isSelectData -= 1;
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("CHC"))
- {
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- }
- private void ultraGrid3_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;
- }
- }
- /// <summary>
- /// 伸缩
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
- {
- if (ultraExpandableGroupBox1.Expanded)
- splitContainer2.SplitterDistance = distance;
- else
- splitContainer2.SplitterDistance = this.Height;
- }
- private void FrmStandard1_Shown(object sender, EventArgs e)
- {
- distance = splitContainer2.SplitterDistance;
- disWidth = splitContainer1.SplitterDistance; ;
- }
- private void ultraExpandableGroupBox2_ExpandedStateChanged(object sender, EventArgs e)
- {
- if (ultraExpandableGroupBox2.Expanded)
- splitContainer1.SplitterDistance = disWidth;
- else
- splitContainer1.SplitterDistance = this.Width;
- }
- }
- }
|