F_MST_1402.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. using Dongke.IBOSS.PRD.Basics.BaseControls;
  2. using Dongke.IBOSS.PRD.Basics.BaseResources;
  3. using Dongke.IBOSS.PRD.Client.CommonModule;
  4. using Dongke.IBOSS.PRD.WCF.DataModels;
  5. using Dongke.IBOSS.PRD.WCF.Proxys;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  15. namespace Dongke.IBOSS.PRD.Client.SystemModule
  16. {
  17. public partial class F_MST_1402 : Form
  18. {
  19. #region 成员变量
  20. // 编辑状态
  21. private Constant.FormMode _editStatus;
  22. private string MOULDGOODSCODE;
  23. private string GOODSCODE;
  24. private string MOULDNAME;
  25. private string GUID;
  26. #endregion
  27. #region 构造函数
  28. public F_MST_1402()
  29. {
  30. InitializeComponent();
  31. }
  32. public F_MST_1402(Constant.FormMode frmStatus, string MouldCode, string MouldNames, string GoodsCode)
  33. {
  34. InitializeComponent();
  35. _editStatus = frmStatus;
  36. // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
  37. if (frmStatus == Constant.FormMode.Add)
  38. {
  39. FromStatus = "Add";
  40. this.Text = "新建";
  41. }
  42. else if (frmStatus == Constant.FormMode.Edit)
  43. {
  44. FromStatus = "Edit";
  45. this.Text = "编辑";
  46. MOULDGOODSCODE = MouldCode;
  47. MOULDNAME = MouldNames;
  48. if (!string.IsNullOrEmpty(MouldCode))
  49. {
  50. //CustomerCodeOne = CustomerCode;
  51. ClientRequestEntity cre = new ClientRequestEntity();
  52. cre.NameSpace = "F_MST_1401";
  53. cre.Name = "GetMouldGoodsCode";
  54. cre.Properties["MOULDGOODSCODE"] = MOULDGOODSCODE;
  55. cre.Properties["GoodsCode"] = GoodsCode;
  56. cre.Properties["MOULDNAME"] = MouldNames;
  57. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  58. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  59. {
  60. DataRow item = sre.Data.Tables[0].Rows[0];
  61. this.txtMouldCode.Text = MOULDGOODSCODE;
  62. //产品编码
  63. this.scbGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  64. GUID= sre.Data.Tables[0].Rows[0]["GUID"].ToString();
  65. }
  66. }
  67. }
  68. // 工具栏按钮文本赋值
  69. this.btnSave.Text = ButtonText.BTN_SAVE;
  70. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  71. }
  72. #endregion
  73. #region 属性
  74. /// <summary>
  75. /// 页面状态
  76. /// </summary>
  77. public string FromStatus
  78. {
  79. get;
  80. set;
  81. }
  82. #endregion
  83. #region 事件
  84. /// <summary>
  85. /// 保存事件
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void btnSave_Click(object sender, EventArgs e)
  90. {
  91. try
  92. {
  93. //商品编码
  94. if (string.IsNullOrEmpty(this.scbGoodsCode.Text.ToString()))
  95. {
  96. //必须输入
  97. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商品编码"),
  98. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  99. this.scbGoodsCode.Focus();
  100. return;
  101. }
  102. if (string.IsNullOrEmpty(this.txtMouldCode.Text.ToString()))
  103. {
  104. //必须输入
  105. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具编码"),
  106. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  107. this.txtMouldCode.Focus();
  108. return;
  109. }
  110. if (string.IsNullOrEmpty(this.txtMouldName.Text.ToString()))
  111. {
  112. //必须输入
  113. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具名称"),
  114. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  115. this.txtMouldCode.Focus();
  116. return;
  117. }
  118. //int returnCustomerID = Constant.INT_IS_ZERO;
  119. //_CustomerEntity = this.SetCustomerEntity();
  120. if (_editStatus == Constant.FormMode.Add)
  121. {
  122. // 新建用户,返回新建的用户ID
  123. this.btnSave.Enabled = false;
  124. this.btnCancel.Enabled = false;
  125. this.AddCustomerInfo();
  126. }
  127. if (_editStatus == Constant.FormMode.Edit)
  128. {
  129. this.btnSave.Enabled = false;
  130. this.btnCancel.Enabled = false;
  131. this.EditCustomer();
  132. this.Close();
  133. }
  134. }
  135. catch (Exception ex)
  136. {
  137. // 对异常进行共通处理
  138. ExceptionManager.HandleEventException(this.ToString(),
  139. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  140. }
  141. }
  142. /// <summary>
  143. /// 退出事件
  144. /// </summary>
  145. /// <param name="sender"></param>
  146. /// <param name="e"></param>
  147. private void btnCancel_Click(object sender, EventArgs e)
  148. {
  149. }
  150. /// <summary>
  151. /// 页面加载事件
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. private void F_MST_1402_Load(object sender, EventArgs e)
  156. {
  157. try
  158. {
  159. this.txtMouldCode.Clear();
  160. this.txtMouldName.Clear();
  161. this.txtMouldCode.Text = MOULDGOODSCODE;
  162. this.txtMouldName.Text = MOULDNAME;
  163. }
  164. catch (Exception ex)
  165. {
  166. // 对异常进行共通处理
  167. ExceptionManager.HandleEventException(this.ToString(),
  168. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  169. }
  170. }
  171. #endregion
  172. #region 私有方法
  173. /// <summary>
  174. /// 下拉框获取数据
  175. /// </summary>
  176. private void Clear()
  177. {
  178. this.scbGoodsCode.ClearValue();
  179. this.txtMouldCode.Clear();
  180. this.txtMouldName.Clear();
  181. }
  182. private void AddCustomerInfo()
  183. {
  184. ClientRequestEntity cre = new ClientRequestEntity();
  185. cre.NameSpace = "F_MST_1401";
  186. cre.Name = "AddMouldCode";
  187. if (!string.IsNullOrWhiteSpace(this.scbGoodsCode.Text))
  188. {
  189. if (this.scbGoodsCode.CheckedPKMember.Contains(","))
  190. {
  191. cre.Properties["GOODSCODE"] = scbGoodsCode.Text;
  192. }
  193. else
  194. {
  195. cre.Properties["GOODSCODE"] = scbGoodsCode.Text;
  196. }
  197. }
  198. cre.Properties["MOULDGOODSCODE"] = this.txtMouldCode.Text.Trim();
  199. cre.Properties["MOULDNAME"] = this.txtMouldName.Text.Trim();
  200. cre.Properties["FromStatus"] = FromStatus.ToString();
  201. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  202. this.btnSave.Enabled = true;
  203. this.btnCancel.Enabled = true;
  204. if (sre.OtherStatus > 0)
  205. {
  206. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  207. this.Clear();
  208. this.txtMouldCode.Focus();
  209. return;
  210. }
  211. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  212. {
  213. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  214. "存在相同数据"),
  215. "",
  216. MessageBoxButtons.OK,
  217. MessageBoxIcon.Warning);
  218. return;
  219. }
  220. }
  221. private void EditCustomer()
  222. {
  223. ClientRequestEntity cre = new ClientRequestEntity();
  224. cre.NameSpace = "F_MST_1401";
  225. cre.Name = "AddMouldCode";
  226. if (!string.IsNullOrWhiteSpace(this.scbGoodsCode.Text))
  227. {
  228. cre.Properties["GOODSCODE"] = this.scbGoodsCode.Text;
  229. }
  230. cre.Properties["MOULDGOODSCODE"] = this.txtMouldCode.Text.Trim();
  231. cre.Properties["MOULDNAME"] = this.txtMouldName.Text.Trim();
  232. cre.Properties["GUID"] = GUID;
  233. cre.Properties["FromStatus"] = FromStatus.ToString();
  234. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  235. this.btnSave.Enabled = true;
  236. this.btnCancel.Enabled = true;
  237. if (sre.OtherStatus > 0)
  238. {
  239. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  240. return;
  241. }
  242. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  243. {
  244. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  245. "存在相同数据"),
  246. "",
  247. MessageBoxButtons.OK,
  248. MessageBoxIcon.Warning);
  249. return;
  250. }
  251. }
  252. }
  253. }
  254. #endregion