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