F_MST_1502.cs 8.4 KB

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