F_MST_1502.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. //记录版面id
  20. private string LayoutidOne;
  21. // 编辑状态
  22. private Constant.FormMode _editStatus;
  23. #endregion
  24. #region 构造函数
  25. public F_MST_1502()
  26. {
  27. InitializeComponent();
  28. }
  29. public F_MST_1502(Constant.FormMode frmStatus, string Layoutid)
  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(Layoutid))
  44. {
  45. LayoutidOne = Layoutid;
  46. ClientRequestEntity cre = new ClientRequestEntity();
  47. cre.NameSpace = "F_MST_1501";
  48. cre.Name = "GetLayout";
  49. cre.Properties["Layoutid"] = Layoutid;
  50. cre.Properties["LayoutCode"] = "";
  51. cre.Properties["CustomerCode"] = "";
  52. cre.Properties["LayoutName"] = "";
  53. cre.Properties["ValueFlag"] = "";
  54. cre.Properties["GOODSCODE"] = "";
  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. this.txtGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  61. //版面名称
  62. this.txtLauoutName.Text = sre.Data.Tables[0].Rows[0]["LAYOUTNAME"].ToString();
  63. //有效标识
  64. if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "是")
  65. {
  66. this.ccbvalueflag.SelectedIndex = 0;
  67. }
  68. else if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "否")
  69. {
  70. this.ccbvalueflag.SelectedIndex = 1;
  71. }
  72. //备注
  73. this.txtRemarks.Text = sre.Data.Tables[0].Rows[0]["REMARKS"].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. //页面加载事件
  94. private void F_MST_1502_Load(object sender, EventArgs e)
  95. {
  96. }
  97. //保存
  98. private void btnSave_Click(object sender, EventArgs e)
  99. {
  100. try
  101. {
  102. //客户编码
  103. if (string.IsNullOrEmpty(this.txtGoodsCode.Text.ToString()))
  104. {
  105. //必须输入
  106. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户编码"),
  107. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  108. this.txtGoodsCode.Focus();
  109. return;
  110. }
  111. //客户编码
  112. if (string.IsNullOrEmpty(this.txtCustomerCode.Text.ToString()))
  113. {
  114. //必须输入
  115. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户编码"),
  116. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  117. this.txtCustomerCode.Focus();
  118. return;
  119. }
  120. //版面名称
  121. if (string.IsNullOrEmpty(this.txtLauoutName.Text.ToString()))
  122. {
  123. //必须输入
  124. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "版面名称"),
  125. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  126. this.txtLauoutName.Focus();
  127. return;
  128. }
  129. //有效标识
  130. if (this.ccbvalueflag.SelectedItem == null)
  131. {
  132. //必须输入
  133. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "有效标识"),
  134. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  135. this.ccbvalueflag.Focus();
  136. return;
  137. }
  138. //int returnCustomerID = Constant.INT_IS_ZERO;
  139. //_CustomerEntity = this.SetCustomerEntity();
  140. if (_editStatus == Constant.FormMode.Add)
  141. {
  142. // 新建用户,返回新建的用户ID
  143. this.btnSave.Enabled = false;
  144. this.btnCancel.Enabled = false;
  145. this.AddLauoutInfo();
  146. this.Clear();
  147. }
  148. if (_editStatus == Constant.FormMode.Edit)
  149. {
  150. this.btnSave.Enabled = false;
  151. this.btnCancel.Enabled = false;
  152. this.EditLauout();
  153. this.Close();
  154. }
  155. }
  156. catch (Exception ex)
  157. {
  158. // 对异常进行共通处理
  159. ExceptionManager.HandleEventException(this.ToString(),
  160. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  161. }
  162. }
  163. //退出
  164. private void btnCancel_Click(object sender, EventArgs e)
  165. {
  166. }
  167. #endregion
  168. #region 私有方法
  169. /// <summary>
  170. /// 保存方法
  171. /// </summary>
  172. /// <returns></returns>
  173. private void AddLauoutInfo()
  174. {
  175. int valueflag = 1;
  176. ClientRequestEntity cre = new ClientRequestEntity();
  177. cre.NameSpace = "F_MST_1501";
  178. cre.Name = "AddLayoutInfo";
  179. cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
  180. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  181. cre.Properties["LAYOUTNAME"] = this.txtLauoutName.Text;
  182. if (this.ccbvalueflag.SelectedIndex == 0)
  183. {
  184. valueflag = 1;
  185. }
  186. if (this.ccbvalueflag.SelectedIndex == 1)
  187. {
  188. valueflag = 0;
  189. }
  190. cre.Properties["VALUEFLAG"] = valueflag;
  191. cre.Properties["REMARKS"] = this.txtRemarks.Text;
  192. cre.Properties["FromStatus"] = FromStatus.ToString();
  193. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  194. this.btnSave.Enabled = true;
  195. this.btnCancel.Enabled = true;
  196. if (sre.OtherStatus > 0)
  197. {
  198. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  199. return;
  200. }
  201. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  202. {
  203. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  204. "存在相同客户编码"),
  205. "",
  206. MessageBoxButtons.OK,
  207. MessageBoxIcon.Warning);
  208. return;
  209. }
  210. }
  211. /// <summary>
  212. /// 编辑方法
  213. /// </summary>
  214. public void EditLauout()
  215. {
  216. int valueflag = 1;
  217. ClientRequestEntity cre = new ClientRequestEntity();
  218. cre.NameSpace = "F_MST_1501";
  219. cre.Name = "AddLayoutInfo";
  220. cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
  221. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  222. cre.Properties["LAYOUTNAME"] = this.txtLauoutName.Text;
  223. if (this.ccbvalueflag.SelectedIndex == 0)
  224. {
  225. valueflag = 1;
  226. }
  227. if (this.ccbvalueflag.SelectedIndex == 1)
  228. {
  229. valueflag = 0;
  230. }
  231. cre.Properties["VALUEFLAG"] = valueflag;
  232. cre.Properties["REMARKS"] = this.txtRemarks.Text;
  233. cre.Properties["FromStatus"] = FromStatus.ToString();
  234. cre.Properties["LAYOUTID"] = LayoutidOne;
  235. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  236. this.btnSave.Enabled = true;
  237. this.btnCancel.Enabled = true;
  238. if (sre.OtherStatus > 0)
  239. {
  240. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  241. return;
  242. }
  243. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  244. {
  245. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  246. "存在相同版面编码"),
  247. "",
  248. MessageBoxButtons.OK,
  249. MessageBoxIcon.Warning);
  250. return;
  251. }
  252. }
  253. /// <summary>
  254. /// 清空方法
  255. /// </summary>
  256. public void Clear()
  257. {
  258. this.txtCustomerCode.Clear();
  259. this.txtGoodsCode.Clear();
  260. this.txtLauoutName.Clear();
  261. this.ccbvalueflag.SelectedText = "";
  262. this.txtRemarks.Clear();
  263. }
  264. #endregion
  265. }
  266. }