锐腾搅拌上料功能
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.

230 lines
9.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.Frame.Data.Entity;
  10. using ICSSoft.Frame.Data.BLL;
  11. using ICSSoft.Base.Config.AppConfig;
  12. using ICSSoft.Base.Config.DBHelper;
  13. using ICSSoft.Base.ReferForm.AppReferForm;
  14. using DevExpress.Utils.About;
  15. namespace ICSSoft.Frame.APP
  16. {
  17. public partial class FormICSRESAdd : DevExpress.XtraEditors.XtraForm
  18. {
  19. String guid = "";
  20. ICSRES entity = new ICSRES();
  21. public FormICSRESAdd()
  22. {
  23. InitializeComponent();
  24. }
  25. public FormICSRESAdd(string id)
  26. {
  27. InitializeComponent();
  28. guid = id;
  29. }
  30. #region 关闭 退出
  31. private void btnClose_Click(object sender, EventArgs e)
  32. {
  33. this.Close();
  34. }
  35. #endregion
  36. #region 移动窗体
  37. private const int WM_NCHITTEST = 0x84;
  38. private const int HTCLIENT = 0x1;
  39. private const int HTCAPTION = 0x2;
  40. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  41. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  42. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  43. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  44. //重写窗体,使窗体可以不通过自带标题栏实现移动
  45. protected override void WndProc(ref Message m)
  46. {
  47. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  48. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  49. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  50. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  51. switch (m.Msg)
  52. {
  53. case WM_NCHITTEST:
  54. base.WndProc(ref m);
  55. if ((int)m.Result == HTCLIENT)
  56. m.Result = (IntPtr)HTCAPTION;
  57. return;
  58. }
  59. //拦截双击标题栏、移动窗体的系统消息
  60. if (m.Msg != 0xA3)
  61. {
  62. base.WndProc(ref m);
  63. }
  64. }
  65. #endregion
  66. #region 新增 修改
  67. private void save_Click(object sender, EventArgs e)
  68. {
  69. if (txtRESCODE.Text.Trim() == "" || btnSSID.Text.Trim() == "" || btnCREWCODE.Text.Trim() == "")
  70. {
  71. ICSBaseSimpleCode.AppshowMessageBox("值不能为空!");
  72. return;
  73. }
  74. entity.ID = guid;
  75. entity.RESCODE = txtRESCODE.Text.Trim();
  76. entity.RESDESC = txtRESDESC.Text.Trim();
  77. entity.CREWCODE = btnCREWCODE.Text;
  78. entity.RESTYPE = comboBox1.SelectedValue.ToString();
  79. if(guid==""){
  80. entity.SEGID = label11SEGID.Text;
  81. entity.SHIFTTYPEID = label13SHIFTTYPEID.Text;
  82. entity.SSID = label12SSID.Text;
  83. }
  84. entity.MUSER = AppConfig.UserId;
  85. entity.MUSERName = AppConfig.UserName;
  86. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  87. try
  88. {
  89. ICSRESBLL.AddandEdit(entity, AppConfig.AppConnectString);
  90. this.Close();
  91. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  92. }
  93. catch (Exception ex)
  94. {
  95. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  96. }
  97. }
  98. #endregion
  99. #region 取消
  100. private void can_Click(object sender, EventArgs e)
  101. {
  102. this.Close();
  103. }
  104. #endregion
  105. #region 页面加载
  106. private void FormICSItenLotAdd_Load(object sender, EventArgs e)
  107. {
  108. bindCbox();
  109. if (guid != "")
  110. {
  111. labelControl1.Text = "修改资源";
  112. txtRESCODE.Properties.ReadOnly = true;
  113. DataTable dt = ICSRESBLL.select(guid, AppConfig.AppConnectString);
  114. txtRESCODE.Text = dt.Rows[0]["RESCODE"].ToString();
  115. txtRESDESC.Text = dt.Rows[0]["RESDESC"].ToString();
  116. comboBox1.Text = dt.Rows[0]["RESTYPE"].ToString() == "Machine"? "机器":"人工";
  117. txtSEGID.Text = dt.Rows[0]["SEGCODE"].ToString();
  118. btnSSID.Text = dt.Rows[0]["SSCODE"].ToString();
  119. txtSHIFTTYPEID.Text = dt.Rows[0]["SHIFTTYPECODE"].ToString();
  120. btnCREWCODE.Text = dt.Rows[0]["CREWCODE"].ToString();
  121. entity.SEGID = dt.Rows[0]["SEGID"].ToString();
  122. entity.SHIFTTYPEID = dt.Rows[0]["SHIFTTYPEID"].ToString();
  123. entity.SSID = dt.Rows[0]["SSID"].ToString();
  124. txtMuser.Text = dt.Rows[0]["MUSERName"].ToString();
  125. txtMtime.Text = dt.Rows[0]["MTIME"].ToString();
  126. }
  127. else {
  128. labelControl1.Text = "新增资源";
  129. txtMuser.Text = AppConfig.UserName;
  130. txtMtime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  131. }
  132. txtMuser.Properties.ReadOnly = true;
  133. txtMtime.Properties.ReadOnly = true;
  134. }
  135. #endregion
  136. public class Info
  137. {
  138. public string Id { get; set; }
  139. public string Name { get; set; }
  140. }
  141. private void bindCbox()
  142. {
  143. IList<Info> infoList = new List<Info>();
  144. Info info1 = new Info() { Id = "Human", Name = "人工" };
  145. Info info2 = new Info() { Id = "Machine", Name = "机器" };
  146. infoList.Add(info1);
  147. infoList.Add(info2);
  148. comboBox1.DataSource = infoList;
  149. comboBox1.ValueMember = "Id";
  150. comboBox1.DisplayMember = "Name";
  151. }
  152. private void btnSSID_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)//产线参照
  153. {
  154. ButtonEdit btn = (ButtonEdit)sender;
  155. string sql = @"SELECT a.ID,b.ID AS 'SEGID',b.SEGCODE,c.ID AS 'SHIFTTYPEID',c.SHIFTTYPECODE,a.SSCODE AS '产线代码',a.SSDESC AS '产线描述'
  156. FROM dbo.ICSSS a LEFT JOIN dbo.ICSSEG b ON a.SEGID=b.ID LEFT JOIN dbo.ICSSHIFTTYPE c ON a.SHIFTTYPEID=c.ID where 1=1 and a.workpoint = "+AppConfig.WorkPointCode+"";
  157. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  158. FormDataRefer reForm = new FormDataRefer();
  159. reForm.FormTitle = "车间信息";
  160. DataTable menuData = data;
  161. reForm.DataSource = menuData;
  162. reForm.MSelectFlag = false;
  163. reForm.RowIndexWidth = 35;
  164. reForm.HideCols.Add("ID");
  165. reForm.HideCols.Add("SEGID");
  166. reForm.HideCols.Add("SEGCODE");
  167. reForm.HideCols.Add("SHIFTTYPEID");
  168. reForm.HideCols.Add("SHIFTTYPECODE");
  169. reForm.FormWidth = 500;
  170. reForm.FormHeight = 500;
  171. reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  172. if (reForm.ShowDialog() == DialogResult.OK)
  173. {
  174. DataTable retData = reForm.ReturnData;
  175. foreach (DataRow dr in retData.Rows)
  176. {
  177. btnSSID.Text = dr["产线代码"].ToString();
  178. txtSEGID.Text = dr["SEGCODE"].ToString();
  179. txtSHIFTTYPEID.Text = dr["SHIFTTYPECODE"].ToString();
  180. label12SSID.Text = dr["ID"].ToString();
  181. label13SHIFTTYPEID.Text = dr["SHIFTTYPEID"].ToString();
  182. label11SEGID.Text = dr["SEGID"].ToString();
  183. }
  184. }
  185. }
  186. private void btnCREWCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  187. {
  188. ButtonEdit btn = (ButtonEdit)sender;
  189. string sql = @"SELECT ID,CREWCODE AS '班组代码', CREWDESC AS '班组描述' FROM dbo.ICSCREW where 1=1 and workpoint = " + AppConfig.WorkPointCode + "";
  190. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  191. FormDataRefer reForm = new FormDataRefer();
  192. reForm.FormTitle = "班组信息";
  193. DataTable menuData = data;
  194. reForm.DataSource = menuData;
  195. reForm.MSelectFlag = false;
  196. reForm.RowIndexWidth = 35;
  197. reForm.HideCols.Add("ID");
  198. reForm.FormWidth = 500;
  199. reForm.FormHeight = 500;
  200. reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  201. if (reForm.ShowDialog() == DialogResult.OK)
  202. {
  203. DataTable retData = reForm.ReturnData;
  204. foreach (DataRow dr in retData.Rows)
  205. {
  206. btnCREWCODE.Text = dr["班组代码"].ToString();
  207. }
  208. }
  209. }
  210. }
  211. }