F_MST_1402.cs 7.9 KB

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