F_MST_1302.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. this.scbGoodsCode.ValueMember = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  62. //商标名称
  63. this.ddlLogoName.SelectedValue = sre.Data.Tables[0].Rows[0]["LOGONAME"].ToString();
  64. //釉料类别
  65. this.ddlGlazeTypeID.SelectedValue = sre.Data.Tables[0].Rows[0]["KINGDEECODE"].ToString();
  66. }
  67. }
  68. }
  69. // 工具栏按钮文本赋值
  70. this.btnSave.Text = ButtonText.BTN_SAVE;
  71. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  72. }
  73. #endregion
  74. #region 属性
  75. /// <summary>
  76. /// 页面状态
  77. /// </summary>
  78. public string FromStatus
  79. {
  80. get;
  81. set;
  82. }
  83. #endregion
  84. #region 事件
  85. /// <summary>
  86. /// 保存事件
  87. /// </summary>
  88. /// <param name="sender"></param>
  89. /// <param name="e"></param>
  90. private void btnSave_Click(object sender, EventArgs e)
  91. {
  92. try
  93. {
  94. //商品编码
  95. if (string.IsNullOrEmpty(this.scbGoodsCode.Text.ToString()))
  96. {
  97. //必须输入
  98. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商品编码"),
  99. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  100. this.scbGoodsCode.Focus();
  101. return;
  102. }
  103. //金蝶代码
  104. if (string.IsNullOrEmpty(this.txtKingdeeCode.Text.ToString()))
  105. {
  106. //必须输入
  107. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "金蝶代码"),
  108. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  109. this.txtKingdeeCode.Focus();
  110. return;
  111. }
  112. //商标
  113. if (this.ddlLogoName.Text == "")
  114. {
  115. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标"),
  116. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  117. this.ddlLogoName.Focus();
  118. return;
  119. }
  120. //釉料类别
  121. if (this.ddlGlazeTypeID.Text == "")
  122. {
  123. //商标
  124. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "釉料类别"),
  125. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  126. this.ddlGlazeTypeID.Focus();
  127. return;
  128. }
  129. //int returnCustomerID = Constant.INT_IS_ZERO;
  130. //_CustomerEntity = this.SetCustomerEntity();
  131. if (_editStatus == Constant.FormMode.Add)
  132. {
  133. // 新建用户,返回新建的用户ID
  134. this.btnSave.Enabled = false;
  135. this.btnCancel.Enabled = false;
  136. this.AddCustomerInfo();
  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.ddlGlazeTypeID.ClearValue();
  171. this.ddlLogoName.ClearValue();
  172. this.loadDataSource();
  173. }
  174. catch (Exception ex)
  175. {
  176. // 对异常进行共通处理
  177. ExceptionManager.HandleEventException(this.ToString(),
  178. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  179. }
  180. }
  181. #endregion
  182. #region 私有方法
  183. /// <summary>
  184. /// 下拉框获取数据
  185. /// </summary>
  186. private void loadDataSource()
  187. {
  188. try
  189. {
  190. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  191. if (dtGlazeType != null)
  192. {
  193. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  194. ddlGlazeTypeID.ValueMember = "DictionarylD";
  195. ddlGlazeTypeID.DataSource = dtGlazeType;
  196. }
  197. ClientRequestEntity cre = new ClientRequestEntity();
  198. cre.NameSpace = "F_MST_1301";
  199. cre.Name = "GetLogoName";
  200. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  201. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  202. {
  203. DataTable dtLogoName = sre.Data.Tables[0];
  204. if (dtLogoName != null)
  205. {
  206. ddlLogoName.DisplayMember = "LogoNameCode";
  207. ddlLogoName.ValueMember = "LogoID";
  208. ddlLogoName.DataSource = dtLogoName;
  209. }
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. throw ex;
  215. }
  216. #endregion
  217. }
  218. private void Clear()
  219. {
  220. this.scbGoodsCode.ClearValue();
  221. this.txtKingdeeCode.Clear();
  222. this.ddlLogoName.SelectedText = "";
  223. this.ddlGlazeTypeID.SelectedText = "";
  224. }
  225. private void AddCustomerInfo()
  226. {
  227. ClientRequestEntity cre = new ClientRequestEntity();
  228. cre.NameSpace = "F_MST_1301";
  229. cre.Name = "AddKingdeeCode";
  230. cre.Properties["GOODSCODE"] = this.scbGoodsCode.SearchedValue + "";
  231. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  232. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  233. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text;
  234. cre.Properties["KINGDEECODEONE"] = "";
  235. cre.Properties["FromStatus"] = FromStatus.ToString();
  236. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  237. this.btnSave.Enabled = true;
  238. this.btnCancel.Enabled = true;
  239. if (sre.OtherStatus > 0)
  240. {
  241. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  242. this.Clear();
  243. this.txtKingdeeCode.Focus();
  244. this.ddlGlazeTypeID.ClearValue();
  245. this.ddlLogoName.ClearValue();
  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. private void EditCustomer()
  259. {
  260. ClientRequestEntity cre = new ClientRequestEntity();
  261. cre.NameSpace = "F_MST_1301";
  262. cre.Name = "AddKingdeeCode";
  263. if (this.scbGoodsCode.ValueMember + "" == this.scbGoodsCode.Text + "")
  264. {
  265. cre.Properties["GOODSCODE"] = this.scbGoodsCode.ValueMember + "";
  266. }
  267. else
  268. {
  269. cre.Properties["GOODSCODE"] = this.scbGoodsCode.Text + "";
  270. }
  271. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  272. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  273. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text;
  274. cre.Properties["KINGDEECODEONE"] = KingdeeCodeOne;
  275. cre.Properties["FromStatus"] = FromStatus.ToString();
  276. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  277. this.btnSave.Enabled = true;
  278. this.btnCancel.Enabled = true;
  279. if (sre.OtherStatus > 0)
  280. {
  281. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  282. return;
  283. }
  284. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  285. {
  286. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  287. "存在相同金蝶代码"),
  288. "",
  289. MessageBoxButtons.OK,
  290. MessageBoxIcon.Warning);
  291. return;
  292. }
  293. }
  294. }
  295. }