F_MST_1302.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.scbGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  61. //商标名称
  62. this.ddlLogoName.SelectedValue = sre.Data.Tables[0].Rows[0]["LOGONAME"].ToString();
  63. //釉料类别
  64. this.ddlGlazeTypeID.SelectedValue = 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.scbGoodsCode.Text.ToString()))
  95. {
  96. //必须输入
  97. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商品编码"),
  98. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  99. this.scbGoodsCode.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. }
  137. if (_editStatus == Constant.FormMode.Edit)
  138. {
  139. this.btnSave.Enabled = false;
  140. this.btnCancel.Enabled = false;
  141. this.EditCustomer();
  142. this.Close();
  143. }
  144. }
  145. catch (Exception ex)
  146. {
  147. // 对异常进行共通处理
  148. ExceptionManager.HandleEventException(this.ToString(),
  149. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  150. }
  151. }
  152. /// <summary>
  153. /// 退出事件
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. private void btnCancel_Click(object sender, EventArgs e)
  158. {
  159. }
  160. /// <summary>
  161. /// 页面加载事件
  162. /// </summary>
  163. /// <param name="sender"></param>
  164. /// <param name="e"></param>
  165. private void F_MST_1302_Load(object sender, EventArgs e)
  166. {
  167. try
  168. {
  169. this.ddlGlazeTypeID.ClearValue();
  170. this.ddlLogoName.ClearValue();
  171. this.loadDataSource();
  172. }
  173. catch (Exception ex)
  174. {
  175. // 对异常进行共通处理
  176. ExceptionManager.HandleEventException(this.ToString(),
  177. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  178. }
  179. }
  180. #endregion
  181. #region 私有方法
  182. /// <summary>
  183. /// 下拉框获取数据
  184. /// </summary>
  185. private void loadDataSource()
  186. {
  187. try
  188. {
  189. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  190. if (dtGlazeType != null)
  191. {
  192. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  193. ddlGlazeTypeID.ValueMember = "DictionarylD";
  194. ddlGlazeTypeID.DataSource = dtGlazeType;
  195. }
  196. ClientRequestEntity cre = new ClientRequestEntity();
  197. cre.NameSpace = "F_MST_1301";
  198. cre.Name = "GetLogoName";
  199. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  200. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  201. {
  202. DataTable dtLogoName = sre.Data.Tables[0];
  203. if (dtLogoName != null)
  204. {
  205. ddlLogoName.DisplayMember = "LogoNameCode";
  206. ddlLogoName.ValueMember = "LogoID";
  207. ddlLogoName.DataSource = dtLogoName;
  208. }
  209. }
  210. }
  211. catch (Exception ex)
  212. {
  213. throw ex;
  214. }
  215. #endregion
  216. }
  217. private void Clear()
  218. {
  219. this.scbGoodsCode.ClearValue();
  220. this.txtKingdeeCode.Clear();
  221. this.ddlLogoName.SelectedText = "";
  222. this.ddlGlazeTypeID.SelectedText = "";
  223. }
  224. private void AddCustomerInfo()
  225. {
  226. ClientRequestEntity cre = new ClientRequestEntity();
  227. cre.NameSpace = "F_MST_1301";
  228. cre.Name = "AddKingdeeCode";
  229. cre.Properties["GOODSCODE"] = this.scbGoodsCode.SearchedValue;
  230. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  231. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  232. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text;
  233. cre.Properties["KINGDEECODEONE"] = "";
  234. cre.Properties["FromStatus"] = FromStatus.ToString();
  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. this.Clear();
  242. this.txtKingdeeCode.Focus();
  243. this.ddlGlazeTypeID.ClearValue();
  244. this.ddlLogoName.ClearValue();
  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. private void EditCustomer()
  258. {
  259. ClientRequestEntity cre = new ClientRequestEntity();
  260. cre.NameSpace = "F_MST_1301";
  261. cre.Name = "AddKingdeeCode";
  262. cre.Properties["GOODSCODE"] = this.scbGoodsCode.Text;
  263. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  264. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  265. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text;
  266. cre.Properties["KINGDEECODEONE"] = KingdeeCodeOne;
  267. cre.Properties["FromStatus"] = FromStatus.ToString();
  268. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  269. this.btnSave.Enabled = true;
  270. this.btnCancel.Enabled = true;
  271. if (sre.OtherStatus > 0)
  272. {
  273. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  274. return;
  275. }
  276. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  277. {
  278. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  279. "存在相同金蝶代码"),
  280. "",
  281. MessageBoxButtons.OK,
  282. MessageBoxIcon.Warning);
  283. return;
  284. }
  285. }
  286. }
  287. }