F_PM_2302.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*******************************************************************************
  2. * Copyright(c) 2017 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2302.cs
  5. * 2.功能描述:生产订单新建/编辑界面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2017/02/07 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. public partial class F_PM_2302 : FormBase
  24. {
  25. #region 成员变量
  26. // 存储窗口的编辑状态
  27. private Constant.FormMode _editStatus;
  28. // 修改生产订单时存储上个窗口传过来的ID
  29. private int _orderID;
  30. private OrderEntity _orderEntity = new OrderEntity();
  31. #endregion
  32. #region 构造函数
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. public F_PM_2302()
  37. : this(Constant.FormMode.Add)
  38. {
  39. }
  40. /// <summary>
  41. /// 构造函数
  42. /// </summary>
  43. public F_PM_2302(Constant.FormMode editStatus)
  44. : this(editStatus, 0)
  45. {
  46. }
  47. /// <summary>
  48. /// 构造函数
  49. /// </summary>
  50. public F_PM_2302(Constant.FormMode editStatus, int orderID)
  51. {
  52. InitializeComponent();
  53. this._editStatus = editStatus;
  54. // 根据新建、编辑状态为标题赋值
  55. if (editStatus == Constant.FormMode.Add)
  56. {
  57. this.Text = FormTitles.F_PM_2302_ADD;
  58. }
  59. else
  60. {
  61. this.Text = FormTitles.F_PM_2302_EDIT;
  62. // 存储上个窗口传过来的生产订单ID
  63. this._orderID = orderID;
  64. }
  65. // 按钮文本
  66. this.btnSave.Text = ButtonText.BTN_SAVE;
  67. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  68. }
  69. #endregion
  70. #region 事件
  71. /// <summary>
  72. /// 关闭按钮事件
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void btnClose_Click(object sender, EventArgs e)
  77. {
  78. this.Close();
  79. }
  80. /// <summary>
  81. /// 保存按钮事件
  82. /// </summary>
  83. /// <param name="sender"></param>
  84. /// <param name="e"></param>
  85. private void btnSave_Click(object sender, EventArgs e)
  86. {
  87. try
  88. {
  89. // 验证信息是否完整
  90. bool validResult = IsValidData();
  91. if (validResult)
  92. {
  93. this.btnSave.Enabled = false;
  94. this.btnCancel.Enabled = false;
  95. ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(this.SaveOrder));//保存按钮方法
  96. this.btnSave.Enabled = true;
  97. this.btnCancel.Enabled = true;
  98. if (Convert.ToInt32(result.Result) > Constant.INT_IS_ZERO)//保存成功
  99. {
  100. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "生产订单", "保存"),
  101. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  102. //this._organizationIDList.Add(Convert.ToInt32(result));
  103. this.DialogResult = DialogResult.OK;
  104. }
  105. else if (Convert.ToInt32(result.Result)==-1)
  106. {
  107. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, result.Message),
  108. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  109. return;
  110. }
  111. if (this._editStatus == Constant.FormMode.Edit)
  112. {
  113. this.Close();
  114. }
  115. else
  116. {
  117. // 重置窗口数据
  118. this.ResetFormData();
  119. }
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. this.btnSave.Enabled = true;
  125. this.btnCancel.Enabled = true;
  126. // 对异常进行共通处理
  127. ExceptionManager.HandleEventException(this.ToString(),
  128. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  129. }
  130. }
  131. /// <summary>
  132. /// 获取组织机构结果集
  133. /// </summary>
  134. /// <returns></returns>
  135. private DataSet GetOrganizationDataSource()
  136. {
  137. try
  138. {
  139. OrganizationEntity organization = new OrganizationEntity();
  140. //// 票号开头字母
  141. //organization.LetterMarket = this.LetterMarket.Text.Trim();
  142. //// 联系电话
  143. //organization.Telephone = this.txtTelephone.Text.Trim();
  144. //// 地址
  145. //organization.Address = this.txtAddress.Text;
  146. //// 备注
  147. //organization.Remarks = this.txtRemarks.Text;
  148. //// 正常标识
  149. //organization.ValueFlags = null;
  150. //organization.in_UserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
  151. //organization.in_AccountID = LogInUserInfo.CurrentUser.CurrentUserEntity.AccountID;
  152. //this._organization = organization;
  153. return SystemModuleProxy.Service.SelectOrganizationData(organization);
  154. }
  155. catch (Exception ex)
  156. {
  157. throw ex;
  158. }
  159. }
  160. /// <summary>
  161. /// 窗体加载事件
  162. /// </summary>
  163. /// <param name="sender"></param>
  164. /// <param name="e"></param>
  165. private void F_PM_2302_Load(object sender, EventArgs e)
  166. {
  167. try
  168. {
  169. this.dtpOrderDateFrom.Value = DateTime.Now.Date;
  170. // 若状态是添加,则有效标志为可用并且不显示
  171. if (this._editStatus == Constant.FormMode.Edit)
  172. {
  173. this.SetOrganizationData();
  174. }
  175. this.txtOrderNo.Focus();
  176. }
  177. catch (Exception ex)
  178. {
  179. // 对异常进行共通处理
  180. ExceptionManager.HandleEventException(this.ToString(),
  181. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  182. }
  183. }
  184. #endregion
  185. #region 私有方法
  186. /// <summary>
  187. /// 为窗体各个控赋值
  188. /// </summary>
  189. private void SetOrganizationData()
  190. {
  191. try
  192. {
  193. // 获取生产订单信息
  194. this._orderEntity = new OrderEntity();
  195. this._orderEntity.OrderID = this._orderID;
  196. DataSet result = (DataSet)DoAsync(new BaseAsyncMethod(this.GetOrderList));
  197. if (result != null && result.Tables.Count > Constant.INT_IS_ZERO && result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  198. {
  199. DataRow orderRow = result.Tables[0].Rows[0];
  200. // 生产号
  201. this.txtOrderNo.Text = orderRow["OrderNo"].ToString();
  202. // 订单日期
  203. this.dtpOrderDateFrom.Value = Convert.ToDateTime(orderRow["OrderDate"]);
  204. // 备注
  205. this.txtRemarks.Text = orderRow["Remarks"].ToString();
  206. }
  207. }
  208. catch (Exception ex)
  209. {
  210. throw ex;
  211. }
  212. }
  213. /// <summary>
  214. /// 获取生产订单数据
  215. /// </summary>
  216. /// <returns></returns>
  217. private DataSet GetOrderList()
  218. {
  219. try
  220. {
  221. return PMModuleProxy.Service.GetOrderList(this._orderEntity);
  222. }
  223. catch (Exception ex)
  224. {
  225. throw ex;
  226. }
  227. }
  228. /// <summary>
  229. /// 验证输入是否完整
  230. /// </summary>
  231. /// <returns></returns>
  232. private bool IsValidData()
  233. {
  234. try
  235. {
  236. // 订单号不能为空
  237. if (string.IsNullOrEmpty(this.txtOrderNo.Text.Trim()))
  238. {
  239. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "订单号"),
  240. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  241. this.txtOrderNo.Focus();
  242. return false;
  243. }
  244. return true;
  245. }
  246. catch (Exception ex)
  247. {
  248. throw ex;
  249. }
  250. }
  251. /// <summary>
  252. /// 保存组织机构
  253. /// </summary>
  254. /// <returns>影响的行数</returns>
  255. private ServiceResultEntity SaveOrder()
  256. {
  257. try
  258. {
  259. OrderEntity order = GetOrderEntity();
  260. return PMModuleProxy.Service.SaveOrder(order);
  261. }
  262. catch (Exception ex)
  263. {
  264. throw ex;
  265. }
  266. }
  267. /// <summary>
  268. /// 给订单体类传值
  269. /// </summary>
  270. /// <returns></returns>
  271. private OrderEntity GetOrderEntity()
  272. {
  273. OrderEntity order = new OrderEntity();
  274. // 生产订单ID
  275. order.OrderID = this._orderID;
  276. // 生产订单号
  277. order.OrderNo = this.txtOrderNo.Text.Trim();
  278. // 生产订单日期
  279. order.OrderDate = this.dtpOrderDateFrom.Value;
  280. // 备注
  281. order.Remarks = this.txtRemarks.Text.Trim();
  282. order.ValueFlag = 1;
  283. return order;
  284. }
  285. /// <summary>
  286. /// 重置窗口数据
  287. /// </summary>
  288. private void ResetFormData()
  289. {
  290. this._orderID = Constant.INT_IS_ZERO;
  291. this.txtOrderNo.Text = string.Empty;
  292. this.dtpOrderDateFrom.Value = DateTime.Now;
  293. this.txtRemarks.Text = string.Empty;
  294. this.txtOrderNo.Focus();
  295. }
  296. #endregion
  297. }
  298. }