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

321 lines
12 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. using System.Text.RegularExpressions;
  21. namespace ICSSoft.Frame.APP
  22. {
  23. public partial class FormICSINVENTORYAdd : DevExpress.XtraEditors.XtraForm
  24. {
  25. String guid = "";
  26. ICSINVENTORY entity = new ICSINVENTORY();
  27. #region 构造函数
  28. public FormICSINVENTORYAdd()
  29. {
  30. InitializeComponent();
  31. }
  32. public FormICSINVENTORYAdd(String id)
  33. {
  34. InitializeComponent();
  35. guid = id;
  36. }
  37. #endregion
  38. #region 关闭 退出
  39. private void btnClose_Click(object sender, EventArgs e)
  40. {
  41. this.Close();
  42. }
  43. #endregion
  44. #region 移动窗体
  45. private const int WM_NCHITTEST = 0x84;
  46. private const int HTCLIENT = 0x1;
  47. private const int HTCAPTION = 0x2;
  48. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  49. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  50. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  51. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  52. //重写窗体,使窗体可以不通过自带标题栏实现移动
  53. protected override void WndProc(ref Message m)
  54. {
  55. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  56. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  57. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  58. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  59. switch (m.Msg)
  60. {
  61. case WM_NCHITTEST:
  62. base.WndProc(ref m);
  63. if ((int)m.Result == HTCLIENT)
  64. m.Result = (IntPtr)HTCAPTION;
  65. return;
  66. }
  67. //拦截双击标题栏、移动窗体的系统消息
  68. if (m.Msg != 0xA3)
  69. {
  70. base.WndProc(ref m);
  71. }
  72. }
  73. #endregion
  74. #region 产品类别
  75. private void txtINVCLASS_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  76. {
  77. ButtonEdit btn = (ButtonEdit)sender;
  78. string sql = "select distinct MODELCODE as [产品别代码], MODELDESC as [产品别描述] from ICSMODEL with(nolock) WHERE 1=1";
  79. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  80. //if (obj == null)
  81. //{
  82. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  83. //}
  84. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  85. FormDataRefer reForm = new FormDataRefer();
  86. reForm.FormTitle = "产品别信息";
  87. DataTable menuData = data;
  88. reForm.DataSource = menuData;
  89. reForm.MSelectFlag = false;
  90. reForm.RowIndexWidth = 35;
  91. reForm.HideCols.Add("ID");
  92. reForm.FormWidth = 500;
  93. reForm.FormHeight = 500;
  94. //reForm.FilterKey = btn.Text;
  95. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  96. if (reForm.ShowDialog() == DialogResult.OK)
  97. {
  98. DataTable retData = reForm.ReturnData;
  99. foreach (DataRow dr in retData.Rows)
  100. {
  101. txtINVCLASS.Text = dr["产品别代码"].ToString();
  102. }
  103. }
  104. }
  105. #endregion
  106. #region 供应商类别
  107. private void txtVENDORCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  108. {
  109. ButtonEdit btn = (ButtonEdit)sender;
  110. string sql = "select distinct VendorCode as [供应商代码], VendorName as [供应商名称] from ICSVendor with(nolock) WHERE 1=1";
  111. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  112. //if (obj == null)
  113. //{
  114. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  115. //}
  116. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  117. FormDataRefer reForm = new FormDataRefer();
  118. reForm.FormTitle = "供应商信息";
  119. DataTable menuData = data;
  120. reForm.DataSource = menuData;
  121. reForm.MSelectFlag = false;
  122. reForm.RowIndexWidth = 35;
  123. reForm.HideCols.Add("ID");
  124. reForm.FormWidth = 500;
  125. reForm.FormHeight = 500;
  126. //reForm.FilterKey = btn.Text;
  127. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  128. if (reForm.ShowDialog() == DialogResult.OK)
  129. {
  130. DataTable retData = reForm.ReturnData;
  131. foreach (DataRow dr in retData.Rows)
  132. {
  133. txtVENDORCODE.Text = dr["供应商代码"].ToString();
  134. }
  135. }
  136. }
  137. #endregion
  138. #region 新增 修改
  139. private void save_Click(object sender, EventArgs e)
  140. {
  141. if (txtINVCODE.Text.Trim() == "")
  142. {
  143. ICSBaseSimpleCode.AppshowMessageBox("存货编码不能为空!");
  144. return;
  145. }
  146. if (txtINVTYPE.Text.Trim() == "")
  147. {
  148. ICSBaseSimpleCode.AppshowMessageBox("存货类型不能为空!");
  149. return;
  150. }
  151. if (txtINVTYPE.Text.Trim() == "")
  152. {
  153. ICSBaseSimpleCode.AppshowMessageBox("存货类别不能为空!");
  154. return;
  155. }
  156. if (txtINVCONTROLTYPE.Text.Trim() == "")
  157. {
  158. ICSBaseSimpleCode.AppshowMessageBox("管控类型不能为空!");
  159. return;
  160. }
  161. Regex rex = new Regex(@"^\d+$");
  162. entity.INVCODE = txtINVCODE.Text.Trim();
  163. entity.INVNAME = txtINVNAME.Text.Trim();
  164. entity.INVDESC = txtINVDESC.Text.Trim();
  165. entity.INVUOM = txtINVUOM.Text.Trim();
  166. entity.INVTYPE = txtINVTYPE.Text.Trim();
  167. entity.INVCLASS = txtINVCLASS.Text.Trim();
  168. entity.INVMACHINETYPE = txtINVMACHINETYPE.Text.Trim();
  169. entity.INVVOLUME = txtINVVOLUME.Text.Trim();
  170. entity.INVMODELCODE = txtINVMODELCODE.Text.Trim();
  171. entity.INVEXPORTIMPORT = "";
  172. entity.INVMODELGROUP = "";
  173. entity.INVGROUP = txtINVGROUP.Text.Trim();
  174. entity.INVGROUPDESC = txtINVGROUPDESC.Text.Trim();
  175. entity.INVCONTROLTYPE = txtINVCONTROLTYPE.Text.Trim();
  176. entity.MUSER = AppConfig.UserId;
  177. entity.MUSERName = AppConfig.UserName;
  178. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  179. entity.WorkPoint = AppConfig.WorkPointCode;
  180. entity.EATTRIBUTE1 = null;
  181. entity.INVPARSETYPE = txtINVPARSETYPE.Text.Trim();
  182. entity.CHECKSTATUS = txtCHECKSTATUS.Text.Trim();
  183. entity.INVCHECKTYPE = txtINVCHECKTYPE.Text.Trim();
  184. int i = 1;
  185. if (int.TryParse(txtSNLENGTH.Text.Trim(),out i))
  186. {
  187. entity.SNLENGTH = int.Parse(txtSNLENGTH.Text.Trim());
  188. }
  189. entity.VENDORCODE = txtVENDORCODE.Text.Trim();
  190. entity.ROHS = "N";
  191. entity.NeedVendor = txtNeedVendor.Text.Trim();
  192. if (int.TryParse(txtINVShelfLife.Text.Trim(), out i))
  193. {
  194. if (!rex.Match(txtINVShelfLife.Text).Success)
  195. {
  196. ICSBaseSimpleCode.AppshowMessageBox("保存期天数需填入正整数!");
  197. return;
  198. }
  199. entity.INVShelfLife = int.Parse(txtINVShelfLife.Text.Trim());
  200. }
  201. if (int.TryParse(txtINVCARTONQTY.Text.Trim(), out i))
  202. {
  203. entity.INVCARTONQTY = int.Parse(txtINVCARTONQTY.Text.Trim());
  204. }
  205. entity.ITEMBURNINQTY = 0;
  206. entity.ELECTRICCURRENTMINVALUE = 0;
  207. entity.ELECTRICCURRENTMAXVALUE = 0;
  208. entity.PCBACOUNT = 0;
  209. entity.CHKITEMOP = txtCHKITEMOP.Text.Trim();
  210. entity.ISSMT = "N";
  211. try
  212. {
  213. ICSINVENTORYBLL.AddandEdit(entity, AppConfig.AppConnectString);
  214. this.Close();
  215. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  216. }
  217. catch (Exception ex)
  218. {
  219. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  220. }
  221. }
  222. #endregion
  223. #region 取消
  224. private void can_Click(object sender, EventArgs e)
  225. {
  226. this.Close();
  227. }
  228. #endregion
  229. #region 页面加载
  230. private void FormICSINVENTORYAdd_Load(object sender, EventArgs e)
  231. {
  232. if (guid != "")
  233. {
  234. lblTitle.Text = "库存档案修改";
  235. txtINVCODE.Properties.ReadOnly = true;
  236. entity = ICSINVENTORYBLL.select(guid, AppConfig.AppConnectString);
  237. txtINVCODE.Text = entity.INVCODE;
  238. txtINVNAME.Text = entity.INVNAME;
  239. txtINVDESC.Text = entity.INVDESC;
  240. txtINVUOM.Text = entity.INVUOM;
  241. txtINVTYPE.Text = entity.INVTYPE;
  242. txtINVCLASS.Text = entity.INVCLASS;
  243. txtINVMACHINETYPE.Text = entity.INVMACHINETYPE;
  244. txtINVVOLUME.Text = entity.INVVOLUME;
  245. txtINVMODELCODE.Text = entity.INVMODELCODE;
  246. txtINVGROUP.Text = entity.INVGROUP;
  247. txtINVGROUPDESC.Text = entity.INVGROUPDESC;
  248. txtINVCONTROLTYPE.Text = entity.INVCONTROLTYPE;
  249. txtINVPARSETYPE.Text = entity.INVPARSETYPE;
  250. txtCHECKSTATUS.Text = entity.CHECKSTATUS;
  251. txtINVCHECKTYPE.Text = entity.INVCHECKTYPE;
  252. txtSNLENGTH.Text = entity.SNLENGTH.ToString();
  253. txtVENDORCODE.Text = entity.VENDORCODE;
  254. txtNeedVendor.Text = entity.NeedVendor;
  255. txtINVShelfLife.Text = entity.INVShelfLife.ToString();
  256. txtINVCARTONQTY.Text = entity.INVCARTONQTY.ToString();
  257. txtCHKITEMOP.Text = entity.CHKITEMOP;
  258. txtINVNAME.Text = entity.INVNAME;
  259. txtMUSERName.Text = entity.MUSERName;
  260. txtMTIME.Text = Convert.ToDateTime(entity.MTIME).ToString();
  261. }
  262. else
  263. {
  264. lblTitle.Text = "库存档案新增";
  265. txtMUSERName.Text = AppConfig.UserName;
  266. txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  267. }
  268. }
  269. #endregion
  270. }
  271. }