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

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