| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinTree;
- using Core.StlMes.Client.Lims.Data.PipeAndOutdec.数据管理.基础信息管理;
- namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec
- {
- public partial class FrmBaseSynchronizeRelation : FrmBase
- {
- private ComBasePhyEntityFull _comBasePhyEntityFull = new ComBasePhyEntityFull();
- private bool isAdd = false;
- public FrmBaseSynchronizeRelation()
- {
- InitializeComponent();
- }
- private void FrmBaseSynchronizeRelation_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<PipeCheckconsignPhyrelationEntity>(ugGrid.DisplayLayout.Bands[0]);
- doQuery2();
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- doQuery();
- break;
- case "Add":
- doAdd();
- break;
- case "Update":
- doUpdate();
- break;
- case "Delete":
- doDelete();
- break;
- case "Close":
- Close();
- break;
- }
- }
- private void doUpdate()
- {
- if (upEdit.Visible)
- {
- btnSave_Click(null, null);
- }
- else
- {
- if (ugGrid.ActiveRow == null)
- {
- MessageBox.Show("请选择需要更新的数据!");
- return;
- }
- var pipeCheckconsignPhyrelationEntity = ugGrid.ActiveRow.ListObject as PipeCheckconsignPhyrelationEntity;
- if (pipeCheckconsignPhyrelationEntity == null) return;
- upEdit.Visible = true;
- upShow.Visible = false;
- SetValue(pipeCheckconsignPhyrelationEntity);
- }
- }
- private void doDelete()
- {
- if (ugGrid.ActiveRow == null)
- {
- MessageBox.Show("请选择需要删除的数据!");
- return;
- }
- var pipeCheckconsignPhyrelationEntity = ugGrid.ActiveRow.ListObject as PipeCheckconsignPhyrelationEntity;
- if (pipeCheckconsignPhyrelationEntity == null) return;
-
-
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.lims.data.base.FrmBaseSynchronizeRelation";
- ccp.MethodName = "doDelete";
- ccp.ServerParams = new object[] { pipeCheckconsignPhyrelationEntity.Relationkey };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- if (ccp.ReturnInfo.Equals("删除成功!"))
- {
- doQuery();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- private void doAdd()
- {
- if (upEdit.Visible)
- {
- btnSave_Click(null, null);
- }
- else
- {
- upEdit.Visible = true;
- upShow.Visible = false;
- PipeCheckconsignPhyrelationEntity pipeCheckconsignPhyrelationEntity;
- if (ugGrid.ActiveRow == null)
- {
- pipeCheckconsignPhyrelationEntity = new PipeCheckconsignPhyrelationEntity();
- }
- else
- {
- pipeCheckconsignPhyrelationEntity = ugGrid.ActiveRow.ListObject as PipeCheckconsignPhyrelationEntity;
- }
- SetValue(pipeCheckconsignPhyrelationEntity, true);
- }
- }
- private void doQuery()
- {
- if (tbMain.SelectedTab.Index == 0)
- doQuery1();
- else if (tbMain.SelectedTab.Index == 1)
- doQuery2();
- }
- private void doQuery1()
- {
- var PhyCode = "";
- var PhyTypeC = "";
- var PhyType = "";
- if (chkPhyCode.Checked)
- PhyCode = cboPhyCodeQuery.Value.ToString();
- if (chkPhyTypeC.Checked)
- PhyTypeC = cboPhyTypeCQuery.Value.ToString();
- if (chkPhyType.Checked)
- PhyType = cboPhyTypeQuery.Value.ToString();
- List<PipeCheckconsignPhyrelationEntity> listSource = EntityHelper.GetData<PipeCheckconsignPhyrelationEntity>
- (
- "com.steering.lims.data.base.FrmBaseSynchronizeRelation.doQuery",
- new object[] {PhyCode, PhyTypeC, PhyType}, ob);
- pipeCheckconsignPhyrelationEntityBindingSource.DataSource = listSource;
- PublicPipeAndOutdec.RefreshAndAutoSizeColumns(ugGrid, new object[] {}, false);
- }
- private void doQuery2()
- {
- var wf = new WaitingForm2("正在查询,请稍候....");
- try
- {
- List<PipeCheckconsignPhyrelationEntity> listSource = EntityHelper.GetData<PipeCheckconsignPhyrelationEntity>
- (
- "com.steering.lims.data.base.FrmBaseSynchronizeRelation.doQuery",
- new object[] {}, ob);
- treeMain.Nodes.Clear();
- UltraTreeNode activeNode = null;
- treeMain.Nodes.AddRange(
- listSource.GroupBy(p => new {p.PhyType, p.PhyTypeName})
- .Select(
- p =>
- {
- var node = new UltraTreeNode
- {
- Text = string.Format(@"{0}-({1})", p.Key.PhyTypeName, p.Key.PhyType),
- Tag = p.Key.PhyType
- };
- if (_comBasePhyEntityFull != null && _comBasePhyEntityFull.PhyCodeC == p.Key.PhyType)
- {
- node.Expanded = true;
- }
- node.Nodes.AddRange(
- p.GroupBy(a => new {a.PhyTypeC, a.PhyTypeCName}).ToList().Select(a =>
- {
- var nodeC = new UltraTreeNode
- {
- Text = string.Format(@"{0}-({1})", a.Key.PhyTypeCName, a.Key.PhyTypeC),
- Tag = a.Key.PhyTypeC
- };
- if (_comBasePhyEntityFull != null && _comBasePhyEntityFull.PhyCodeC == p.Key.PhyType &&
- _comBasePhyEntityFull.PhyCodeB == a.Key.PhyTypeC)
- {
- nodeC.Expanded = true;
- }
- nodeC.Nodes.AddRange(
- a.GroupBy(b => new {b.PhyCode, b.PhyName}).Select(b =>
- {
- var nodeD = new UltraTreeNode
- {
- Text = string.Format(@"{0}-({1})", b.Key.PhyName, b.Key.PhyCode),
- Tag = b.ToList()
- };
- if (_comBasePhyEntityFull != null && _comBasePhyEntityFull.PhyCodeC == p.Key.PhyType &&
- _comBasePhyEntityFull.PhyCodeB == a.Key.PhyTypeC && _comBasePhyEntityFull.PhyCodeA == b.Key.PhyCode)
- {
- activeNode = nodeD;
- }
- return nodeD;
- }).ToArray());
- return nodeC;
- }).ToArray());
- return node;
- }
- ).ToArray());
- if (activeNode != null)
- {
- activeNode.Selected = true;
- treeMain.ActiveNode = activeNode;
- }
- wf.Close();
- Cursor = Cursors.Default;
- }
- catch (Exception ex)
- {
- wf.Close();
- Cursor = Cursors.Default;
- MessageBox.Show(ex.Message);
- }
-
- }
- private void treeMain_AfterActivate(object sender, NodeEventArgs e)
- {
- if (treeMain.ActiveNode == null) return;
- upShow.Visible = true;
- upEdit.Visible = false;
- if (treeMain.ActiveNode.HasNodes) return;
- ugGrid.DataSource = treeMain.ActiveNode.Tag as List<PipeCheckconsignPhyrelationEntity>;
- ugGrid.Update();
- PublicPipeAndOutdec.RefreshAndAutoSizeColumns(ugGrid, new object[] {}, false);
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- var data = GetEntity();
- if (data.PhyCode == "")
- {
- MessageUtil.ShowWarning("检验项不能为空");
- return;
- }
- if (data.PhyTypeC == "")
- {
- MessageUtil.ShowWarning("试样组不能为空");
- return;
- }
- if (data.PhyType == "")
- {
- MessageUtil.ShowWarning("检验大项不能为空");
- return;
- }
- if (string.IsNullOrWhiteSpace(data.Relationkey))
- {
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.lims.data.base.FrmBaseSynchronizeRelation";
- ccp.MethodName = "doAdd";
- ccp.ServerParams = new object[] {JSONFormat.Format(data)};
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- if (ccp.ReturnInfo.Equals("新增成功!"))
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- doQuery();
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- else
- {
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.lims.data.base.FrmBaseSynchronizeRelation";
- ccp.MethodName = "doUpdate";
- ccp.ServerParams = new object[] {JSONFormat.Format(data)};
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- if (ccp.ReturnInfo.Equals("修改成功!"))
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- doQuery();
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- private void btnCancle_Click(object sender, EventArgs e)
- {
- upEdit.Visible = false;
- upShow.Visible = true;
- }
- private void SetValue(PipeCheckconsignPhyrelationEntity pipeCheckconsignPhyrelationEntity,bool isAdd = false)
- {
- _comBasePhyEntityFull = new ComBasePhyEntityFull
- {
- PhyCodeA = pipeCheckconsignPhyrelationEntity.PhyCode,
- PhyNameA = pipeCheckconsignPhyrelationEntity.PhyName,
- PhyCodeB = pipeCheckconsignPhyrelationEntity.PhyTypeC,
- PhyNameB = pipeCheckconsignPhyrelationEntity.PhyTypeCName,
- PhyCodeC = pipeCheckconsignPhyrelationEntity.PhyType,
- PhyNameC = pipeCheckconsignPhyrelationEntity.PhyTypeName
- };
- SetComBasePhyFull();
- cboPhyCodeDir.Tag = pipeCheckconsignPhyrelationEntity.PhyCodeDir;
- cboPhyCodeDir.Text = pipeCheckconsignPhyrelationEntity.PhyNameDir;
- cboValuename.Text = pipeCheckconsignPhyrelationEntity.Valuename;
- txtDbColumn1.Text = pipeCheckconsignPhyrelationEntity.DbColumn1;
- txtDbColumn2.Text = pipeCheckconsignPhyrelationEntity.DbColumn2;
- txtDbColumn3.Text = pipeCheckconsignPhyrelationEntity.DbColumn3;
- txtDbColumn4.Text = pipeCheckconsignPhyrelationEntity.DbColumn4;
- txtDbColumn5.Text = pipeCheckconsignPhyrelationEntity.DbColumn5;
- txtDbColumn6.Text = pipeCheckconsignPhyrelationEntity.DbColumn6;
- txtDbPara1.Text = pipeCheckconsignPhyrelationEntity.DbPara1;
- txtDbPara2.Text = pipeCheckconsignPhyrelationEntity.DbPara2;
- txtDbPara3.Text = pipeCheckconsignPhyrelationEntity.DbPara3;
- txtDbParaValue1.Text = pipeCheckconsignPhyrelationEntity.DbParaValue1;
- txtDbParaValue2.Text = pipeCheckconsignPhyrelationEntity.DbParaValue2;
- txtDbParaValue3.Text = pipeCheckconsignPhyrelationEntity.DbParaValue3;
- txtFormula1.Text = pipeCheckconsignPhyrelationEntity.Formula1;
- txtFormula2.Text = pipeCheckconsignPhyrelationEntity.Formula2;
- txtFormula3.Text = pipeCheckconsignPhyrelationEntity.Formula3;
- txtFormula4.Text = pipeCheckconsignPhyrelationEntity.Formula4;
- txtFormula5.Text = pipeCheckconsignPhyrelationEntity.Formula5;
- if (!isAdd)
- txtKey.Text = pipeCheckconsignPhyrelationEntity.Relationkey;
- }
- private void SetComBasePhyFull()
- {
- cboPhyCode.Tag = _comBasePhyEntityFull.PhyCodeA;
- cboPhyCode.Text = _comBasePhyEntityFull.PhyNameA;
- cboPhyTypeC.Tag = _comBasePhyEntityFull.PhyCodeB;
- cboPhyTypeC.Text = _comBasePhyEntityFull.PhyNameB;
- cboPhyType.Tag = _comBasePhyEntityFull.PhyCodeC;
- cboPhyType.Text = _comBasePhyEntityFull.PhyNameC;
- showButton();
- }
- public void showButton()
- {
- cboPhyCode.ButtonsRight["Edit"].Visible = true;
- cboPhyCode.ButtonsRight["Comm"].Visible = cboPhyCode.Tag.ToString2() != "0000";
- cboPhyTypeC.ButtonsRight["Edit"].Visible = cboPhyCode.Tag.ToString2() == "0000";
- cboPhyTypeC.ButtonsRight["Comm"].Visible = cboPhyTypeC.ButtonsRight["Edit"].Visible &&
- (cboPhyTypeC.Tag.ToString2() != "0000");
- cboPhyType.ButtonsRight["Edit"].Visible = cboPhyTypeC.Tag.ToString2() == "0000";
- cboPhyType.ButtonsRight["Comm"].Visible = cboPhyType.ButtonsRight["Edit"].Visible &&
- (cboPhyType.Tag.ToString2() != "0000");
- }
- private PipeCheckconsignPhyrelationEntity GetEntity()
- {
- var pipeCheckconsignPhyrelationEntity = new PipeCheckconsignPhyrelationEntity
- {
- PhyCode = cboPhyCode.Tag.ToString2(),
- PhyName = cboPhyCode.Text,
- PhyCodeDir = cboPhyCodeDir.Tag.ToString2(),
- PhyNameDir = cboPhyCodeDir.Text,
- PhyType = cboPhyType.Tag.ToString2(),
- PhyTypeName = cboPhyType.Text,
- PhyTypeC = cboPhyTypeC.Tag.ToString2(),
- PhyTypeCName = cboPhyTypeC.Text,
- Valuename = cboValuename.Text,
- DbColumn1 = txtDbColumn1.Text,
- DbColumn2 = txtDbColumn2.Text,
- DbColumn3 = txtDbColumn3.Text,
- DbColumn4 = txtDbColumn4.Text,
- DbColumn5 = txtDbColumn5.Text,
- DbColumn6 = txtDbColumn6.Text,
- DbPara1 = txtDbPara1.Text,
- DbPara2 = txtDbPara2.Text,
- DbPara3 = txtDbPara3.Text,
- DbParaValue1 = txtDbParaValue1.Text,
- DbParaValue2 = txtDbParaValue2.Text,
- DbParaValue3 = txtDbParaValue3.Text,
- Formula1 = " " + txtFormula1.Text,
- Formula2 = " " + txtFormula2.Text,
- Formula3 = " " + txtFormula3.Text,
- Formula4 = " " + txtFormula4.Text,
- Formula5 = " " + txtFormula5.Text,
- Relationkey = txtKey.Text
- };
- return pipeCheckconsignPhyrelationEntity;
- }
- private void cboPhyCode_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- var ultraTextEditor = sender as UltraTextEditor;
- if (ultraTextEditor == null) return;
- if (e.Button.Key == "Comm")
- {
- ultraTextEditor.Tag = "0000";
- ultraTextEditor.Text = "通用";
- showButton();
- }
- else if (e.Button.Key == "Edit")
- {
- using (var PhyCodeSelect = new PhyCodeSelect(ob, _comBasePhyEntityFull, ultraTextEditor == cboPhyCode ? "1" : ultraTextEditor == cboPhyTypeC?"2":ultraTextEditor == cboPhyType?"3":"'"))
- {
- if (PhyCodeSelect.ShowDialog() == DialogResult.OK)
- {
- _comBasePhyEntityFull = PhyCodeSelect.SelectRow;
- SetComBasePhyFull();
- }
- }
- }
- }
- private void cboPhyCodeDir_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- using (var phyCodeSelect = new PhyCodeSelect(ob, new ComBasePhyEntityFull(), "1"))
- {
- if (phyCodeSelect.ShowDialog() == DialogResult.OK)
- {
- cboPhyCodeDir.Tag = phyCodeSelect.SelectRow.PhyCodeA;
- cboPhyCodeDir.Text = phyCodeSelect.SelectRow.PhyNameA;
- }
- }
- }
- }
- }
|