F_MST_1302.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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_1302 : Form
  17. {
  18. #region 成员变量
  19. // 编辑状态
  20. private Constant.FormMode _editStatus;
  21. //记录金蝶代码
  22. private string KingdeeCodeOne;
  23. #endregion
  24. #region 构造函数
  25. public F_MST_1302()
  26. {
  27. InitializeComponent();
  28. }
  29. public F_MST_1302(Constant.FormMode frmStatus, string KingdeeCode)
  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. KingdeeCodeOne = KingdeeCode;
  44. if (!string.IsNullOrEmpty(KingdeeCode))
  45. {
  46. //CustomerCodeOne = CustomerCode;
  47. ClientRequestEntity cre = new ClientRequestEntity();
  48. cre.NameSpace = "F_MST_1301";
  49. cre.Name = "GetKingdeeCode";
  50. cre.Properties["KingdeeCode"] = KingdeeCode;
  51. cre.Properties["GoodsCode"] = "";
  52. cre.Properties["GlazeType"] = "";
  53. cre.Properties["LogoName"] = "";
  54. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  55. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  56. {
  57. //金蝶代码
  58. this.txtKingdeeCode.Text = KingdeeCode;
  59. //产品编码
  60. this.txtGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  61. //商标名称
  62. this.ddlLogoName.Text = sre.Data.Tables[0].Rows[0]["LOGONAME"].ToString();
  63. //釉料类别
  64. this.ddlGlazeTypeID.Text = sre.Data.Tables[0].Rows[0]["KINGDEECODE"].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.txtGoodsCode.Text.ToString()))
  95. {
  96. //必须输入
  97. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商品编码"),
  98. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  99. this.txtGoodsCode.Focus();
  100. return;
  101. }
  102. //金蝶代码
  103. if (string.IsNullOrEmpty(this.txtKingdeeCode.Text.ToString()))
  104. {
  105. //必须输入
  106. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "金蝶代码"),
  107. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  108. this.txtKingdeeCode.Focus();
  109. return;
  110. }
  111. //商标
  112. if (this.ddlLogoName.Text == "")
  113. {
  114. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标"),
  115. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  116. this.ddlLogoName.Focus();
  117. return;
  118. }
  119. //釉料类别
  120. if (this.ddlGlazeTypeID.Text == "")
  121. {
  122. //商标
  123. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "釉料类别"),
  124. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  125. this.ddlGlazeTypeID.Focus();
  126. return;
  127. }
  128. //int returnCustomerID = Constant.INT_IS_ZERO;
  129. //_CustomerEntity = this.SetCustomerEntity();
  130. if (_editStatus == Constant.FormMode.Add)
  131. {
  132. // 新建用户,返回新建的用户ID
  133. this.btnSave.Enabled = false;
  134. this.btnCancel.Enabled = false;
  135. this.AddCustomerInfo();
  136. this.Clear();
  137. }
  138. if (_editStatus == Constant.FormMode.Edit)
  139. {
  140. this.btnSave.Enabled = false;
  141. this.btnCancel.Enabled = false;
  142. this.EditCustomer();
  143. this.Close();
  144. }
  145. }
  146. catch (Exception ex)
  147. {
  148. // 对异常进行共通处理
  149. ExceptionManager.HandleEventException(this.ToString(),
  150. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  151. }
  152. }
  153. /// <summary>
  154. /// 退出事件
  155. /// </summary>
  156. /// <param name="sender"></param>
  157. /// <param name="e"></param>
  158. private void btnCancel_Click(object sender, EventArgs e)
  159. {
  160. }
  161. /// <summary>
  162. /// 页面加载事件
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void F_MST_1302_Load(object sender, EventArgs e)
  167. {
  168. try
  169. {
  170. this.loadDataSource();
  171. }
  172. catch (Exception ex)
  173. {
  174. // 对异常进行共通处理
  175. ExceptionManager.HandleEventException(this.ToString(),
  176. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  177. }
  178. }
  179. #endregion
  180. #region 私有方法
  181. /// <summary>
  182. /// 下拉框获取数据
  183. /// </summary>
  184. private void loadDataSource()
  185. {
  186. try
  187. {
  188. ClientRequestEntity cre = new ClientRequestEntity();
  189. cre.NameSpace = "F_MST_1301";
  190. cre.Name = "GetGlazeType";
  191. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  192. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  193. {
  194. DataTable dtGlazeType = sre.Data.Tables[0];
  195. if (dtGlazeType != null)
  196. {
  197. ddlGlazeTypeID.DisplayMember = "GLAZETYPE";
  198. ddlGlazeTypeID.ValueMember = "ROWNUM";
  199. ddlGlazeTypeID.DataSource = dtGlazeType;
  200. }
  201. }
  202. cre = new ClientRequestEntity();
  203. cre.NameSpace = "F_MST_1301";
  204. cre.Name = "GetLogoName";
  205. sre = SystemModuleProxy.Service.DoRequest(cre);
  206. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  207. {
  208. DataTable dtLogoName = sre.Data.Tables[0];
  209. if (dtLogoName != null)
  210. {
  211. ddlLogoName.DisplayMember = "LOGONAME";
  212. ddlLogoName.ValueMember = "ROWNUM";
  213. ddlLogoName.DataSource = dtLogoName;
  214. }
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. throw ex;
  220. }
  221. #endregion
  222. }
  223. private void Clear()
  224. {
  225. this.txtGoodsCode.Clear();
  226. this.txtKingdeeCode.Clear();
  227. this.ddlLogoName.SelectedText = "";
  228. this.ddlGlazeTypeID.SelectedText = "";
  229. }
  230. private void AddCustomerInfo()
  231. {
  232. }
  233. private void EditCustomer()
  234. {
  235. ClientRequestEntity cre = new ClientRequestEntity();
  236. cre.NameSpace = "F_MST_1401";
  237. cre.Name = "AddKingdeeCode";
  238. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  239. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  240. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  241. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text;
  242. cre.Properties["KINGDEECODEONE"] = KingdeeCodeOne;
  243. cre.Properties["FromStatus"] = FromStatus.ToString();
  244. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  245. this.btnSave.Enabled = true;
  246. this.btnCancel.Enabled = true;
  247. if (sre.OtherStatus > 0)
  248. {
  249. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  250. return;
  251. }
  252. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  253. {
  254. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  255. "存在相同金蝶代码"),
  256. "",
  257. MessageBoxButtons.OK,
  258. MessageBoxIcon.Warning);
  259. return;
  260. }
  261. }
  262. }
  263. }