F_PM_2118.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2118.cs
  5. * 2.功能描述:工序商标
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/11/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. public partial class F_PM_2118 : DKFormBase
  24. {
  25. #region 成员变量
  26. private string _currentbarcode = "";//当前产品条码
  27. private int? _logoid = null; // 商标ID
  28. private string _logoCode = "";//商标编码
  29. private string _logoName = "";//商标编码
  30. private string _barcode = ""; //产品条码
  31. private int? defaultlogoid = null;
  32. #endregion
  33. #region 属性
  34. /// <summary>
  35. /// 商标ID
  36. /// </summary>
  37. public int? LogoID
  38. {
  39. set
  40. {
  41. _logoid = value;
  42. }
  43. get
  44. {
  45. return _logoid;
  46. }
  47. }
  48. /// <summary>
  49. /// 商标编码
  50. /// </summary>
  51. public string LogoCode
  52. {
  53. set
  54. {
  55. _logoCode = value;
  56. }
  57. get
  58. {
  59. return _logoCode;
  60. }
  61. }
  62. /// <summary>
  63. /// 商标名称
  64. /// </summary>
  65. public string LogoName
  66. {
  67. set
  68. {
  69. _logoName = value;
  70. }
  71. get
  72. {
  73. return _logoName;
  74. }
  75. }
  76. #endregion
  77. #region 构造函数
  78. public F_PM_2118()
  79. {
  80. InitializeComponent();
  81. this.btnClose.Text = ButtonText.BTN_CLOSE;
  82. this.btnSave.Text = ButtonText.BTN_SAVE;
  83. this.Text = "商标";
  84. }
  85. public F_PM_2118(int logoid)
  86. {
  87. InitializeComponent();
  88. this.btnClose.Text = ButtonText.BTN_CLOSE;
  89. this.btnSave.Text = ButtonText.BTN_SAVE;
  90. this.Text = "商标";
  91. this.LogoID = logoid;
  92. }
  93. #endregion
  94. #region 事件
  95. /// <summary>
  96. /// 窗体加载事件
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void F_PM_2118_Load(object sender, EventArgs e)
  101. {
  102. // 加载商标数据源
  103. DataSet dsResultLogo = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  104. {
  105. //return SystemModuleProxy.Service.GetAllLogoInfo();
  106. return SystemModuleProxy.Service.GetLogoInfo();
  107. }));
  108. if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
  109. {
  110. //DataView dv = dsResultLogo.Tables[0].DefaultView;
  111. //dv.RowFilter = "ValueFlag=1";
  112. this.cmbLogo.DataSource = dsResultLogo.Tables[0];
  113. this.cmbLogo.ValueMember = "LogoID";
  114. this.cmbLogo.DisplayMember = "LogoNameCode";
  115. defaultlogoid = Convert.ToInt32(this.cmbLogo.SelectedValue);
  116. //this.cmbLogo.SelectedValue = this.LogoID;
  117. //DataTable dt = this.cmbLogo.DataSource as DataTable;
  118. //DataRow[] dr = dt.Select("logoID='" + this.LogoID + "'");
  119. //if (dr.Length > 0)
  120. //{
  121. // this.LogoCode = dr[0]["LogoCode"].ToString();
  122. // this.LogoName = dr[0]["LogoName"].ToString();
  123. //}
  124. }
  125. }
  126. /// <summary>
  127. /// 保存按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnSave_Click(object sender, EventArgs e)
  132. {
  133. try
  134. {
  135. if(this.txtOrgLogo.Text.Trim()=="")
  136. {
  137. // 提示信息
  138. MessageBox.Show("请先扫描条码",
  139. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  140. this.txtOrgLogo.Text = "";
  141. this.txtLogo.Text = "";
  142. this.txtBarcode.Text = "";
  143. this.txtBarcode.Focus();
  144. return;
  145. }
  146. DataTable dt = this.cmbLogo.DataSource as DataTable;
  147. if(dt==null || dt.Rows.Count==0)
  148. {
  149. // 提示信息
  150. MessageBox.Show("请先设置商标",
  151. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  152. this.txtOrgLogo.Text = "";
  153. this.txtLogo.Text = "";
  154. this.txtBarcode.Text = "";
  155. this.txtBarcode.Focus();
  156. return;
  157. }
  158. int logoid = Convert.ToInt32(cmbLogo.SelectedValue);
  159. int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
  160. {
  161. return PMModuleProxy.Service.SaveBarCodeLogo(this._barcode,logoid);
  162. }));
  163. if (returnValue > 0)
  164. {
  165. // 提示信息
  166. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  167. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  168. this._barcode = "";
  169. this.txtOrgLogo.Text = "";
  170. this.txtLogo.Text = "";
  171. this.cmbLogo.SelectedIndex = 0;
  172. this.txtBarcode.Text = "";
  173. //this.DialogResult = DialogResult.OK;
  174. }
  175. else if (returnValue == 0)
  176. {
  177. // 提示信息
  178. MessageBox.Show("保存失败",
  179. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. // 对异常进行共通处理
  185. ExceptionManager.HandleEventException(this.ToString(),
  186. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  187. }
  188. }
  189. /// <summary>
  190. /// 回车符事件
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  195. {
  196. try
  197. {
  198. if (this.txtLogo.ReadOnly)
  199. {
  200. return;
  201. }
  202. if ((int)e.KeyChar == 13) // 按了回车键
  203. {
  204. DataTable dt = this.cmbLogo.DataSource as DataTable;
  205. if (dt != null && dt.Rows.Count > 0)
  206. {
  207. DataRow[] dr = dt.Select("LogoCode='" + this.txtLogo.Text.Trim() + "'");
  208. if (dr.Length > 0)
  209. {
  210. this.LogoID = Convert.ToInt32(dr[0]["LogoID"]);
  211. this.cmbLogo.SelectedValue = this.LogoID;
  212. }
  213. else
  214. {
  215. DataRow[] dr2 = dt.Select("isdefault='1'");
  216. if (dr2.Length > 0)
  217. {
  218. this.LogoID = Convert.ToInt32(dr2[0]["LogoID"]);
  219. this.cmbLogo.SelectedValue = this.LogoID;
  220. }
  221. else
  222. {
  223. this.LogoID = this.defaultlogoid;
  224. this.cmbLogo.SelectedValue = this.LogoID;
  225. }
  226. }
  227. }
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. // 对异常进行共通处理
  233. ExceptionManager.HandleEventException(this.ToString(),
  234. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  235. }
  236. }
  237. #endregion
  238. private void txtBarcode_KeyPress_1(object sender, KeyPressEventArgs e)
  239. {
  240. try
  241. {
  242. if (this.txtBarcode.ReadOnly)
  243. {
  244. return;
  245. }
  246. if ((int)e.KeyChar == 13) // 按了回车键
  247. {
  248. if (this.txtBarcode.Text.Trim() == string.Empty)
  249. {
  250. this.txtBarcode.Focus();
  251. this.txtBarcode.Focus();
  252. return;
  253. }
  254. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  255. {
  256. return PMModuleProxy.Service.GetBarCodeLogoID(this.txtBarcode.Text.Trim());
  257. }));
  258. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  259. {
  260. this._barcode = this.txtBarcode.Text.Trim();
  261. this.txtOrgLogo.Text = dsCheckBarcode.Tables[0].Rows[0]["logoname"].ToString() + "[" + dsCheckBarcode.Tables[0].Rows[0]["logocode"].ToString() + "]";
  262. //this.cmbLogo.SelectedValue = dsCheckBarcode.Tables[0].Rows[0]["logoid"].ToString();
  263. }
  264. else
  265. {
  266. MessageBox.Show("无效条码",
  267. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  268. this.txtBarcode.Text = "";
  269. this.txtOrgLogo.Text = "";
  270. this.txtLogo.Text = "";
  271. this._barcode = "";
  272. this.cmbLogo.SelectedValue = defaultlogoid;
  273. return;
  274. }
  275. }
  276. }
  277. catch (Exception ex)
  278. {
  279. // 对异常进行共通处理
  280. ExceptionManager.HandleEventException(this.ToString(),
  281. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  282. }
  283. }
  284. }
  285. }