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

345 lines
14 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 FormICSInvTransferAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. string guid = "";
  25. int flag;
  26. FormICSInvTransferUIModel model;
  27. #region 构造函数
  28. public FormICSInvTransferAdd()
  29. {
  30. InitializeComponent();
  31. flag = 0;
  32. chargeFormState("Add");
  33. }
  34. public FormICSInvTransferAdd(String id)
  35. {
  36. InitializeComponent();
  37. flag = 1;
  38. chargeFormState("Edit");
  39. SearchInfo(id);
  40. }
  41. #endregion
  42. private void chargeFormState(string state)
  43. {
  44. switch (state)
  45. {
  46. case "Add":
  47. txtTransferSTATUS.Text="新建";
  48. txtTransferSTATUS.Properties.ReadOnly = true;
  49. txtTransferNO.Properties.ReadOnly = false;
  50. txtMUSERName.Text = AppConfig.UserName;
  51. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  52. txtCreateUSER.Text = AppConfig.UserName;
  53. txtEffectedUSER.Text = AppConfig.UserName;
  54. txtMUSERName.Properties.ReadOnly = true;
  55. txtMTIME.Properties.ReadOnly = true;
  56. txtCreateUSER.Properties.ReadOnly = true;
  57. txtEffectedUSER.Properties.ReadOnly = true;
  58. break;
  59. case "Edit":
  60. txtTransferNO.Properties.ReadOnly = true;
  61. txtTransferSTATUS.Properties.ReadOnly = true;
  62. txtFRMStorageCode.Properties.ReadOnly = true;
  63. txtTOStorageCode.Properties.ReadOnly = true;
  64. txtTransferNO.Properties.ReadOnly = true;
  65. txtMUSERName.Properties.ReadOnly = true;
  66. txtMTIME.Properties.ReadOnly = true;
  67. txtCreateUSER.Properties.ReadOnly = true;
  68. txtEffectedUSER.Properties.ReadOnly = true;
  69. break;
  70. }
  71. }
  72. private void SearchInfo(string id)
  73. {
  74. model= ICSInvTransferBLL.SearchInfoByID(id, AppConfig.AppConnectString);
  75. guid = model.ID;
  76. txtTransferNO.Text = model.TransferNO;
  77. txtFRMStorageCode.Text = model.storage1.StorageCode;
  78. txtTOStorageCode.Text = model.storage2.StorageCode;
  79. txtTransferSTATUS.Text = model.TransferSTATUS;
  80. txtRECTYPE.Text = model.RECTYPE;
  81. txtTIMETYPE.Text = model.TIMETYPE;
  82. txtCreateUSER.Text = model.CreateUSER;
  83. txtCreateTIME.Text = model.CreateTIME;
  84. txtEffectedUSER.Text = model.EffectedUSER;
  85. txtEffectedTIME.Text = model.EffectedTIME;
  86. txtMEMO.Text = model.MEMO;
  87. txtMUSERName.Text = model.MUSERName;
  88. txtMTIME.Text = model.MTIME.ToString();
  89. txtTransferNO.Properties.ReadOnly = true;
  90. }
  91. #region 关闭 退出
  92. private void btnClose_Click(object sender, EventArgs e)
  93. {
  94. this.Close();
  95. }
  96. #endregion
  97. #region 移动窗体
  98. private const int WM_NCHITTEST = 0x84;
  99. private const int HTCLIENT = 0x1;
  100. private const int HTCAPTION = 0x2;
  101. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  102. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  103. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  104. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  105. //重写窗体,使窗体可以不通过自带标题栏实现移动
  106. protected override void WndProc(ref Message m)
  107. {
  108. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  109. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  110. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  111. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  112. switch (m.Msg)
  113. {
  114. case WM_NCHITTEST:
  115. base.WndProc(ref m);
  116. if ((int)m.Result == HTCLIENT)
  117. m.Result = (IntPtr)HTCAPTION;
  118. return;
  119. }
  120. //拦截双击标题栏、移动窗体的系统消息
  121. if (m.Msg != 0xA3)
  122. {
  123. base.WndProc(ref m);
  124. }
  125. }
  126. #endregion
  127. #region 新增 修改
  128. private void save_Click(object sender, EventArgs e)
  129. {
  130. try
  131. {
  132. if (txtTransferNO.Text.Trim() == "")
  133. {
  134. ICSBaseSimpleCode.AppshowMessageBox("移转单号不能为空");
  135. return;
  136. }
  137. if (txtTransferSTATUS.Text.Trim() == "")
  138. {
  139. ICSBaseSimpleCode.AppshowMessageBox("转移单状态不能为空");
  140. return;
  141. }
  142. if (txtRECTYPE.Text.Trim() == "")
  143. {
  144. ICSBaseSimpleCode.AppshowMessageBox("入库单类型不能为空");
  145. return;
  146. }
  147. if (txtFRMStorageCode.Text.Trim() == "")
  148. {
  149. ICSBaseSimpleCode.AppshowMessageBox("源库别代码不能为空");
  150. return;
  151. }
  152. if (txtTOStorageCode.Text.Trim() == "")
  153. {
  154. ICSBaseSimpleCode.AppshowMessageBox("目标库别代码不能为空");
  155. return;
  156. }
  157. if (txtFRMStorageCode.Text.Trim() == txtTOStorageCode.Text.Trim())
  158. {
  159. ICSBaseSimpleCode.AppshowMessageBox("源库别代码与目标库别代码相同请重新选择!");
  160. return;
  161. }
  162. FormICSInvTransferUIModel invtransfer = new FormICSInvTransferUIModel();
  163. invtransfer.ID = guid;
  164. DataTable dt = ICSSoft.Frame.Data.BLL.ICSInvTransferBLL.SelectFRMStorageId(txtFRMStorageCode.Text, AppConfig.WorkPointCode);
  165. if (dt != null && dt.Rows.Count > 0)
  166. {
  167. invtransfer.FRMStorageID = dt.Rows[0][0].ToString();
  168. }
  169. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSInvTransferBLL.TOStorageId(txtTOStorageCode.Text, AppConfig.WorkPointCode);
  170. if (dt1 != null && dt1.Rows.Count > 0)
  171. {
  172. invtransfer.TOStorageID = dt1.Rows[0][0].ToString();
  173. }
  174. invtransfer.TransferNO = txtTransferNO.Text;
  175. invtransfer.FRMStorageCode = txtFRMStorageCode.Text;
  176. invtransfer.TOStorageCode = txtTOStorageCode.Text;
  177. invtransfer.TransferSTATUS = txtTransferSTATUS.Text;
  178. invtransfer.RECTYPE = txtRECTYPE.Text;
  179. invtransfer.TIMETYPE = txtTIMETYPE.Text;
  180. invtransfer.MEMO = txtMEMO.Text;
  181. invtransfer.CreateTIME = txtCreateTIME.Text;
  182. invtransfer.CreateUSER = txtCreateUSER.Text;
  183. invtransfer.EffectedTIME = txtEffectedTIME.Text;
  184. invtransfer.EffectedUSER = txtEffectedUSER.Text;
  185. invtransfer.MUSER = AppConfig.UserId;
  186. invtransfer.MUSERName = AppConfig.UserName;
  187. invtransfer.MTIME = System.DateTime.Parse(txtMTIME.Text);
  188. invtransfer.WorkPoint = AppConfig.WorkPointCode;
  189. invtransfer.EATTRIBUTE1 = null;
  190. ICSInvTransferBLL.AddandEdit(invtransfer, AppConfig.AppConnectString);
  191. if (flag == 0)
  192. {
  193. ICSBaseSimpleCode.AppshowMessageBox("新增成功");
  194. }
  195. else if (flag == 1)
  196. {
  197. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  198. }
  199. }
  200. catch (Exception ex)
  201. {
  202. MessageBox.Show(ex.Message);
  203. }
  204. this.Close();
  205. this.DialogResult = DialogResult.Yes;
  206. }
  207. #endregion
  208. #region 取消
  209. private void can_Click(object sender, EventArgs e)
  210. {
  211. this.Close();
  212. }
  213. #endregion
  214. #region 转移源库别代码按钮
  215. private void txtFRMStorageID_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  216. {
  217. ButtonEdit btn = (ButtonEdit)sender;
  218. string sql = "select distinct StorageCode as [转移源库别代码], StorageName as [转移源库别名称] from ICSStorage with(nolock) WHERE 1=1";
  219. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  220. //if (obj == null)
  221. //{
  222. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  223. //}
  224. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  225. FormDataRefer reForm = new FormDataRefer();
  226. reForm.FormTitle = "库别信息";
  227. DataTable menuData = data;
  228. reForm.DataSource = menuData;
  229. reForm.MSelectFlag = false;
  230. reForm.RowIndexWidth = 35;
  231. reForm.HideCols.Add("ID");
  232. reForm.FormWidth = 500;
  233. reForm.FormHeight = 500;
  234. //reForm.FilterKey = btn.Text;
  235. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  236. if (reForm.ShowDialog() == DialogResult.OK)
  237. {
  238. DataTable retData = reForm.ReturnData;
  239. foreach (DataRow dr in retData.Rows)
  240. {
  241. txtFRMStorageCode.Text = dr["转移源库别代码"].ToString();
  242. }
  243. }
  244. }
  245. #endregion
  246. #region 转移目标库别代码按钮
  247. private void txtTOStorageID_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  248. {
  249. ButtonEdit btn = (ButtonEdit)sender;
  250. string sql = "select distinct StorageCode as [转移目标库别代码], StorageName as [转移目标库别名称] from ICSStorage with(nolock) WHERE 1=1";
  251. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  252. //if (obj == null)
  253. //{
  254. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  255. //}
  256. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  257. FormDataRefer reForm = new FormDataRefer();
  258. reForm.FormTitle = "库别信息";
  259. DataTable menuData = data;
  260. reForm.DataSource = menuData;
  261. reForm.MSelectFlag = false;
  262. reForm.RowIndexWidth = 35;
  263. reForm.HideCols.Add("ID");
  264. reForm.FormWidth = 500;
  265. reForm.FormHeight = 500;
  266. //reForm.FilterKey = btn.Text;
  267. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  268. if (reForm.ShowDialog() == DialogResult.OK)
  269. {
  270. DataTable retData = reForm.ReturnData;
  271. foreach (DataRow dr in retData.Rows)
  272. {
  273. txtTOStorageCode.Text = dr["转移目标库别代码"].ToString();
  274. }
  275. }
  276. }
  277. #endregion
  278. #region 入库单类型按钮
  279. private void txtRECTYPE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  280. {
  281. ButtonEdit btn = (ButtonEdit)sender;
  282. string sql = "select distinct BusinessCode as [业务类型代码], BusinessDesc as [业务类型描述] from ICSINVBusiness with(nolock) WHERE BusinessType='入库'";
  283. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  284. //if (obj == null)
  285. //{
  286. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  287. //}
  288. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  289. FormDataRefer reForm = new FormDataRefer();
  290. reForm.FormTitle = "物料出入库类型";
  291. DataTable menuData = data;
  292. reForm.DataSource = menuData;
  293. reForm.MSelectFlag = false;
  294. reForm.RowIndexWidth = 35;
  295. reForm.HideCols.Add("ID");
  296. reForm.FormWidth = 500;
  297. reForm.FormHeight = 500;
  298. //reForm.FilterKey = btn.Text;
  299. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  300. if (reForm.ShowDialog() == DialogResult.OK)
  301. {
  302. DataTable retData = reForm.ReturnData;
  303. foreach (DataRow dr in retData.Rows)
  304. {
  305. txtRECTYPE.Text = dr["业务类型描述"].ToString();
  306. }
  307. }
  308. }
  309. #endregion
  310. }
  311. }