FrmSG.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using CoreFS.CA06;
  9. using Core.Mes.Client.Common;
  10. using System.Collections;
  11. namespace Core.LgMes.Client.LgDeviceManager
  12. {
  13. public partial class FrmSG : FrmLgDevFunctions//frmModelFormStyle
  14. {
  15. public string strID = ""; //ID
  16. public string strNO = ""; //扇形段编号
  17. public string strCCM = ""; //铸机号
  18. public string strPOS = ""; //位置
  19. public string strSTATUS = ""; //当前状态
  20. public string strCCM_LH = ""; //流号
  21. public FrmSG(OpeBase oba)
  22. {
  23. InitializeComponent();
  24. ob = oba;
  25. }
  26. private void FrmSG_Load(object sender, EventArgs e)
  27. {
  28. this.ultraGroupBox1.Text = "[" + this.strCCM + "]-扇形段[" + this.strNO + "]";
  29. cmbCCM.Text = strCCM;
  30. txtCurrPos.Text = cmbPos.Text = this.strPOS;
  31. txtCurrStatus.Text = cmbStatus.Text = this.strSTATUS;
  32. tbCurrPos.Text = ucmbPos.Text = this.strCCM_LH;
  33. }
  34. private void btnclose_Click(object sender, EventArgs e)
  35. {
  36. this.Close();
  37. }
  38. private string proc_CodeNameExchangeStatus(bool bCodetoName, string str)
  39. {
  40. if (bCodetoName) //代码->名称
  41. {
  42. switch (str)
  43. {
  44. case "0":
  45. return "下线";
  46. case "1":
  47. return "上线";
  48. case "2":
  49. return "维修";
  50. case "3":
  51. return "备用";
  52. default:
  53. return "";
  54. }
  55. }
  56. else
  57. {
  58. switch (str)
  59. {
  60. case "下线":
  61. return "0";
  62. case "上线":
  63. return "1";
  64. case "维修":
  65. return "2";
  66. case "备用":
  67. return "3";
  68. default:
  69. return "";
  70. }
  71. }
  72. }
  73. private void proc_OK()
  74. {
  75. try
  76. {
  77. //string strErr = "";
  78. //string strSql = "select count(1) from DEV_SXD_BASE_INFO where ID = '" + this.strID + "'";
  79. //CallingMessage par = new CallingMessage();
  80. //par.ServerName = "LgDeviceManager";
  81. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  82. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.jjqmanager";
  83. //par.MethodName = "ExecuteCommand_Return";
  84. //par.args = new object[] { strSql };
  85. //DataSet ds = null; //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
  86. string strErr = "";
  87. ArrayList arry = new ArrayList();
  88. arry.Add("FrmSG_Query1");
  89. CommonClientToServer ccs = new CommonClientToServer();
  90. ccs.ob = this.ob;
  91. arry.Add(strID);
  92. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  93. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  94. {
  95. MessageBox.Show("[" + this.strCCM + "]扇形段[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  96. return;
  97. }
  98. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  99. if (iCnt == 0)
  100. {
  101. MessageBox.Show("[" + this.strCCM + "]不存在扇形段[" + this.strNO + "],请录入基础信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  102. return;
  103. }
  104. string strPos = cmbPos.Text.Trim();
  105. string strStatus = proc_CodeNameExchangeStatus(false, cmbStatus.Text.Trim());
  106. string strCcm_s_ID = ucmbPos.Text.Trim();
  107. if (strCcm_s_ID == "")
  108. {
  109. MessageBox.Show("请选择流号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  110. ucmbPos.Focus();
  111. return;
  112. }
  113. if (strStatus == "")
  114. {
  115. MessageBox.Show("请选择状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  116. cmbStatus.Focus();
  117. return;
  118. }
  119. if (strStatus == "1" && strPos == "")
  120. {
  121. MessageBox.Show("请选择位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  122. cmbPos.Focus();
  123. return;
  124. }
  125. ds = null;
  126. strErr = "";
  127. arry.Clear();
  128. arry.Add("FrmSG_Query2");
  129. arry.Add(strID);
  130. //strSql = "select NOWSTATUS, POSITION from DEV_SXD_BASE_INFO where ID = '" + this.strID + "'";
  131. ds=ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  132. //par.args = new object[] { strSql };
  133. //ds = null; //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
  134. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  135. {
  136. MessageBox.Show("[" + this.strCCM + "]扇形段[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  137. return;
  138. }
  139. this.strPOS = Convert.ToString(ds.Tables[0].Rows[0]["POSITION"].ToString().Trim()); //原始状态
  140. this.strSTATUS = Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"].ToString().Trim());
  141. this.strCCM_LH = Convert.ToString(ds.Tables[0].Rows[0]["CCM_S_ID"].ToString());
  142. txtCurrPos.Text = this.strPOS;
  143. txtCurrStatus.Text = proc_CodeNameExchangeStatus(true, this.strSTATUS);
  144. if (this.strSTATUS == "")
  145. {
  146. MessageBox.Show("[" + this.strCCM + "]扇形段[" + this.strNO + "]当前状态不明确,无法设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  147. return;
  148. }
  149. if ((this.strSTATUS == "0" && strStatus == "0") ||
  150. (this.strSTATUS == "2" && strStatus == "2") ||
  151. (this.strSTATUS == "3" && strStatus == "3") ||
  152. ((this.strSTATUS == "1" && strStatus == "1") && (this.strPOS == strPos)))
  153. {
  154. MessageBox.Show("操作无意义!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  155. cmbStatus.Focus();
  156. return;
  157. }
  158. if (this.strSTATUS == "0" && strStatus == "1")
  159. {
  160. MessageBox.Show("不能将[" + this.strCCM + "]扇形段[" + this.strNO + "]从[下线]改为[上线]状态!\r\n如有必要,请先设置为[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  161. cmbStatus.Focus();
  162. return;
  163. }
  164. if (this.strSTATUS == "1" && (strStatus == "2" || strStatus == "3"))
  165. {
  166. MessageBox.Show("不能将[" + this.strCCM + "]扇形段[" + this.strNO + "]从[上线]改为[维修]或[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  167. cmbStatus.Focus();
  168. return;
  169. }
  170. if (this.strSTATUS == "2" && (strStatus == "0" || strStatus == "1"))
  171. {
  172. MessageBox.Show("不能将[" + this.strCCM + "]扇形段[" + this.strNO + "]从[维修]改为[下线]或[上线]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  173. cmbStatus.Focus();
  174. return;
  175. }
  176. //if (this.strSTATUS == "3" && (strStatus == "0" || strStatus == "2"))
  177. //{
  178. // MessageBox.Show("不能将[" + this.strCCM + "]扇形段[" + this.strNO + "]从[备用]改为[下线]或[维修]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  179. // cbbStatus.Focus();
  180. // return;
  181. //}
  182. if (this.strSTATUS == "3" && strStatus == "2")
  183. {
  184. MessageBox.Show("不能将[" + this.strCCM + "]扇形段[" + this.strNO + "]从[备用]改为[维修]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  185. cmbStatus.Focus();
  186. return;
  187. }
  188. if (this.strSTATUS == "0" && strStatus == "2")
  189. {
  190. if (MessageBox.Show("确定[" + this.strCCM + "]扇形段[" + this.strNO + "]开始维修吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  191. {
  192. cmbStatus.Focus();
  193. return;
  194. }
  195. }
  196. if (this.strSTATUS == "1" && strStatus == "0")
  197. {
  198. if (MessageBox.Show("确定[" + this.strCCM + "]扇形段[" + this.strNO + "][下线]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  199. {
  200. cmbStatus.Focus();
  201. return;
  202. }
  203. }
  204. if (this.strSTATUS == "2" && strStatus == "3")
  205. {
  206. if (MessageBox.Show("确定[" + this.strCCM + "]扇形段[" + this.strNO + "]结束维修吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  207. {
  208. cmbStatus.Focus();
  209. return;
  210. }
  211. }
  212. if (strStatus == "1")
  213. {
  214. ds = null;
  215. strErr = "";
  216. arry.Clear();
  217. ccs.ob = ob;
  218. arry.Add("FrmSG_Query3");
  219. arry.Add(strPos);
  220. arry.Add(strID);
  221. //strSql = "select SEGMENTID from DEV_SXD_BASE_INFO where NOWSTATUS = '1' and POSITION = '" + strPos + "' and CCM_ID = (select CCM_ID from DEV_SXD_BASE_INFO where ID = '" + this.strID + "')";
  222. //par.args = new object[] { strSql };
  223. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  224. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  225. {
  226. MessageBox.Show("[" + this.strCCM + "]扇形段[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  227. return;
  228. }
  229. if (ds.Tables[0].Rows.Count > 0)
  230. {
  231. string str = Convert.ToString(ds.Tables[0].Rows[0]["SEGMENTID"].ToString().Trim());
  232. if (MessageBox.Show("当前扇形段[" + str + "]处于[" + this.strCCM + "][" + strPos + "],确定要替换为扇形段[" + this.strNO + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  233. {
  234. cmbStatus.Focus();
  235. return;
  236. }
  237. }
  238. }
  239. string[] strParams = new string[6] { this.strID, strPos,strCcm_s_ID, strStatus, cmbCCM.Text.Trim(),CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName()};
  240. //strErr = "";
  241. //object obj = null; // ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.jjqmanager", "SxdStatus_Change", new object[] { strParams }, out strErr);
  242. string Mse = "";
  243. strErr = "";
  244. ProcedureZ("Core.LgMes.Server.DEV.Methods.DEVPublicMethods", "procedure", new object[] { "RES_LG_TOOLMANAGE.SXDSTATUS_CHANGE", strParams }, ob, out strErr, out Mse);
  245. if (Convert.ToInt32(strErr) > 0)
  246. {
  247. MessageBox.Show(Mse, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  248. JJQCcmNo_Edit();
  249. FrmSegMentManage frm = (FrmSegMentManage)this.Tag;//修改完成,重新加载基础信息
  250. frm.proc_GetBaseInfo(this.strCCM, this.strNO);
  251. this.Close();
  252. }
  253. else
  254. MessageBox.Show(strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  255. }
  256. catch (Exception ex)
  257. {
  258. MessageBox.Show(ex.Message);
  259. }
  260. }
  261. /// <summary>
  262. /// 修改扇形段对应的铸机号
  263. /// </summary>
  264. public void JJQCcmNo_Edit()
  265. {
  266. string strErr = "";
  267. ArrayList arry = new ArrayList();
  268. arry.Add("FrmSXD_CCMNO.Edit");
  269. arry.Add(this.cmbCCM.Text);
  270. arry.Add(strNO);
  271. arry.Add(strID);
  272. CommonClientToServer cctos = new CommonClientToServer();
  273. cctos.ob = this.ob;
  274. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  275. "doSimpleSave", arry, out strErr);
  276. if (strErr != "" && ds != null)
  277. {
  278. MessageBox.Show(strErr);
  279. }
  280. }
  281. private void btnOK_Click(object sender, EventArgs e)
  282. {
  283. this.proc_OK();
  284. }
  285. }
  286. }