F_MST_1302.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  15. namespace Dongke.IBOSS.PRD.Client.SystemModule
  16. {
  17. public partial class F_MST_1302 : Form
  18. {
  19. #region 成员变量
  20. // 编辑状态
  21. private Constant.FormMode _editStatus;
  22. //记录金蝶代码
  23. private string KingdeeCodeOne;
  24. private string lognameOne;
  25. private string GLAZETYPEOne;
  26. #endregion
  27. #region 构造函数
  28. public F_MST_1302()
  29. {
  30. InitializeComponent();
  31. }
  32. public F_MST_1302(Constant.FormMode frmStatus, string KingdeeCode, string logname,string GLAZETYPE)
  33. {
  34. InitializeComponent();
  35. _editStatus = frmStatus;
  36. // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
  37. if (frmStatus == Constant.FormMode.Add)
  38. {
  39. FromStatus = "Add";
  40. this.Text = "新建";
  41. }
  42. else if (frmStatus == Constant.FormMode.Edit)
  43. {
  44. FromStatus = "Edit";
  45. this.Text = "编辑";
  46. KingdeeCodeOne = KingdeeCode;
  47. if (!string.IsNullOrEmpty(KingdeeCode))
  48. {
  49. //CustomerCodeOne = CustomerCode;
  50. ClientRequestEntity cre = new ClientRequestEntity();
  51. cre.NameSpace = "F_MST_1301";
  52. cre.Name = "GetKingdeeCode";
  53. cre.Properties["KingdeeCode"] = KingdeeCode;
  54. cre.Properties["GoodsCode"] = "";
  55. cre.Properties["GoodsName"] = "";
  56. cre.Properties["LogoName"] = "";
  57. cre.Properties["GlazeType"] = "";
  58. lognameOne = logname;
  59. GLAZETYPEOne = GLAZETYPE;
  60. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  61. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  62. {
  63. DataRow item = sre.Data.Tables[0].Rows[0];
  64. //金蝶代码
  65. this.txtKingdeeCode.Text = KingdeeCode;
  66. //产品编码
  67. this.scbGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  68. }
  69. }
  70. }
  71. // 工具栏按钮文本赋值
  72. this.btnSave.Text = ButtonText.BTN_SAVE;
  73. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  74. }
  75. #endregion
  76. #region 属性
  77. /// <summary>
  78. /// 页面状态
  79. /// </summary>
  80. public string FromStatus
  81. {
  82. get;
  83. set;
  84. }
  85. #endregion
  86. #region 事件
  87. /// <summary>
  88. /// 保存事件
  89. /// </summary>
  90. /// <param name="sender"></param>
  91. /// <param name="e"></param>
  92. private void btnSave_Click(object sender, EventArgs e)
  93. {
  94. try
  95. {
  96. //商品编码
  97. if (string.IsNullOrEmpty(this.scbGoodsCode.Text.ToString()))
  98. {
  99. //必须输入
  100. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商品编码"),
  101. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  102. this.scbGoodsCode.Focus();
  103. return;
  104. }
  105. //金蝶代码
  106. if (string.IsNullOrEmpty(this.txtKingdeeCode.Text.ToString()))
  107. {
  108. //必须输入
  109. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "金蝶代码"),
  110. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  111. this.txtKingdeeCode.Focus();
  112. return;
  113. }
  114. //商标
  115. if (this.ddlLogoName.Text == "")
  116. {
  117. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标"),
  118. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  119. this.ddlLogoName.Focus();
  120. return;
  121. }
  122. //釉料类别
  123. if (this.ddlGlazeTypeID.Text == "")
  124. {
  125. //商标
  126. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "釉料类别"),
  127. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  128. this.ddlGlazeTypeID.Focus();
  129. return;
  130. }
  131. //int returnCustomerID = Constant.INT_IS_ZERO;
  132. //_CustomerEntity = this.SetCustomerEntity();
  133. if (_editStatus == Constant.FormMode.Add)
  134. {
  135. // 新建用户,返回新建的用户ID
  136. this.btnSave.Enabled = false;
  137. this.btnCancel.Enabled = false;
  138. this.AddCustomerInfo();
  139. }
  140. if (_editStatus == Constant.FormMode.Edit)
  141. {
  142. this.btnSave.Enabled = false;
  143. this.btnCancel.Enabled = false;
  144. this.EditCustomer();
  145. this.Close();
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. // 对异常进行共通处理
  151. ExceptionManager.HandleEventException(this.ToString(),
  152. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  153. }
  154. }
  155. /// <summary>
  156. /// 退出事件
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. private void btnCancel_Click(object sender, EventArgs e)
  161. {
  162. }
  163. /// <summary>
  164. /// 页面加载事件
  165. /// </summary>
  166. /// <param name="sender"></param>
  167. /// <param name="e"></param>
  168. private void F_MST_1302_Load(object sender, EventArgs e)
  169. {
  170. try
  171. {
  172. this.ddlGlazeTypeID.ClearValue();
  173. this.ddlLogoName.ClearValue();
  174. this.loadDataSource();
  175. this.ddlGlazeTypeID.SelectedText = GLAZETYPEOne;
  176. int logindex = ddlLogoName.FindStringExact(lognameOne);
  177. this.ddlLogoName.SelectedIndex = logindex;
  178. int index = ddlGlazeTypeID.FindStringExact(GLAZETYPEOne);
  179. this.ddlGlazeTypeID.SelectedIndex = index;
  180. }
  181. catch (Exception ex)
  182. {
  183. // 对异常进行共通处理
  184. ExceptionManager.HandleEventException(this.ToString(),
  185. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  186. }
  187. }
  188. #endregion
  189. #region 私有方法
  190. /// <summary>
  191. /// 下拉框获取数据
  192. /// </summary>
  193. private void loadDataSource()
  194. {
  195. try
  196. {
  197. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  198. if (dtGlazeType != null)
  199. {
  200. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  201. ddlGlazeTypeID.ValueMember = "DictionarylD";
  202. ddlGlazeTypeID.DataSource = dtGlazeType;
  203. }
  204. ClientRequestEntity cre = new ClientRequestEntity();
  205. cre.NameSpace = "F_MST_1301";
  206. cre.Name = "GetLogoName";
  207. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  208. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  209. {
  210. DataTable dtLogoName = sre.Data.Tables[0];
  211. if (dtLogoName != null)
  212. {
  213. ddlLogoName.DisplayMember = "LogoNameCode";
  214. ddlLogoName.ValueMember = "LogoID";
  215. ddlLogoName.DataSource = dtLogoName;
  216. }
  217. }
  218. }
  219. catch (Exception ex)
  220. {
  221. throw ex;
  222. }
  223. #endregion
  224. }
  225. private void Clear()
  226. {
  227. this.scbGoodsCode.ClearValue();
  228. this.txtKingdeeCode.Clear();
  229. this.ddlLogoName.SelectedText = "";
  230. this.ddlGlazeTypeID.SelectedText = "";
  231. }
  232. private void AddCustomerInfo()
  233. {
  234. ClientRequestEntity cre = new ClientRequestEntity();
  235. cre.NameSpace = "F_MST_1301";
  236. cre.Name = "AddKingdeeCode";
  237. if (!string.IsNullOrWhiteSpace(this.scbGoodsCode.Text))
  238. {
  239. if (this.scbGoodsCode.CheckedPKMember.Contains(","))
  240. {
  241. cre.Properties["GOODSCODE"] = scbGoodsCode.Text;
  242. }
  243. else
  244. {
  245. cre.Properties["GOODSCODE"] = scbGoodsCode.Text;
  246. }
  247. }
  248. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  249. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  250. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text.Trim();
  251. cre.Properties["KINGDEECODEONE"] = "";
  252. cre.Properties["FromStatus"] = FromStatus.ToString();
  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. this.Clear();
  260. this.txtKingdeeCode.Focus();
  261. this.ddlGlazeTypeID.ClearValue();
  262. this.ddlLogoName.ClearValue();
  263. return;
  264. }
  265. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  266. {
  267. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  268. "存在相同金蝶代码"),
  269. "",
  270. MessageBoxButtons.OK,
  271. MessageBoxIcon.Warning);
  272. return;
  273. }
  274. }
  275. private void EditCustomer()
  276. {
  277. ClientRequestEntity cre = new ClientRequestEntity();
  278. cre.NameSpace = "F_MST_1301";
  279. cre.Name = "AddKingdeeCode";
  280. if (!string.IsNullOrWhiteSpace(this.scbGoodsCode.Text))
  281. {
  282. cre.Properties["GOODSCODE"] = this.scbGoodsCode.Text;
  283. }
  284. cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
  285. cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
  286. cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text.Trim();
  287. cre.Properties["KINGDEECODEONE"] = KingdeeCodeOne.Trim();
  288. cre.Properties["FromStatus"] = FromStatus.ToString();
  289. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  290. this.btnSave.Enabled = true;
  291. this.btnCancel.Enabled = true;
  292. if (sre.OtherStatus > 0)
  293. {
  294. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  295. return;
  296. }
  297. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  298. {
  299. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  300. "存在相同金蝶代码"),
  301. "",
  302. MessageBoxButtons.OK,
  303. MessageBoxIcon.Warning);
  304. return;
  305. }
  306. }
  307. }
  308. }