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

188 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.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 FormICSINVBusinessAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String guid = "";
  25. FormICSINVBusinessUIModel modelma;
  26. int flag;
  27. #region 构造函数
  28. public FormICSINVBusinessAdd()
  29. {
  30. InitializeComponent();
  31. flag = 0;
  32. txtmuser.Text = AppConfig.UserName;
  33. txttime.Text = Convert.ToString(DateTime.Now);
  34. chargeFormState("Add");
  35. }
  36. public FormICSINVBusinessAdd(String maid,string time)
  37. {
  38. InitializeComponent();
  39. guid = maid;
  40. txtmuser.Text = AppConfig.UserName;
  41. txttime.Text = time;
  42. chargeFormState("Edit");
  43. SearchMAInfo(guid);
  44. flag = 1;
  45. }
  46. #endregion
  47. private void chargeFormState(string state)
  48. {
  49. switch (state)
  50. {
  51. case "Add":
  52. txtBusinessCode.Properties.ReadOnly = false;
  53. break;
  54. case "Edit":
  55. txtBusinessCode.Properties.ReadOnly = true;
  56. break;
  57. }
  58. }
  59. private void SearchMAInfo(string guid)
  60. {
  61. modelma = ICSINVBusinessBLL.SearchMAInfoByID(guid, AppConfig.AppConnectString);
  62. txtBusinessCode.Text = modelma.BusinessCode;
  63. txtBusinessDesc.Text = modelma.BusinessDesc;
  64. txtBusinessType.Text = modelma.BusinessType;
  65. txtISFIFO.Text = modelma.ISFIFO;
  66. }
  67. #region 关闭 退出
  68. private void btnClose_Click(object sender, EventArgs e)
  69. {
  70. this.Close();
  71. }
  72. #endregion
  73. #region 移动窗体
  74. private const int WM_NCHITTEST = 0x84;
  75. private const int HTCLIENT = 0x1;
  76. private const int HTCAPTION = 0x2;
  77. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  78. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  79. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  80. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  81. //重写窗体,使窗体可以不通过自带标题栏实现移动
  82. protected override void WndProc(ref Message m)
  83. {
  84. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  85. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  86. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  87. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  88. switch (m.Msg)
  89. {
  90. case WM_NCHITTEST:
  91. base.WndProc(ref m);
  92. if ((int)m.Result == HTCLIENT)
  93. m.Result = (IntPtr)HTCAPTION;
  94. return;
  95. }
  96. //拦截双击标题栏、移动窗体的系统消息
  97. if (m.Msg != 0xA3)
  98. {
  99. base.WndProc(ref m);
  100. }
  101. }
  102. #endregion
  103. #region 新增 修改
  104. private void save_Click(object sender, EventArgs e)
  105. {
  106. try
  107. {
  108. #region 判断是否为空
  109. if (txtBusinessCode.Text.Trim() == "")
  110. {
  111. ICSBaseSimpleCode.AppshowMessageBox("业务类型代码不能为空");
  112. return;
  113. }
  114. if (txtBusinessDesc.Text.Trim() == "")
  115. {
  116. ICSBaseSimpleCode.AppshowMessageBox("业务类型描述不能为空");
  117. return;
  118. }
  119. if (txtBusinessType.Text.Trim() == "")
  120. {
  121. ICSBaseSimpleCode.AppshowMessageBox("入库/出库不能为空");
  122. return;
  123. }
  124. #endregion
  125. //业务类型代码是否已经存在
  126. if (flag == 0)
  127. {
  128. bool b = ICSINVBusinessBLL.IsIncluding(txtBusinessCode.Text.Trim(),AppConfig.WorkPointCode, AppConfig.AppConnectString);
  129. if (!b)
  130. {
  131. ICSBaseSimpleCode.AppshowMessageBox("业务类型代码已经存在");
  132. return;
  133. }
  134. }
  135. FormICSINVBusinessUIModel maInfo = new FormICSINVBusinessUIModel();
  136. maInfo.ID = guid;
  137. maInfo.BusinessCode = txtBusinessCode.Text;
  138. maInfo.BusinessDesc = txtBusinessDesc.Text;
  139. maInfo.BusinessType = txtBusinessType.Text;
  140. maInfo.ISFIFO = txtISFIFO.Text;
  141. ICSINVBusinessBLL.Add(maInfo, AppConfig.AppConnectString);
  142. if (flag == 0)
  143. {
  144. ICSBaseSimpleCode.AppshowMessageBox("增加成功");
  145. }
  146. else if (flag == 1)
  147. {
  148. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. MessageBox.Show(ex.Message);
  154. }
  155. this.Close();
  156. this.DialogResult = DialogResult.Yes;
  157. }
  158. #endregion
  159. #region 取消
  160. private void can_Click(object sender, EventArgs e)
  161. {
  162. this.Close();
  163. }
  164. #endregion
  165. }
  166. }