华恒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.

159 lines
6.2 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. namespace ICSSoft.Frame.APP
  13. {
  14. public partial class FormICSASNIQCAdd : DevExpress.XtraEditors.XtraForm
  15. {
  16. String guid = "";
  17. ICSCREW entity = new ICSCREW();
  18. public FormICSASNIQCAdd()
  19. {
  20. InitializeComponent();
  21. }
  22. public FormICSASNIQCAdd(string id)
  23. {
  24. InitializeComponent();
  25. guid = id;
  26. }
  27. #region 关闭 退出
  28. private void btnClose_Click(object sender, EventArgs e)
  29. {
  30. this.Close();
  31. }
  32. #endregion
  33. #region 移动窗体
  34. private const int WM_NCHITTEST = 0x84;
  35. private const int HTCLIENT = 0x1;
  36. private const int HTCAPTION = 0x2;
  37. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  38. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  39. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  40. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  41. //重写窗体,使窗体可以不通过自带标题栏实现移动
  42. protected override void WndProc(ref Message m)
  43. {
  44. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  45. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  46. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  47. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  48. switch (m.Msg)
  49. {
  50. case WM_NCHITTEST:
  51. base.WndProc(ref m);
  52. if ((int)m.Result == HTCLIENT)
  53. m.Result = (IntPtr)HTCAPTION;
  54. return;
  55. }
  56. //拦截双击标题栏、移动窗体的系统消息
  57. if (m.Msg != 0xA3)
  58. {
  59. base.WndProc(ref m);
  60. }
  61. }
  62. #endregion
  63. //#region 存货编码按钮
  64. //private void txtItemCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  65. //{
  66. // ButtonEdit btn = (ButtonEdit)sender;
  67. // string sql = "select distinct ItemCode as [存货编码], ItemName as [存货名称] from ICSItemLot with(nolock) WHERE 1=1";
  68. // //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  69. // //if (obj == null)
  70. // //{
  71. // // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  72. // //}
  73. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  74. // FormDataRefer reForm = new FormDataRefer();
  75. // reForm.FormTitle = "产品信息";
  76. // DataTable menuData = data;
  77. // reForm.DataSource = menuData;
  78. // reForm.MSelectFlag = false;
  79. // reForm.RowIndexWidth = 35;
  80. // reForm.HideCols.Add("ID");
  81. // reForm.FormWidth = 500;
  82. // reForm.FormHeight = 500;
  83. // reForm.FilterKey = btn.Text; //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  84. // if (reForm.ShowDialog() == DialogResult.OK)
  85. // {
  86. // DataTable retData = reForm.ReturnData;
  87. // foreach (DataRow dr in retData.Rows)
  88. // {
  89. // txtItemCode.Text = dr["存货编码"].ToString();
  90. // txtItemName.Text = dr["存货名称"].ToString();
  91. // }
  92. // }
  93. //}
  94. //#endregion
  95. #region 新增 修改
  96. private void save_Click(object sender, EventArgs e)
  97. {
  98. if (txtCREWCODE.Text.Trim() == "")
  99. {
  100. ICSBaseSimpleCode.AppshowMessageBox("班组代码不能为空!");
  101. }
  102. entity.CREWCODE = txtCREWCODE.Text.Trim();
  103. entity.CREWDESC=txtCREWDESC.Text.Trim();
  104. entity.MUSER = AppConfig.UserId;
  105. entity.MUSERName = AppConfig.UserName;
  106. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  107. try
  108. {
  109. ICSCREWBLL.AddandEdit(entity, AppConfig.AppConnectString);
  110. this.Close();
  111. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  112. }
  113. catch (Exception ex)
  114. {
  115. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  116. }
  117. }
  118. #endregion
  119. #region 取消
  120. private void can_Click(object sender, EventArgs e)
  121. {
  122. this.Close();
  123. }
  124. #endregion
  125. #region 页面加载
  126. private void FormICSItenLotAdd_Load(object sender, EventArgs e)
  127. {
  128. if (guid != "")
  129. {
  130. labelControl1.Text = "修改班组";
  131. txtCREWCODE.Properties.ReadOnly = true;
  132. entity = ICSCREWBLL.select(guid, AppConfig.AppConnectString);
  133. txtCREWCODE.Text = entity.CREWCODE;
  134. txtCREWDESC.Text = entity.CREWDESC;
  135. txtMuser.Text = entity.MUSERName;
  136. txtMtime.Text = Convert.ToDateTime(entity.MTIME).ToString();
  137. }
  138. else {
  139. labelControl1.Text = "新增班租";
  140. txtMuser.Text = AppConfig.UserName;
  141. txtMtime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  142. }
  143. txtMuser.Properties.ReadOnly = true;
  144. txtMtime.Properties.ReadOnly = true;
  145. }
  146. #endregion
  147. }
  148. }