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

210 lines
7.9 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.BLL;
  10. using ICSSoft.Base.Config.AppConfig;
  11. using ICSSoft.Frame.Data.Entity;
  12. using System.Data.Linq;
  13. using System.Linq;
  14. using ICSSoft.Base.Language.Tool;
  15. using System.Reflection;
  16. using ICSSoft.Base.Config.DBHelper;
  17. using ICSSoft.Base.ReferForm;
  18. using ICSSoft.Base.Report;
  19. using ICSSoft.Frame.Data.DAL;
  20. using ICSSoft.Base.ReferForm.AppReferForm;
  21. using ICSSoft.Frame.APP;
  22. namespace ICSSoft.Frame.APP
  23. {
  24. public partial class FormICSStackAddEdit : DevExpress.XtraEditors.XtraForm
  25. {
  26. String guid = "";
  27. ICSStack entity = new ICSStack();
  28. #region 构造函数
  29. public FormICSStackAddEdit()
  30. {
  31. InitializeComponent();
  32. }
  33. public FormICSStackAddEdit(String id)
  34. {
  35. InitializeComponent();
  36. guid = id;
  37. }
  38. #endregion
  39. #region 页面加载
  40. private void FormICSStackAddEdit_Load(object sender, EventArgs e)
  41. {
  42. if (guid != "")
  43. {
  44. lblTitle.Text = "修改库位";
  45. entity = ICSStackBLL.select(guid, AppConfig.AppConnectString);
  46. txtStackCode.Text = entity.StackCode;
  47. txtStackName.Text = entity.StackName;
  48. string[] s = txtStackCode.Text.Split('-');
  49. if (s.Length == 5)
  50. {
  51. txtQu.Text = s[1];
  52. txtPai.Text = s[2];
  53. txtCeng.Text = s[3];
  54. txtGe.Text = s[4];
  55. }
  56. txtStorage_Serial.Text = ICSStorageBLL.selectById(entity.Storage_Serial, AppConfig.AppConnectString).StorageCode;
  57. txtStorageName.Text = entity.Storage_Name;
  58. txtMUSER.Text = entity.MUSERName;
  59. MTIME.Text = Convert.ToDateTime(entity.MTIME).ToString();
  60. }
  61. else {
  62. txtMUSER.Text = AppConfig.UserName;
  63. MTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  64. }
  65. }
  66. #endregion
  67. #region 列表
  68. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  69. {
  70. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  71. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  72. }
  73. #endregion
  74. #region 关闭 退出
  75. private void btnClose_Click(object sender, EventArgs e)
  76. {
  77. this.Close();
  78. }
  79. #region 移动窗体
  80. private const int WM_NCHITTEST = 0x84;
  81. private const int HTCLIENT = 0x1;
  82. private const int HTCAPTION = 0x2;
  83. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  84. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  85. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  86. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  87. //重写窗体,使窗体可以不通过自带标题栏实现移动
  88. protected override void WndProc(ref Message m)
  89. {
  90. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  91. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  92. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  93. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  94. switch (m.Msg)
  95. {
  96. case WM_NCHITTEST:
  97. base.WndProc(ref m);
  98. if ((int)m.Result == HTCLIENT)
  99. m.Result = (IntPtr)HTCAPTION;
  100. return;
  101. }
  102. //拦截双击标题栏、移动窗体的系统消息
  103. if (m.Msg != 0xA3)
  104. {
  105. base.WndProc(ref m);
  106. }
  107. }
  108. #endregion
  109. private void can_Click(object sender, EventArgs e)
  110. {
  111. this.Close();
  112. }
  113. #endregion
  114. #region 修改 新增
  115. private void save_Click(object sender, EventArgs e)
  116. {
  117. if (txtStorage_Serial.Text=="")
  118. {
  119. ICSBaseSimpleCode.AppshowMessageBox("库房不能为空!");
  120. return;
  121. }
  122. if (txtQu.Text == ""|| txtPai.Text==""||txtCeng.Text==""||txtGe.Text=="")
  123. {
  124. ICSBaseSimpleCode.AppshowMessageBox("请输入完整的库位编码!");
  125. return;
  126. }
  127. else if (txtQu.Text.Trim().Length != 4 || txtPai.Text.Trim().Length != 2 || txtCeng.Text.Trim().Length != 2 || txtGe.Text.Trim().Length != 2)
  128. {
  129. ICSBaseSimpleCode.AppshowMessageBox("请输入正确位数的库位编码!");
  130. return;
  131. }
  132. txtStackCode.Text = txtStorage_Serial.Text.Trim() + "-" + txtQu.Text.Trim().ToUpper() + "-" + txtPai.Text.Trim().ToUpper() + "-" + txtCeng.Text.Trim().ToUpper() + "-" + txtGe.Text.Trim().ToUpper();
  133. txtStackName.Text = txtStorage_Serial.Text.Trim() + "仓库" + txtQu.Text.Trim().ToUpper() + "区" + txtPai.Text.Trim().ToUpper() + "架" + txtCeng.Text.Trim().ToUpper() + "层" + txtGe.Text.Trim().ToUpper() + "格";
  134. entity.StackCode = txtStackCode.Text.Trim();
  135. entity.StackName = txtStackName.Text.Trim();
  136. entity.Storage_Serial = ICSStorageBLL.selectByCode(txtStorage_Serial.Text.Trim(),AppConfig.AppConnectString).Serial;
  137. entity.Storage_Name = txtStorageName.Text.Trim();
  138. entity.MUSER = AppConfig.UserId;
  139. entity.MUSERName = AppConfig.UserName;
  140. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  141. try
  142. {
  143. ICSStackBLL.AddAndEdit(entity, AppConfig.AppConnectString);
  144. this.Close();
  145. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  146. }catch(Exception ex){
  147. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  148. return;
  149. }
  150. }
  151. #endregion
  152. #region 库房选择列表
  153. private void btnCategory_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  154. {
  155. DataTable data = null;
  156. try
  157. {
  158. data = ICSStackBLL.selectData();
  159. }catch(Exception ex){
  160. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  161. }
  162. FormDataRefer reForm = new FormDataRefer();
  163. reForm.FormTitle = "库房列表";
  164. DataTable menuData = data;
  165. reForm.DataSource = menuData;
  166. reForm.MSelectFlag = false;
  167. reForm.RowIndexWidth = 35;
  168. reForm.FormWidth = 500;
  169. reForm.FormHeight = 500;
  170. if (reForm.ShowDialog() == DialogResult.OK)
  171. {
  172. DataTable retData = reForm.ReturnData;
  173. foreach (DataRow dr in retData.Rows)
  174. {
  175. txtStorage_Serial.Text = dr["库房编号"].ToString();
  176. txtStorageName.Text = dr["库房名称"].ToString();
  177. }
  178. }
  179. }
  180. #endregion
  181. private void panelControl1_Paint(object sender, PaintEventArgs e)
  182. {
  183. }
  184. private void txtStackName_EditValueChanged(object sender, EventArgs e)
  185. {
  186. }
  187. private void txtStackCode_EditValueChanged(object sender, EventArgs e)
  188. {
  189. }
  190. }
  191. }