F_MST_1402.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. namespace Dongke.IBOSS.PRD.Client.SystemModule
  15. {
  16. public partial class F_MST_1402 : FormBase
  17. {
  18. #region 成员变量
  19. //记录客户编码
  20. private string CustomerCodeOne;
  21. // 编辑状态
  22. private Constant.FormMode _editStatus;
  23. #endregion
  24. #region 构造函数
  25. public F_MST_1402()
  26. {
  27. InitializeComponent();
  28. }
  29. public F_MST_1402(Constant.FormMode frmStatus,string CustomerCode)
  30. {
  31. InitializeComponent();
  32. _editStatus = frmStatus;
  33. // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
  34. if (frmStatus == Constant.FormMode.Add)
  35. {
  36. FromStatus = "Add";
  37. this.Text = "新建";
  38. }
  39. else if (frmStatus == Constant.FormMode.Edit)
  40. {
  41. FromStatus = "Edit";
  42. this.Text = "编辑";
  43. if (!string.IsNullOrEmpty(CustomerCode))
  44. {
  45. CustomerCodeOne = CustomerCode;
  46. ClientRequestEntity cre = new ClientRequestEntity();
  47. cre.NameSpace = "F_MST_1401";
  48. cre.Name = "GetCustomer";
  49. cre.Properties["CustomerCode"] = CustomerCode;
  50. cre.Properties["CustomerName"] = "";
  51. cre.Properties["GOODSCODE"] = "";
  52. cre.Properties["GOODSNAME"] = "";
  53. cre.Properties["ValueFlag"] = "";
  54. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  55. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  56. {
  57. //客户编码
  58. this.txtCustomerCode.Text = CustomerCode;
  59. //客户名称
  60. this.txtCustomerName.Text = sre.Data.Tables[0].Rows[0]["CUSTOMERNAME"].ToString();
  61. //有效标识
  62. if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "是")
  63. {
  64. this.ccbvalueflag.SelectedIndex = 0;
  65. }
  66. else if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "否")
  67. {
  68. this.ccbvalueflag.SelectedIndex = 1;
  69. }
  70. //备注
  71. this.txtRemarks.Text = sre.Data.Tables[0].Rows[0]["REMARKS"].ToString();
  72. this.txtGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  73. }
  74. }
  75. }
  76. // 工具栏按钮文本赋值
  77. this.btnSave.Text = ButtonText.BTN_SAVE;
  78. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  79. }
  80. #endregion
  81. #region 属性
  82. /// <summary>
  83. /// 页面状态
  84. /// </summary>
  85. public string FromStatus
  86. {
  87. get;
  88. set;
  89. }
  90. #endregion
  91. #region 事件
  92. /// <summary>
  93. /// 关闭事件
  94. /// </summary>
  95. /// <param name="sender"></param>
  96. /// <param name="e"></param>
  97. private void btnCancel_Click(object sender, EventArgs e)
  98. {
  99. this.Close();
  100. }
  101. /// <summary>
  102. /// 保存事件
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void btnSave_Click(object sender, EventArgs e)
  107. {
  108. try
  109. {
  110. //产品编码
  111. if (string.IsNullOrEmpty(this.txtGoodsCode.Text.ToString()))
  112. {
  113. //必须输入
  114. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品编码"),
  115. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  116. this.txtGoodsCode.Focus();
  117. return;
  118. }
  119. //客户编码
  120. if (string.IsNullOrEmpty(this.txtCustomerCode.Text.ToString()))
  121. {
  122. //必须输入
  123. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户编码"),
  124. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  125. this.txtCustomerCode.Focus();
  126. return;
  127. }
  128. //客户名称
  129. if (string.IsNullOrEmpty(this.txtCustomerName.Text.ToString()))
  130. {
  131. //必须输入
  132. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户名称"),
  133. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  134. this.txtCustomerName.Focus();
  135. return;
  136. }
  137. //有效标识
  138. if (this.ccbvalueflag.SelectedItem == null)
  139. {
  140. //必须输入
  141. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "有效标识"),
  142. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  143. this.ccbvalueflag.Focus();
  144. return;
  145. }
  146. //int returnCustomerID = Constant.INT_IS_ZERO;
  147. //_CustomerEntity = this.SetCustomerEntity();
  148. if (_editStatus == Constant.FormMode.Add)
  149. {
  150. // 新建用户,返回新建的用户ID
  151. this.btnSave.Enabled = false;
  152. this.btnCancel.Enabled = false;
  153. this.AddCustomerInfo();
  154. this.Clear();
  155. }
  156. if (_editStatus == Constant.FormMode.Edit)
  157. {
  158. this.btnSave.Enabled = false;
  159. this.btnCancel.Enabled = false;
  160. this.EditCustomer();
  161. this.Close();
  162. }
  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. /// <returns></returns>
  177. private void AddCustomerInfo()
  178. {
  179. int valueflag = 1;
  180. ClientRequestEntity cre = new ClientRequestEntity();
  181. cre.NameSpace = "F_MST_1401";
  182. cre.Name = "AddCustomer";
  183. cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
  184. cre.Properties["CUSTOMERNAME"] = this.txtCustomerName.Text;
  185. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  186. if (this.ccbvalueflag.SelectedIndex == 0)
  187. {
  188. valueflag = 1;
  189. }
  190. if (this.ccbvalueflag.SelectedIndex == 1)
  191. {
  192. valueflag = 0;
  193. }
  194. cre.Properties["VALUEFLAG"] = valueflag;
  195. cre.Properties["REMARKS"] = this.txtRemarks.Text;
  196. cre.Properties["FromStatus"] = FromStatus.ToString();
  197. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  198. this.btnSave.Enabled = true;
  199. this.btnCancel.Enabled = true;
  200. if (sre.OtherStatus > 0)
  201. {
  202. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  203. return;
  204. }
  205. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  206. {
  207. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  208. "存在相同客户编码"),
  209. "",
  210. MessageBoxButtons.OK,
  211. MessageBoxIcon.Warning);
  212. return;
  213. }
  214. }
  215. /// <summary>
  216. /// 编辑方法
  217. /// </summary>
  218. public void EditCustomer()
  219. {
  220. int valueflag = 1;
  221. ClientRequestEntity cre = new ClientRequestEntity();
  222. cre.NameSpace = "F_MST_1401";
  223. cre.Name = "AddCustomer";
  224. cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
  225. cre.Properties["CUSTOMERNAME"] = this.txtCustomerName.Text;
  226. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  227. if (this.ccbvalueflag.SelectedIndex == 0)
  228. {
  229. valueflag = 1;
  230. }
  231. if (this.ccbvalueflag.SelectedIndex == 1)
  232. {
  233. valueflag = 0;
  234. }
  235. cre.Properties["VALUEFLAG"] = valueflag;
  236. cre.Properties["REMARKS"] = this.txtRemarks.Text;
  237. cre.Properties["FromStatus"] = FromStatus.ToString();
  238. cre.Properties["CUSTOMERCODEONE"] = CustomerCodeOne;
  239. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  240. this.btnSave.Enabled = true;
  241. this.btnCancel.Enabled = true;
  242. if (sre.OtherStatus > 0)
  243. {
  244. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  245. return;
  246. }
  247. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  248. {
  249. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  250. "存在相同客户编码"),
  251. "",
  252. MessageBoxButtons.OK,
  253. MessageBoxIcon.Warning);
  254. return;
  255. }
  256. }
  257. /// <summary>
  258. /// 清空方法
  259. /// </summary>
  260. public void Clear()
  261. {
  262. this.txtCustomerCode.Clear();
  263. this.txtCustomerName.Clear();
  264. this.txtGoodsCode.Clear();
  265. this.ccbvalueflag.SelectedText = "";
  266. this.txtRemarks.Clear();
  267. }
  268. #endregion
  269. private void F_MST_1402_Load(object sender, EventArgs e)
  270. {
  271. }
  272. }
  273. }