F_PM_3502.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_010201_1.cs
  5. * 2.功能描述:发货单编辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 冯林勇 2023/1/11 1.00 新建
  9. *******************************************************************************/
  10. using Dongke.IBOSS.PRD.Basics.BaseResources;
  11. using Dongke.IBOSS.PRD.Client.CommonModule;
  12. using Dongke.IBOSS.PRD.Client.Controls;
  13. using Dongke.IBOSS.PRD.WCF.DataModels;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. using System;
  16. using System.Data;
  17. using System.Windows.Forms;
  18. namespace Dongke.IBOSS.PRD.Client.PMModule
  19. {
  20. public partial class F_PM_3502 : DKDockPanelBase
  21. {
  22. #region 成员变量
  23. // 窗体的单例模式
  24. private static F_PM_3502 _instance;
  25. // 存储窗口的编辑状态
  26. private Constant.FormMode _editStatus;
  27. private int _sendoutGoodsLogID;
  28. #endregion
  29. #region 构造函数
  30. public F_PM_3502()
  31. {
  32. InitializeComponent();
  33. }
  34. public F_PM_3502(Constant.FormMode editStatus, int sendoutGoodsLogID)
  35. {
  36. InitializeComponent();
  37. this._editStatus = editStatus;
  38. // 根据新建、编辑状态为标题赋值
  39. if (editStatus == Constant.FormMode.Edit)
  40. {
  41. this.Text = "编辑发货单";
  42. this._sendoutGoodsLogID = sendoutGoodsLogID;
  43. }
  44. // 按钮文本
  45. this.btnSave.Text = ButtonText.BTN_SAVE;
  46. }
  47. #endregion
  48. #region 单例模式
  49. /// <summary>
  50. /// 单例模式,防止重复创建窗体
  51. /// </summary>
  52. public static F_PM_3502 Instance
  53. {
  54. get
  55. {
  56. if (_instance == null || _instance.IsDisposed)
  57. {
  58. _instance = new F_PM_3502();
  59. }
  60. return _instance;
  61. }
  62. }
  63. #endregion
  64. #region 事件处理
  65. /// <summary>
  66. /// 窗体加载事件
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="e"></param>
  70. private void F_PM_3502_Load(object sender, EventArgs e)
  71. {
  72. try
  73. {
  74. #region 页面数据源
  75. #region 发出/接收仓库
  76. //发出仓库
  77. ServiceResultEntity sreType = DoAsync<ServiceResultEntity>(() =>
  78. {
  79. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC026");
  80. }
  81. );
  82. if (sreType.Data == null)
  83. {
  84. return;
  85. }
  86. if (sreType.Data != null && sreType.Data.Tables[0].Rows.Count > 0)
  87. {
  88. // 设置空选项
  89. DataRow dataRow = sreType.Data.Tables[0].NewRow();
  90. dataRow["DictionaryID"] = DBNull.Value;
  91. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  92. dataRow["DisplayNo"] = 0;
  93. sreType.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  94. this.cmbWAREHOUSINGCODE.DisplayMember = "DictionaryValue";
  95. this.cmbWAREHOUSINGCODE.ValueMember = "DictionaryID";
  96. this.cmbWAREHOUSINGCODE.DataSource = sreType.Data.Tables[0];
  97. }
  98. //接收仓库
  99. sreType = DoAsync<ServiceResultEntity>(() =>
  100. {
  101. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC027");
  102. }
  103. );
  104. if (sreType.Data == null)
  105. {
  106. return;
  107. }
  108. if (sreType.Data != null && sreType.Data.Tables[0].Rows.Count > 0)
  109. {
  110. // 设置空选项
  111. DataRow dataRow = sreType.Data.Tables[0].NewRow();
  112. dataRow["DictionaryID"] = DBNull.Value;
  113. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  114. dataRow["DisplayNo"] = 0;
  115. sreType.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  116. this.cmbRECEIVECODE.DisplayMember = "DictionaryValue";
  117. this.cmbRECEIVECODE.ValueMember = "DictionaryID";
  118. this.cmbRECEIVECODE.DataSource = sreType.Data.Tables[0];
  119. }
  120. #endregion
  121. #region 车牌号
  122. //接收仓库
  123. sreType = DoAsync<ServiceResultEntity>(() =>
  124. {
  125. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC028");
  126. }
  127. );
  128. if (sreType.Data == null)
  129. {
  130. return;
  131. }
  132. if (sreType.Data != null && sreType.Data.Tables[0].Rows.Count > 0)
  133. {
  134. // 设置空选项
  135. DataRow dataRow = sreType.Data.Tables[0].NewRow();
  136. dataRow["DictionaryID"] = DBNull.Value;
  137. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  138. dataRow["DisplayNo"] = 0;
  139. sreType.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  140. this.cmbCARPLATENAME.DisplayMember = "DictionaryValue";
  141. this.cmbCARPLATENAME.ValueMember = "DictionaryID";
  142. this.cmbCARPLATENAME.DataSource = sreType.Data.Tables[0];
  143. }
  144. #endregion
  145. #endregion
  146. //编辑查询数据
  147. if (this._sendoutGoodsLogID > 0)
  148. {
  149. ClientRequestEntity cre = new ClientRequestEntity();
  150. cre.NameSpace = "F_PM_3502";
  151. cre.Name = "GetSendInfo";
  152. cre.Properties["SENDOUTGOODSLOGID"] = this._sendoutGoodsLogID;
  153. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  154. {
  155. return PMModuleProxyNew.Service.HandleRequest(cre);
  156. });
  157. if (sre.Status == Constant.ServiceResultStatus.Success)
  158. {
  159. if (sre != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  160. {
  161. DataTable dtable = sre.Data.Tables[0];
  162. this.txtSENDOUTCODE.Text = dtable.Rows[0]["SENDOUTCODE"].ToString();
  163. this.cmbWAREHOUSINGCODE.SelectedValue = Convert.ToInt32(dtable.Rows[0]["WAREHOUSINGID"]);
  164. this.cmbRECEIVECODE.SelectedValue = Convert.ToInt32(dtable.Rows[0]["RECEIVEID"]);
  165. this.cmbCARPLATENAME.SelectedValue = Convert.ToInt32(dtable.Rows[0]["CARPLATEID"]);
  166. if (sre.Data.Tables[1].Rows.Count > 0)
  167. {
  168. DataTable dtable2 = sre.Data.Tables[0];
  169. this.dgvSendDetail.DataSource = dtable2;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. catch (Exception ex)
  176. {
  177. // 对异常进行共通处理
  178. ExceptionManager.HandleEventException(this.ToString(),
  179. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  180. }
  181. }
  182. /// <summary>
  183. /// 窗体关闭事件
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void F_PM_3502_FormClosed(object sender, FormClosedEventArgs e)
  188. {
  189. _instance = null;
  190. }
  191. /// <summary>
  192. /// 保存
  193. /// </summary>
  194. /// <param name="sender"></param>
  195. /// <param name="e"></param>
  196. private void btnSave_Click(object sender, EventArgs e)
  197. {
  198. try
  199. {
  200. ClientRequestEntity cre = new ClientRequestEntity();
  201. cre.NameSpace = "F_PM_3502";
  202. cre.Name = "SaveSendInfo";
  203. cre.Properties["SENDOUTGOODSLOGID"] = this._sendoutGoodsLogID;
  204. cre.Properties["OUTLABELCODE"] = this.txtOUTLABELCODE.Text;
  205. cre.Properties["WAREHOUSINGCODE"] = this.cmbWAREHOUSINGCODE.SelectedValue;
  206. cre.Properties["RECEIVECODE"] = this.cmbRECEIVECODE.SelectedValue;
  207. cre.Properties["CARPLATECODE"] = this.cmbCARPLATENAME.SelectedValue;
  208. cre.Properties["WAREHOUSINGENAME"] = this.cmbWAREHOUSINGCODE.Text;
  209. cre.Properties["RECEIVEENAME"] = this.cmbRECEIVECODE.Text;
  210. cre.Properties["CARPLATENAME"] = this.cmbCARPLATENAME.Text;
  211. cre.Properties["AccountDateStart"] = this.dtpAccountDateStart.Value;
  212. cre.Properties["DELIVERDATE"] = this.c_DateTimePicker1.Value;
  213. if (dgvSendDetail.DataSource != null)
  214. {
  215. DataTable detail = (DataTable)(dgvSendDetail.DataSource);
  216. cre.Data = new DataSet();
  217. cre.Data.Tables.Add(detail.Copy());
  218. }
  219. else
  220. {
  221. MessageBox.Show(string.Format("发货单信息不能为空"),
  222. this.Text,
  223. MessageBoxButtons.OK,
  224. MessageBoxIcon.Warning);
  225. return;
  226. }
  227. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  228. {
  229. return PMModuleProxyNew.Service.HandleRequest(cre);
  230. });
  231. if (sre.Status == Constant.ServiceResultStatus.Success)
  232. {
  233. MessageBox.Show("保存成功",
  234. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  235. return;
  236. }
  237. else if(sre.Status == Constant.ServiceResultStatus.DataChanged)//"库存不足"
  238. {
  239. MessageBox.Show("sap库存不足",
  240. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  241. return;
  242. }
  243. else if (sre.Status == Constant.ServiceResultStatus.Other) // "存在已发货产品";
  244. {
  245. MessageBox.Show("存在已发货产品",
  246. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  247. return;
  248. }
  249. }
  250. catch (Exception ex)
  251. {
  252. this.btnSave.Enabled = true;
  253. // 对异常进行共通处理
  254. ExceptionManager.HandleEventException(this.ToString(),
  255. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  256. }
  257. }
  258. /// <summary>
  259. ///编辑时输入外箱码事件
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. private void txtOUTLABELCODE_KeyDown(object sender, KeyEventArgs e)
  264. {
  265. if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(this.txtOUTLABELCODE.Text.Trim()))
  266. {
  267. //调用查询
  268. }
  269. }
  270. #endregion
  271. }
  272. }