F_MST_1301.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_1301.cs
  5. * 2.功能描述:产品档案
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. /// <summary>
  22. /// 产品档案
  23. /// </summary>
  24. public partial class F_MST_1301 : DockPanelBase
  25. {
  26. #region 成员变量
  27. private static F_MST_1301 _instance; //单例模式
  28. #endregion
  29. #region 构造函数
  30. public F_MST_1301()
  31. {
  32. InitializeComponent();
  33. this.Text = "金蝶代码对应";
  34. // 按钮
  35. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  36. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  37. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  38. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  39. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  40. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  41. }
  42. #endregion
  43. #region 单例模式
  44. /// <summary>
  45. /// 单例模式,防止重复创建窗体
  46. /// </summary>
  47. public static F_MST_1301 Instance
  48. {
  49. get
  50. {
  51. if (_instance == null)
  52. {
  53. _instance = new F_MST_1301();
  54. }
  55. return _instance;
  56. }
  57. }
  58. #endregion
  59. #region 事件
  60. /// <summary>
  61. /// 窗体加载
  62. /// </summary>
  63. private void F_MST_1301_Load(object sender, EventArgs e)
  64. {
  65. try
  66. {
  67. this.dgvGoosKingdeecode.AutoGenerateColumns = false;
  68. this.loadDataSource();
  69. this.ddlGlazeTypeID.ClearValue();
  70. this.ddlLogoName.ClearValue();
  71. FormPermissionManager.FormPermissionControl(this.Name, this,
  72. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  73. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  74. }
  75. catch (Exception ex)
  76. {
  77. // 对异常进行共通处理
  78. ExceptionManager.HandleEventException(this.ToString(),
  79. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  80. }
  81. }
  82. /// <summary>
  83. /// 清空事件
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. private void btnClearCondition_Click(object sender, EventArgs e)
  88. {
  89. this.goodscodetxt.Clear();
  90. this.goodsnametxt.Clear();
  91. this.ddlGlazeTypeID.ClearValue();
  92. this.ddlLogoName.ClearValue();
  93. this.txtKingdeeCode.Clear();
  94. }
  95. /// <summary>
  96. /// 查询事件
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void btnSearch_Click(object sender, EventArgs e)
  101. {
  102. try
  103. {
  104. this.DataSource = this.GetSearchData();
  105. if (this.DataSource != null)
  106. {
  107. this.dgvGoosKingdeecode.DataSource = this.DataSource.Tables[0];
  108. }
  109. }
  110. catch (Exception ex)
  111. {
  112. // 对异常进行共通处理
  113. ExceptionManager.HandleEventException(this.ToString(),
  114. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  115. }
  116. }
  117. /// <summary>
  118. /// 新建事件
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnAdd_Click(object sender, EventArgs e)
  123. {
  124. try
  125. {
  126. F_MST_1302 frmMST1302 = new F_MST_1302(Constant.FormMode.Add,"","","","");
  127. DialogResult dialogResult = frmMST1302.ShowDialog();
  128. // 重新加载GridView
  129. btnSearch_Click(sender, null);
  130. }
  131. catch (Exception ex)
  132. {
  133. // 对异常进行共通处理
  134. ExceptionManager.HandleEventException(this.ToString(),
  135. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  136. }
  137. }
  138. /// <summary>
  139. /// 编辑事件
  140. /// </summary>
  141. /// <param name="sender"></param>
  142. /// <param name="e"></param>
  143. private void tsbtnEdit_Click(object sender, EventArgs e)
  144. {
  145. try
  146. {
  147. if (this.dgvGoosKingdeecode.SelectedRows.Count != 0)
  148. {
  149. string KingdeeCode = this.dgvGoosKingdeecode.SelectedRows[0].Cells["KINGDEECODE"].Value.ToString();
  150. string logname= this.dgvGoosKingdeecode.SelectedRows[0].Cells["LOGONAME"].Value.ToString();
  151. string GLAZETYPE= this.dgvGoosKingdeecode.SelectedRows[0].Cells["GLAZETYPE"].Value.ToString();
  152. string GoodsCode = this.dgvGoosKingdeecode.SelectedRows[0].Cells["GOODSCODE"].Value.ToString();
  153. F_MST_1302 frmFPC1302 = new F_MST_1302(Constant.FormMode.Edit, KingdeeCode, logname, GLAZETYPE, GoodsCode);
  154. DialogResult dialogresult = frmFPC1302.ShowDialog();
  155. btnSearch_Click(sender, null);
  156. }
  157. }
  158. catch (Exception ex)
  159. {
  160. // 对异常进行共通处理
  161. ExceptionManager.HandleEventException(this.ToString(),
  162. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  163. }
  164. }
  165. /// <summary>
  166. /// 自适应列宽
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  171. {
  172. this.dgvGoosKingdeecode.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  173. }
  174. /// <summary>
  175. /// 关闭事件
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. private void tsbtnClose_Click(object sender, EventArgs e)
  180. {
  181. this.Close();
  182. }
  183. /// <summary>
  184. /// 窗体关闭事件
  185. /// </summary>
  186. /// <param name="sender"></param>
  187. /// <param name="e"></param>
  188. private void F_MST_1301_FormClosed(object sender, FormClosedEventArgs e)
  189. {
  190. _instance = null;
  191. }
  192. #endregion
  193. #region 私有方法
  194. private DataSet GetSearchData()
  195. {
  196. try
  197. {
  198. ClientRequestEntity cre = new ClientRequestEntity();
  199. cre.NameSpace = "F_MST_1301";
  200. cre.Name = "GetKingdeeCode";
  201. cre.Properties["GoodsCode"] = this.goodscodetxt.Text;
  202. cre.Properties["GoodsName"] = this.goodsnametxt.Text;
  203. cre.Properties["GlazeType"] = this.ddlGlazeTypeID.Text;
  204. cre.Properties["LogoName"] = this.ddlLogoName.Text;
  205. cre.Properties["KingdeeCode"] = this.txtKingdeeCode.Text;
  206. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  207. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  208. {
  209. return sre.Data;
  210. }
  211. return null;
  212. }
  213. catch (Exception ex)
  214. {
  215. throw ex;
  216. }
  217. }
  218. /// <summary>
  219. /// 下拉框获取数据
  220. /// </summary>
  221. private void loadDataSource()
  222. {
  223. try
  224. {
  225. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  226. if (dtGlazeType != null)
  227. {
  228. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  229. ddlGlazeTypeID.ValueMember = "DictionarylD";
  230. ddlGlazeTypeID.DataSource = dtGlazeType;
  231. }
  232. ClientRequestEntity cre = new ClientRequestEntity();
  233. cre.NameSpace = "F_MST_1301";
  234. cre.Name = "GetLogoName";
  235. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  236. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  237. {
  238. DataTable dtLogoName = sre.Data.Tables[0];
  239. if (dtLogoName != null)
  240. {
  241. ddlLogoName.DisplayMember = "LogoNameCode";
  242. ddlLogoName.ValueMember = "LogoID";
  243. ddlLogoName.DataSource = dtLogoName;
  244. }
  245. }
  246. }
  247. catch (Exception ex)
  248. {
  249. throw ex;
  250. }
  251. }
  252. #endregion
  253. private void delBtn_Click(object sender, EventArgs e)
  254. {
  255. try
  256. {
  257. if (this.dgvGoosKingdeecode.SelectedRows.Count != 0)
  258. {
  259. ClientRequestEntity cre = new ClientRequestEntity();
  260. cre.NameSpace = "F_MST_1301";
  261. cre.Name = "AddKingdeeCode";
  262. cre.Properties["FromStatus"] ="Delete";
  263. cre.Properties["GUID"] = this.dgvGoosKingdeecode.SelectedRows[0].Cells["GUID"].Value.ToString(); ;
  264. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  265. if (sre.OtherStatus > 0)
  266. {
  267. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  268. }
  269. btnSearch_Click(sender, null);//删除后重新查询数据
  270. }
  271. }
  272. catch (Exception ex)
  273. {
  274. // 对异常进行共通处理
  275. ExceptionManager.HandleEventException(this.ToString(),
  276. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  277. }
  278. }
  279. }
  280. }