华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
8.3 KiB

5 months ago
  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 DevExpress.XtraEditors;
  9. using ICSSoft.Base.Config.AppConfig;
  10. using System.Data.Linq;
  11. using System.Linq;
  12. using ICSSoft.Base.Language.Tool;
  13. using System.Reflection;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.ReferForm;
  16. using ICSSoft.Base.Report;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Frame.Data.Entity;
  19. using ICSSoft.Frame.Data.BLL;
  20. namespace ICSSoft.Frame.APP
  21. {
  22. public partial class FormICSTSECodeAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String rcard = "";
  25. ICSTSERRORCODE entity = new ICSTSERRORCODE();
  26. #region 构造函数
  27. public FormICSTSECodeAdd(string card)
  28. {
  29. InitializeComponent();
  30. txtMUSERName.Text = AppConfig.UserName;
  31. txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  32. txtMUSERName.Properties.ReadOnly = true;
  33. txtMTIME.Properties.ReadOnly = true;
  34. rcard = card;
  35. }
  36. #endregion
  37. #region 关闭 退出
  38. private void btnClose_Click(object sender, EventArgs e)
  39. {
  40. this.Close();
  41. }
  42. #endregion
  43. #region 移动窗体
  44. private const int WM_NCHITTEST = 0x84;
  45. private const int HTCLIENT = 0x1;
  46. private const int HTCAPTION = 0x2;
  47. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  48. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  49. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  50. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  51. //重写窗体,使窗体可以不通过自带标题栏实现移动
  52. protected override void WndProc(ref Message m)
  53. {
  54. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  55. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  56. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  57. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  58. switch (m.Msg)
  59. {
  60. case WM_NCHITTEST:
  61. base.WndProc(ref m);
  62. if ((int)m.Result == HTCLIENT)
  63. m.Result = (IntPtr)HTCAPTION;
  64. return;
  65. }
  66. //拦截双击标题栏、移动窗体的系统消息
  67. if (m.Msg != 0xA3)
  68. {
  69. base.WndProc(ref m);
  70. }
  71. }
  72. #endregion
  73. #region 不良代码组按钮
  74. private void txtECGCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  75. {
  76. ButtonEdit btn = (ButtonEdit)sender;
  77. string sql = "select distinct ECGCODE as [不良代码组代码], ECGDESC as [不良代码组描述] from ICSECG with(nolock) WHERE 1=1";
  78. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  79. //if (obj == null)
  80. //{
  81. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  82. //}
  83. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  84. FormDataRefer reForm = new FormDataRefer();
  85. reForm.FormTitle = "不良代码组信息";
  86. DataTable menuData = data;
  87. reForm.DataSource = menuData;
  88. reForm.MSelectFlag = false;
  89. reForm.RowIndexWidth = 35;
  90. reForm.HideCols.Add("ID");
  91. reForm.FormWidth = 500;
  92. reForm.FormHeight = 500;
  93. //reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  94. if (reForm.ShowDialog() == DialogResult.OK)
  95. {
  96. DataTable retData = reForm.ReturnData;
  97. foreach (DataRow dr in retData.Rows)
  98. {
  99. txtECGCODE.Text = dr["不良代码组代码"].ToString();
  100. //txtItemName.Text = dr["存货名称"].ToString();
  101. }
  102. }
  103. }
  104. #endregion
  105. #region 不良代码按钮
  106. private void txtECODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  107. {
  108. ButtonEdit btn = (ButtonEdit)sender;
  109. string sql = @"select distinct a.ECODE as [不良代码], b.ECDESC as [不良代码描述]
  110. from ICSECG2EC a
  111. left join ICSEC b on a.ECODE=b.ECODE
  112. WHERE a.ECODE not in(select ECODE from ICSTSERRORCODE where ECGCODE='" + txtECGCODE.Text + "') and a.ECGCODE='" + txtECGCODE.Text + "' and 1=1";
  113. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  114. //if (obj == null)
  115. //{
  116. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  117. //}
  118. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  119. FormDataRefer reForm = new FormDataRefer();
  120. reForm.FormTitle = "不良代码信息";
  121. DataTable menuData = data;
  122. reForm.DataSource = menuData;
  123. reForm.MSelectFlag = false;
  124. reForm.RowIndexWidth = 35;
  125. reForm.HideCols.Add("ID");
  126. reForm.FormWidth = 500;
  127. reForm.FormHeight = 500;
  128. //reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  129. if (reForm.ShowDialog() == DialogResult.OK)
  130. {
  131. DataTable retData = reForm.ReturnData;
  132. foreach (DataRow dr in retData.Rows)
  133. {
  134. txtECODE.Text = dr["不良代码"].ToString();
  135. //txtItemName.Text = dr["存货名称"].ToString();
  136. }
  137. }
  138. }
  139. #endregion
  140. #region 新增 修改
  141. private void save_Click(object sender, EventArgs e)
  142. {
  143. if (txtECGCODE.Text.Trim() == "")
  144. {
  145. ICSBaseSimpleCode.AppshowMessageBox("不良代码组不能为空!");
  146. return;
  147. }
  148. if (txtECODE.Text.Trim() == "")
  149. {
  150. ICSBaseSimpleCode.AppshowMessageBox("不良代码不能为空!");
  151. return;
  152. }
  153. ICSTS tsInfo = ICSTSBLL.SearchTSInfoByRcard(rcard, AppConfig.AppConnectString);
  154. entity.ECODE = txtECODE.Text.Trim();
  155. entity.ECGCODE = txtECGCODE.Text.Trim();
  156. entity.TSID = tsInfo.TSID;
  157. entity.RCARD = tsInfo.RCARD;
  158. entity.RCARDSEQ = tsInfo.RCARDSEQ;
  159. entity.MODELCODE = tsInfo.MODELCODE;
  160. entity.ITEMCODE = tsInfo.ITEMCODE;
  161. entity.MOCODE = tsInfo.MOCODE;
  162. entity.MOSEQ =Convert.ToDecimal(tsInfo.MOSEQ);
  163. entity.SHIFTDAY =Convert.ToInt32(tsInfo.SHIFTDAY);
  164. entity.MUSER = AppConfig.UserCode;
  165. entity.MUSERName = AppConfig.UserName;
  166. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  167. entity.WorkPoint = AppConfig.WorkPointCode;
  168. entity.EATTRIBUTE1 = null;
  169. try
  170. {
  171. ICSTSBLL.AddECode(entity, AppConfig.AppConnectString);
  172. this.Close();
  173. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  174. }
  175. catch (Exception ex)
  176. {
  177. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  178. }
  179. }
  180. #endregion
  181. #region 取消
  182. private void can_Click(object sender, EventArgs e)
  183. {
  184. this.Close();
  185. }
  186. #endregion
  187. }
  188. }