F_MST_1302.cs 9.0 KB

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