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

289 lines
10 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 FormICSINVReceiptAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String guid = "";
  25. int flag;
  26. FormICSINVReceiptUIModel model;
  27. #region 构造函数
  28. public FormICSINVReceiptAdd()
  29. {
  30. InitializeComponent();
  31. flag = 0;
  32. chargeFormState("Add");
  33. txtCreateUSER.Text = AppConfig.UserName;
  34. txtmuser.Text = AppConfig.UserName;
  35. txttime.Text = Convert.ToString(DateTime.Now);
  36. }
  37. public FormICSINVReceiptAdd(String Rguid, string RMTIME)
  38. {
  39. InitializeComponent();
  40. flag = 1;
  41. chargeFormState("Edit");
  42. guid = Rguid;
  43. txtmuser.Text = AppConfig.UserName;
  44. txttime.Text = RMTIME;
  45. SearchInfo(Rguid);
  46. }
  47. #endregion
  48. private void chargeFormState(string state)
  49. {
  50. switch (state)
  51. {
  52. case "Add":
  53. txtReceiptNO.Properties.ReadOnly = false;
  54. break;
  55. case "Edit":
  56. txtReceiptNO.Properties.ReadOnly = true;
  57. break;
  58. }
  59. }
  60. private void SearchInfo(string Rguid)
  61. {
  62. model = ICSINVReceiptBLL.SearchInfoByID(Rguid, AppConfig.AppConnectString);
  63. txtReceiptNO.Text = model.ReceiptNO;
  64. txtRECTYPE.Text = model.RECTYPE;
  65. txtStorageID.Tag = model.sto as FormICSStorageUIModel;
  66. txtStorageID.Text = model.sto.StorageName;
  67. if (model.ven != null)
  68. {
  69. txtVENDORCODE.Tag = model.ven as FormICSVendorUIModel;
  70. txtVENDORCODE.Text = model.ven.VendorName;
  71. }
  72. txtMEMO.Text = model.MEMO;
  73. txtCreateTIME.Text = Convert.ToString(model.CreateTIME);
  74. txtCreateUSER.Text = model.CreateUSER;
  75. }
  76. #region 关闭 退出
  77. private void btnClose_Click(object sender, EventArgs e)
  78. {
  79. this.Close();
  80. }
  81. #endregion
  82. #region 移动窗体
  83. private const int WM_NCHITTEST = 0x84;
  84. private const int HTCLIENT = 0x1;
  85. private const int HTCAPTION = 0x2;
  86. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  87. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  88. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  89. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  90. //重写窗体,使窗体可以不通过自带标题栏实现移动
  91. protected override void WndProc(ref Message m)
  92. {
  93. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  94. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  95. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  96. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  97. switch (m.Msg)
  98. {
  99. case WM_NCHITTEST:
  100. base.WndProc(ref m);
  101. if ((int)m.Result == HTCLIENT)
  102. m.Result = (IntPtr)HTCAPTION;
  103. return;
  104. }
  105. //拦截双击标题栏、移动窗体的系统消息
  106. if (m.Msg != 0xA3)
  107. {
  108. base.WndProc(ref m);
  109. }
  110. }
  111. #endregion
  112. #region 新增 修改
  113. private void save_Click(object sender, EventArgs e)
  114. {
  115. try
  116. {
  117. #region 判断是否为空
  118. if (txtReceiptNO.Text.Trim() == "")
  119. {
  120. ICSBaseSimpleCode.AppshowMessageBox("入库单号不能为空");
  121. return;
  122. }
  123. if (txtRECTYPE.Text.Trim() == "")
  124. {
  125. ICSBaseSimpleCode.AppshowMessageBox("入库单类型不能为空");
  126. return;
  127. }
  128. if (txtStorageID.Text.Trim() == "")
  129. {
  130. ICSBaseSimpleCode.AppshowMessageBox("库别不能为空");
  131. return;
  132. }
  133. #endregion
  134. if (flag == 0)
  135. {
  136. bool b = ICSINVReceiptBLL.IsIncluding(txtReceiptNO.Text.Trim(), AppConfig.WorkPointCode,AppConfig.AppConnectString);
  137. if (!b)
  138. {
  139. ICSBaseSimpleCode.AppshowMessageBox("入库单号已经存在");
  140. return;
  141. }
  142. }
  143. FormICSINVReceiptUIModel inv = new FormICSINVReceiptUIModel();
  144. inv.ID = guid;
  145. inv.ReceiptNO = txtReceiptNO.Text;
  146. inv.RECTYPE = txtRECTYPE.Text;
  147. //inv.RECSTATUS ="新建";
  148. //库别
  149. inv.sto = new FormICSStorageUIModel();
  150. inv.sto = txtStorageID.Tag as FormICSStorageUIModel;
  151. //厂商
  152. if (txtVENDORCODE.Tag != null)
  153. {
  154. inv.ven = new FormICSVendorUIModel();
  155. inv.ven = txtVENDORCODE.Tag as FormICSVendorUIModel;
  156. }
  157. inv.MEMO = txtMEMO.Text;
  158. inv.CreateTIME = Convert.ToDateTime(txtCreateTIME.Text);
  159. inv.CreateUSER = txtCreateUSER.Text;
  160. ICSINVReceiptBLL.Add(inv, AppConfig.AppConnectString);
  161. if (flag == 0)
  162. {
  163. ICSBaseSimpleCode.AppshowMessageBox("新增成功");
  164. }
  165. else if (flag == 1)
  166. {
  167. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. MessageBox.Show(ex.Message);
  173. }
  174. this.Close();
  175. this.DialogResult = DialogResult.Yes;
  176. }
  177. #endregion
  178. #region 取消
  179. private void can_Click(object sender, EventArgs e)
  180. {
  181. this.Close();
  182. }
  183. #endregion
  184. //库别
  185. private void txtStorageID_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  186. {
  187. DataTable dt = ICSINVReceiptBLL.SearchStorageInfoList(AppConfig.AppConnectString);
  188. FormDataRefer reForm = new FormDataRefer();
  189. reForm.FormTitle = "库别";
  190. reForm.DataSource = dt;
  191. reForm.MSelectFlag = false;
  192. reForm.RowIndexWidth = 35;
  193. reForm.HideCols.Add("Serial");
  194. reForm.FormWidth = 500;
  195. reForm.FormHeight = 500;
  196. if (reForm.ShowDialog() == DialogResult.OK)
  197. {
  198. DataTable retData = reForm.ReturnData;
  199. foreach (DataRow dr in retData.Rows)
  200. {
  201. FormICSStorageUIModel storage = new FormICSStorageUIModel();
  202. storage.Serial = dr["Serial"].ToString();
  203. storage.StorageCode = dr["库别代码"].ToString();
  204. storage.StorageName = dr["库别名称"].ToString();
  205. txtStorageID.Text = storage.StorageCode;
  206. txtStorageID.Tag = storage;
  207. break;
  208. }
  209. }
  210. }
  211. //厂商
  212. private void txtVENDORCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  213. {
  214. DataTable dt = ICSINVReceiptBLL.SearchVendorInfoList(AppConfig.AppConnectString);
  215. FormDataRefer reForm = new FormDataRefer();
  216. reForm.FormTitle = "厂商";
  217. reForm.DataSource = dt;
  218. reForm.MSelectFlag = false;
  219. reForm.RowIndexWidth = 35;
  220. reForm.HideCols.Add("ID");
  221. reForm.FormWidth = 500;
  222. reForm.FormHeight = 500;
  223. if (reForm.ShowDialog() == DialogResult.OK)
  224. {
  225. DataTable retData = reForm.ReturnData;
  226. foreach (DataRow dr in retData.Rows)
  227. {
  228. FormICSVendorUIModel vendor = new FormICSVendorUIModel();
  229. vendor.ID = dr["ID"].ToString();
  230. vendor.VendorCode = dr["厂商代码"].ToString();
  231. vendor.VendorName = dr["厂商名称"].ToString();
  232. txtVENDORCODE.Text = vendor.VendorCode;
  233. txtVENDORCODE.Tag = vendor;
  234. break;
  235. }
  236. }
  237. }
  238. private void txtStorageID_KeyPress(object sender, KeyPressEventArgs e)
  239. {
  240. if (e.KeyChar != (char)Keys.Back)
  241. {
  242. e.Handled = true;
  243. }
  244. }
  245. private void txtStorageID_KeyDown(object sender, KeyEventArgs e)
  246. {
  247. this.txtStorageID.Text = "";
  248. this.txtStorageID.Tag = null;
  249. }
  250. private void txtVENDORCODE_KeyPress(object sender, KeyPressEventArgs e)
  251. {
  252. if (e.KeyChar != (char)Keys.Back)
  253. {
  254. e.Handled = true;
  255. }
  256. }
  257. private void txtVENDORCODE_KeyDown(object sender, KeyEventArgs e)
  258. {
  259. this.txtVENDORCODE.Text = "";
  260. this.txtVENDORCODE.Tag = null;
  261. }
  262. }
  263. }