F_PM_2118.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 == -2)
  176. {
  177. // 提示信息
  178. MessageBox.Show("条码不存在",
  179. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  180. }
  181. else if (returnValue == -3)
  182. {
  183. // 提示信息
  184. MessageBox.Show("已交接的产品不能变更商标",
  185. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  186. }
  187. else if (returnValue == -5)
  188. {
  189. // 提示信息
  190. MessageBox.Show("该商标已超过生产计划允许变更数量,不能变更商标",
  191. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  192. }
  193. else
  194. {
  195. // 提示信息
  196. MessageBox.Show("保存失败",
  197. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  198. }
  199. }
  200. catch (Exception ex)
  201. {
  202. // 对异常进行共通处理
  203. ExceptionManager.HandleEventException(this.ToString(),
  204. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  205. }
  206. }
  207. /// <summary>
  208. /// 回车符事件
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  213. {
  214. try
  215. {
  216. if (this.txtLogo.ReadOnly)
  217. {
  218. return;
  219. }
  220. if ((int)e.KeyChar == 13) // 按了回车键
  221. {
  222. DataTable dt = this.cmbLogo.DataSource as DataTable;
  223. if (dt != null && dt.Rows.Count > 0)
  224. {
  225. DataRow[] dr = dt.Select("LogoCode='" + this.txtLogo.Text.Trim() + "'");
  226. if (dr.Length > 0)
  227. {
  228. this.LogoID = Convert.ToInt32(dr[0]["LogoID"]);
  229. this.cmbLogo.SelectedValue = this.LogoID;
  230. }
  231. else
  232. {
  233. DataRow[] dr2 = dt.Select("isdefault='1'");
  234. if (dr2.Length > 0)
  235. {
  236. this.LogoID = Convert.ToInt32(dr2[0]["LogoID"]);
  237. this.cmbLogo.SelectedValue = this.LogoID;
  238. }
  239. else
  240. {
  241. this.LogoID = this.defaultlogoid;
  242. this.cmbLogo.SelectedValue = this.LogoID;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. catch (Exception ex)
  249. {
  250. // 对异常进行共通处理
  251. ExceptionManager.HandleEventException(this.ToString(),
  252. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  253. }
  254. }
  255. #endregion
  256. private void txtBarcode_KeyPress_1(object sender, KeyPressEventArgs e)
  257. {
  258. try
  259. {
  260. if (this.txtBarcode.ReadOnly)
  261. {
  262. return;
  263. }
  264. if ((int)e.KeyChar == 13) // 按了回车键
  265. {
  266. if (this.txtBarcode.Text.Trim() == string.Empty)
  267. {
  268. this.txtBarcode.Focus();
  269. this.txtBarcode.Focus();
  270. return;
  271. }
  272. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  273. {
  274. return PMModuleProxy.Service.GetBarCodeLogoID(this.txtBarcode.Text.Trim());
  275. }));
  276. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  277. {
  278. this._barcode = this.txtBarcode.Text.Trim();
  279. this.txtOrgLogo.Text = dsCheckBarcode.Tables[0].Rows[0]["logoname"].ToString() + "[" + dsCheckBarcode.Tables[0].Rows[0]["logocode"].ToString() + "]";
  280. //this.cmbLogo.SelectedValue = dsCheckBarcode.Tables[0].Rows[0]["logoid"].ToString();
  281. }
  282. else
  283. {
  284. MessageBox.Show("无效条码",
  285. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  286. this.txtBarcode.Text = "";
  287. this.txtOrgLogo.Text = "";
  288. this.txtLogo.Text = "";
  289. this._barcode = "";
  290. this.cmbLogo.SelectedValue = defaultlogoid;
  291. return;
  292. }
  293. }
  294. }
  295. catch (Exception ex)
  296. {
  297. // 对异常进行共通处理
  298. ExceptionManager.HandleEventException(this.ToString(),
  299. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  300. }
  301. }
  302. }
  303. }