| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 |
- using com.steering.mes.zgmil.entity;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.StlMes.Client.ZGMil.Entity;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.ZGMil.Result
- {
- public partial class FrmIPAdress : FrmBase
- {
- public FrmIPAdress()
- {
- InitializeComponent();
-
-
- }
- //实例化类
- private MilBaseAddressEntity MilBase = new MilBaseAddressEntity();
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- CMB_CX1.Enabled = false;
- CMB_CZT1.Enabled = false;
- CMB_GX1.Enabled = false;
- RB_CX.Checked=false;
- RB_CZT.Checked = false;
- RB_GX.Checked = false;
- foreach (UltraGridColumn ugc in this.ultraGrid1.DisplayLayout.Bands[0].Columns)
- {
- ugc.CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
-
- }
- this.ipTB1.Label1.BackColor = Color.Transparent;
- this.ipTB1.Label2.BackColor = Color.Transparent;
- this.ipTB1.Label3.BackColor = Color.Transparent;
- this.ipTB2.Label1.BackColor = Color.Transparent;
- this.ipTB2.Label2.BackColor = Color.Transparent;
- this.ipTB2.Label3.BackColor = Color.Transparent;
- this.ipTB3.Label1.BackColor = Color.Transparent;
- this.ipTB3.Label2.BackColor = Color.Transparent;
- this.ipTB3.Label3.BackColor = Color.Transparent;
- this.ipTB4.Label1.BackColor = Color.Transparent;
- this.ipTB4.Label2.BackColor = Color.Transparent;
- this.ipTB4.Label3.BackColor = Color.Transparent;
- //this.CMB_CX.Text = "250机组";
- //this.CMB_CZT.Text = "1";
- //this.CMB_GZ.Text = "管排锯操作";
- }
- /// <summary>
- /// 查询区域条件选择控件控制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void RB_CheckedChanged(object sender, EventArgs e)
- {
- if (RB_GX.Checked)
- {
- CMB_GX1.Enabled = true;
- CMB_GX1.Text = "管排锯操作";
- }
- else
- {
- CMB_GX1.Enabled = false;
- }
- if (RB_CZT.Checked)
- {
- CMB_CZT1.Enabled = true;
- CMB_CZT1.Text = "1";
- }
- else
- {
- CMB_CZT1.Enabled = false;
- }
- if (RB_CX.Checked)
- {
- CMB_CX1.Enabled = true;
- CMB_CX1.Text = "250机组";
- }
- else
- {
- CMB_CX1.Enabled = false;
- }
- }
- /// <summary>
- /// ToolBar按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "DoQuery":
- Query();
- break;
- case "DoSave":
- Save();
- break;
- case "DoDelete":
- Delete();
- break;
- case "DoAdd":
- Add();
- break;
- case "Close":
- this.Dispose();
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void Query()
- {
- MilBase.Clear();
- if (RB_GX.Checked)
- {
- switch(CMB_GX1.Text.ToString())
- {
- case"管排锯操作":
- MilBase.ProcessNo = "GP";
- break;
- case"矫直操作":
- MilBase.ProcessNo = "JZ";
- break;
- case "涡流探伤操作":
- MilBase.ProcessNo = "ET";
- break;
- case "漏磁探伤操作":
- MilBase.ProcessNo = "MT";
- break;
- case "超声波探伤操作":
- MilBase.ProcessNo = "UT";
- break;
- }
- }
- else
- {
- MilBase.ProcessNo = "";
- }
- if (RB_CZT.Checked)
- {
- MilBase.OperatCode = CMB_CZT1.Text.ToString();
- }
- else
- {
- MilBase.OperatCode = "";
- }
- if (RB_CX.Checked)
- {
- switch(CMB_CX1.Text.ToString())
- {
- case "250机组":
- MilBase.PlineCode = "C008";
- break;
- case "258机组":
- MilBase.PlineCode = "C009";
- break;
- case "168机组":
- MilBase.PlineCode = "C010";
- break;
- case "ASSEL机组":
- MilBase.PlineCode = "C012";
- break;
- case "460机组":
- MilBase.PlineCode = "C017";
- break;
- case "天淮508机组":
- MilBase.PlineCode = "C072";
- break;
- }
- }
- else
- {
- MilBase.PlineCode = "";
- }
-
- DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmIPAdress.Query", new object[] { MilBase },this.ob);
- if (dt.Rows.Count > 0)
- {
- GridHelper.CopyDataToDatatable(dt, dtAdress, true);
- }
- else
- {
- MessageBox.Show("未查询到数据。", "提示",MessageBoxButtons.OK, MessageBoxIcon.Warning );
- }
- }
- #region 废代码
- public bool CheckIPAddress(string ip,DataTable dt)
- {
- bool result = false;
- ArrayList arr = new ArrayList();
- foreach (DataRow dr in dt.Rows)
- {
- if (!string.IsNullOrEmpty(dr["IP_ADDRESS1"].ToString()))
- {
- arr.Add(dr["IP_ADDRESS1"].ToString());
- }
- if (!string.IsNullOrEmpty(dr["IP_ADDRESS2"].ToString()))
- {
- arr.Add(dr["IP_ADDRESS2"].ToString());
- }
- if (!string.IsNullOrEmpty(dr["IP_ADDRESS3"].ToString()))
- {
- arr.Add(dr["IP_ADDRESS3"].ToString());
- }
- if (!string.IsNullOrEmpty(dr["IP_ADDRESS4"].ToString()))
- {
- arr.Add(dr["IP_ADDRESS4"].ToString());
- }
- }
- for (int i = 0; i < arr.Count; i++)
- {
- if (ip.Equals(arr[i]))
- {
- result = true;
- }
- }
- return result;
- }
- public bool BeforeCheck(string str)
- {
- bool result = false;
- MilBaseAddressEntity milb = new MilBaseAddressEntity();
- DataTable dtcheck = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmIPAdress.Query", new object[] { milb }, this.ob);
- if (str.Equals("1"))
- {
- foreach (DataRow dr in dtcheck.Rows)
- {
- if (dr["PROCESS_NO"].ToString().Equals(MilBase.ProcessNo) && dr["OPERAT_CODE"].ToString().Equals(MilBase.OperatCode) && dr["PLINE_CODE"].ToString().Equals(MilBase.PlineCode))
- {
- dtcheck.Rows.Remove(dr);
- }
- }
- }
- if (!string.IsNullOrEmpty(MilBase.IpAddress1.ToString()))
- {
- if (CheckIPAddress(MilBase.IpAddress1.ToString(), dtcheck))
- {
- MessageBox.Show("您输入的操作台IP地址1:【" + MilBase.IpAddress1.ToString() + "】已经录入数据库中,不允许重复录入,请检查后重录", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- }
- }
- if (!string.IsNullOrEmpty(MilBase.IpAddress2.ToString()))
- {
- if (CheckIPAddress(MilBase.IpAddress2.ToString(), dtcheck))
- {
- MessageBox.Show("您输入的操作台IP地址2:【" + MilBase.IpAddress2.ToString() + "】已经录入数据库中,不允许重复录入,请检查后重录", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- }
- }
- if (!string.IsNullOrEmpty(MilBase.IpAddress3.ToString()))
- {
- if (CheckIPAddress(MilBase.IpAddress3.ToString(), dtcheck))
- {
- MessageBox.Show("您输入的操作台IP地址3:【" + MilBase.IpAddress3.ToString() + "】已经录入数据库中,不允许重复录入,请检查后重录", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- }
- }
- if (!string.IsNullOrEmpty(MilBase.IpAddress4.ToString()))
- {
- if (CheckIPAddress(MilBase.IpAddress4.ToString(), dtcheck))
- {
- MessageBox.Show("您输入的操作台IP地址4:【" + MilBase.IpAddress4.ToString() + "】已经录入数据库中,不允许重复录入,请检查后重录", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- }
- }
- return result;
- }
- #endregion
- public bool CheckIPisIn(MilBaseAddressEntity milbase)
- {
- bool result = false;
- if (checkself(milbase))
- {
- MessageBox.Show("您配置的该条操作台IP记录内,有重复IP,请检查修改后重新配置", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- }
- NativeMethodNew na = new NativeMethodNew(this.ob);
- switch (na.CheckIpAddressisin(milbase))
- {
- case 0:
- break;
- case 1:
- MessageBox.Show("您配置的该条操作台IP记录内 IP_ADDRESS1:【" + milbase.IpAddress1 + "】,已存在于数据库", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- break;
- case 2:
- MessageBox.Show("您配置的该条操作台IP记录内 IP_ADDRESS2:【" + milbase.IpAddress2 + "】,已存在于数据库", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- break;
- case 3:
- MessageBox.Show("您配置的该条操作台IP记录内 IP_ADDRESS3:【" + milbase.IpAddress3 + "】,已存在于数据库", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- break;
- case 4:
- MessageBox.Show("您配置的该条操作台IP记录内 IP_ADDRESS4:【" + milbase.IpAddress4 + "】,已存在于数据库", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- result = true;
- break;
- }
- return result;
- }
- public bool checkself(MilBaseAddressEntity milbase)
- {
- bool result=false;
- List<string> list = new List<string>();
- string ip1 = MilBase.IpAddress1.ToString();
- string ip2 = MilBase.IpAddress2.ToString();
- string ip3 = MilBase.IpAddress3.ToString();
- string ip4 = MilBase.IpAddress4.ToString();
- list.Add(ip1); list.Add(ip2); list.Add(ip3); list.Add(ip4);
- if (ip1.Equals(list[1]) || ip1.Equals(list[2]) || ip1.Equals(list[3]))
- {
- if (!string.IsNullOrEmpty(ip1))
- {
- result = true;
- }
- }
- if (ip2.Equals(ip1) || ip2.Equals(ip3) || ip2.Equals(ip4))
- {
- if (!string.IsNullOrEmpty(ip2))
- {
- result = true;
- }
- }
- if (ip3.Equals(ip1) || ip3.Equals(ip2) || ip3.Equals(ip4))
- {
- if (!string.IsNullOrEmpty(ip3))
- {
- result = true;
- }
- }
- if (ip4.Equals(ip1) || ip4.Equals(ip2) || ip4.Equals(ip3))
- {
- if (!string.IsNullOrEmpty(ip4))
- {
- result = true;
- }
- }
- return result;
- }
- private void Add()
- {
- MilBase.Clear();
- MilBase.IpAddress1 = this.ipTB1.Text.ToString();
- MilBase.IpAddress2 = this.ipTB2.Text.ToString();
- MilBase.IpAddress3 = this.ipTB3.Text.ToString();
- MilBase.IpAddress4 = this.ipTB4.Text.ToString();
- MilBase.OperatCode = this.CMB_CZT.Text.ToString();
- switch (this.CMB_CX.Text.ToString())
- {
- case "250机组":
- MilBase.PlineCode = "C008";
- break;
- case "258机组":
- MilBase.PlineCode = "C009";
- break;
- case "168机组":
- MilBase.PlineCode = "C010";
- break;
- case "ASSEL机组":
- MilBase.PlineCode = "C012";
- break;
- case "460机组":
- MilBase.PlineCode = "C017";
- break;
- case "天淮508机组":
- MilBase.PlineCode = "C072";
- break;
- }
- switch (CMB_GZ.Text.ToString())
- {
- case "管排锯操作":
- MilBase.ProcessNo = "GP";
- break;
- case "矫直操作":
- MilBase.ProcessNo = "JZ";
- break;
- case "涡流探伤操作":
- MilBase.ProcessNo = "ET";
- break;
- case "漏磁探伤操作":
- MilBase.ProcessNo = "MT";
- break;
- case "超声波探伤操作":
- MilBase.ProcessNo = "UT";
- break;
- }
- MilBase.OperatName = this.CMB_GZ.Text.ToString() + this.CMB_CZT.Text.ToString() + "台";
- if (this.TXTRich.Text.Length > 40)
- {
- MessageBox.Show("您输入的字符过长,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- MilBase.Remark = this.TXTRich.Text.ToString();
- if (isExist(MilBase))
- {
- MessageBox.Show("已存在该跳数据,请检查并重新输入再进行保存。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- //if (BeforeCheck("0"))
- //{
- // return;
- //}
- if(CheckIPisIn(MilBase))
- {
- return;
- }
- int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmIPAdress.Add", new object[] { MilBase }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("新增数据完成。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- string ProcessNo = MilBase.ProcessNo.ToString();
- string PlineCode = MilBase.PlineCode.ToString();
- string OperatCode = MilBase.OperatCode.ToString();
- Query();
- foreach(UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (ugr.Cells["PROCESS"].Value.ToString().Trim() == ProcessNo && ugr.Cells["PLINE"].Value.ToString().Trim() == PlineCode && ugr.Cells["OPERAT_CODE"].Value.ToString().Trim() == OperatCode)
- {
- this.ultraGrid1.ActiveRow = ugr;
- }
- }
- }
- private void Save()
- {
- MilBase.Clear();
- MilBase.IpAddress1 = this.ipTB1.Text.ToString();
- MilBase.IpAddress2 = this.ipTB2.Text.ToString();
- MilBase.IpAddress3 = this.ipTB3.Text.ToString();
- MilBase.IpAddress4 = this.ipTB4.Text.ToString();
- MilBase.OperatCode = this.CMB_CZT.Text.ToString();
- switch (this.CMB_CX.Text.ToString())
- {
- case "250机组":
- MilBase.PlineCode = "C008";
- break;
- case "258机组":
- MilBase.PlineCode = "C009";
- break;
- case "168机组":
- MilBase.PlineCode = "C010";
- break;
- case "ASSEL机组":
- MilBase.PlineCode = "C012";
- break;
- case "460机组":
- MilBase.PlineCode = "C017";
- break;
- case "天淮508机组":
- MilBase.PlineCode = "C072";
- break;
- }
- switch (CMB_GZ.Text.ToString())
- {
- case "管排锯操作":
- MilBase.ProcessNo = "GP";
- break;
- case "矫直操作":
- MilBase.ProcessNo = "JZ";
- break;
- case "涡流探伤操作":
- MilBase.ProcessNo = "ET";
- break;
- case "漏磁探伤操作":
- MilBase.ProcessNo = "MT";
- break;
- case "超声波探伤操作":
- MilBase.ProcessNo = "UT";
- break;
- }
- MilBase.OperatName = this.CMB_GZ.Text.ToString() + this.CMB_CZT.Text.ToString() + "台";
- if (this.TXTRich.Text.Length > 40)
- {
- MessageBox.Show("您输入的字符过长,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- MilBase.Remark = this.TXTRich.Text.ToString();
- if (!isExist(MilBase))
- {
- MessageBox.Show("不存在该条记录,如果是新增,请点击添加按钮,添加数据", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- //if (BeforeCheck("1"))
- //{
- // return;
- //}
- if (CheckIPisIn(MilBase))
- {
- return;
- }
- int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmIPAdress.Save", new object[] { MilBase }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("修改数据完成。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- string ProcessNo = MilBase.ProcessNo.ToString();
- string PlineCode = MilBase.PlineCode.ToString();
- string OperatCode = MilBase.OperatCode.ToString();
- Query();
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (ugr.Cells["PROCESS"].Value.ToString().Trim() == ProcessNo && ugr.Cells["PLINE"].Value.ToString().Trim() == PlineCode && ugr.Cells["OPERAT_CODE"].Value.ToString().Trim() == OperatCode)
- {
- this.ultraGrid1.ActiveRow = ugr;
- }
- }
-
- }
- private void Delete()
- {
- MilBase.Clear();
- MilBase.IpAddress1 = this.ipTB1.Text.ToString();
- MilBase.IpAddress2 = this.ipTB2.Text.ToString();
- MilBase.IpAddress3 = this.ipTB3.Text.ToString();
- MilBase.IpAddress4 = this.ipTB4.Text.ToString();
- MilBase.OperatCode = this.CMB_CZT.Text.ToString();
- switch (this.CMB_CX.Text.ToString())
- {
- case "250机组":
- MilBase.PlineCode = "C008";
- break;
- case "258机组":
- MilBase.PlineCode = "C009";
- break;
- case "168机组":
- MilBase.PlineCode = "C010";
- break;
- case "ASSEL机组":
- MilBase.PlineCode = "C012";
- break;
- case "460机组":
- MilBase.PlineCode = "C017";
- break;
- case "天淮508机组":
- MilBase.PlineCode = "C072";
- break;
- }
- switch (CMB_GZ.Text.ToString())
- {
- case "管排锯操作":
- MilBase.ProcessNo = "GP";
- break;
- case "矫直操作":
- MilBase.ProcessNo = "JZ";
- break;
- case "涡流探伤操作":
- MilBase.ProcessNo = "ET";
- break;
- case "漏磁探伤操作":
- MilBase.ProcessNo = "MT";
- break;
- case "超声波探伤操作":
- MilBase.ProcessNo = "UT";
- break;
- }
- MilBase.OperatName = this.CMB_GZ.Text.ToString() + this.CMB_CZT.Text.ToString() + "台";
- if (!isExist(MilBase))
- {
- MessageBox.Show("不存在该条记录,请检查后重新删除。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmIPAdress.Delete", new object[] { MilBase }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("删除数据完成。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- Query();
-
-
- }
- /// <summary>
- /// 判断数据是否已经存在
- /// </summary>
- /// <param name="milbase"></param>
- /// <returns></returns>
- private bool isExist(MilBaseAddressEntity milbase)
- {
- bool result = false;
- string processno= milbase.ProcessNo.ToString();
- string operatcode= milbase.OperatCode.ToString();
- string plinecode = milbase.PlineCode.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmIPAdress.isExist", new object[] { milbase }, this.ob);
- if (dt.Rows.Count == 1)
- {
- result = true;
- }
- return result;
-
- }
- /// <summary>
- /// 单击主表事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActive(object sender, EventArgs e)
- {
- UltraGridRow ugr = this.ultraGrid1.ActiveRow;
- this.ipTB1.Text = ugr.Cells["IP_ADDRESS1"].Value.ToString();
- this.ipTB2.Text = ugr.Cells["IP_ADDRESS2"].Value.ToString();
- this.ipTB3.Text = ugr.Cells["IP_ADDRESS3"].Value.ToString();
- this.ipTB4.Text = ugr.Cells["IP_ADDRESS4"].Value.ToString();
- this.CMB_CX.Text = ugr.Cells["PLINE_CODE"].Value.ToString();
- this.CMB_GZ.Text = ugr.Cells["PROCESS_NO"].Value.ToString();
- this.CMB_CZT.Text = ugr.Cells["OPERAT_CODE"].Value.ToString();
- this.TXTRich.Text = ugr.Cells["REMARK"].Value.ToString();
- }
- }
- }
|