F_MST_1302.cs 9.2 KB

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