F_MST_013004.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_013002.cs
  5. * 2.功能描述:新票据信息操作
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2016/02/18 1.00 新建
  9. * 周兴 2016/03/11 1.00 编辑
  10. *******************************************************************************/
  11. using System;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.WinForm.Controls;
  19. namespace Dongke.IBOSS.PRD.Client.Controls
  20. {
  21. public partial class F_MST_013004 : DKFormBase
  22. {
  23. #region 成员变量
  24. private ClientRequestEntity _clientRequestEntity = null;
  25. #endregion
  26. #region 属性
  27. /// <summary>
  28. /// 打开本窗体的来源窗体
  29. /// 1:另存为
  30. /// 2:导入
  31. /// 3:编辑
  32. /// </summary>
  33. public int FromForm
  34. {
  35. get;
  36. set;
  37. }
  38. /// <summary>
  39. /// 模板ID
  40. /// </summary>
  41. public int LayoutID
  42. {
  43. get;
  44. set;
  45. }
  46. /// <summary>
  47. /// 模板名
  48. /// </summary>
  49. public string LayoutName
  50. {
  51. get;
  52. set;
  53. }
  54. /// <summary>
  55. /// 产品类别ID
  56. /// </summary>
  57. public int? GoodsTypeID
  58. {
  59. get;
  60. set;
  61. }
  62. /// <summary>
  63. /// 产品类别编码
  64. /// </summary>
  65. public string GoodsTypeCode
  66. {
  67. get;
  68. set;
  69. }
  70. /// <summary>
  71. /// 产品类别名
  72. /// </summary>
  73. public string GoodsTypeName
  74. {
  75. get;
  76. set;
  77. }
  78. /// <summary>
  79. /// 产品商标ID
  80. /// </summary>
  81. public int? LogoID
  82. {
  83. get;
  84. set;
  85. }
  86. /// <summary>
  87. /// 产品商标Name
  88. /// </summary>
  89. public string LogoName
  90. {
  91. get;
  92. set;
  93. }
  94. /// <summary>
  95. /// 备注
  96. /// </summary>
  97. public string Remarks
  98. {
  99. get;
  100. set;
  101. }
  102. #endregion
  103. #region 构造函数
  104. /// <summary>
  105. /// 构造函数
  106. /// </summary>
  107. public F_MST_013004()
  108. {
  109. InitializeComponent();
  110. this.InitializeControlText();
  111. }
  112. #endregion
  113. #region 控件事件
  114. /// <summary>
  115. /// 页面加载事件
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void F_MST_013004_Load(object sender, System.EventArgs e)
  120. {
  121. try
  122. {
  123. if (1 == FromForm)
  124. {
  125. this.chkValueFlag.Checked = true;
  126. this.chkValueFlag.Visible = false;
  127. this.Text = "标签另存为...";
  128. //DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  129. //if (logoInfo != null && logoInfo.Tables.Count > 0)
  130. //{
  131. // this.ftcLogo.DataSource = logoInfo.Tables[0];
  132. // this.ftcLogo.DisplayMember = "LogoNameCode";
  133. // this.ftcLogo.ValueMember = "LogoID";
  134. //}
  135. //if (this.LogoID.HasValue)
  136. //{
  137. // this.ftcLogo.SelectedValue = this.LogoID.Value;
  138. //}
  139. //else
  140. //{
  141. // this.ftcLogo.SelectedValue = DBNull.Value;
  142. //}
  143. }
  144. else if (2 == FromForm)
  145. {
  146. this.chkValueFlag.Checked = true;
  147. this.chkValueFlag.Visible = false;
  148. this.txtInvoiceName.Text = this.LayoutName;
  149. this.Text = "导入标签";
  150. //DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  151. //if (logoInfo != null && logoInfo.Tables.Count > 0)
  152. //{
  153. // this.ftcLogo.DataSource = logoInfo.Tables[0];
  154. // this.ftcLogo.DisplayMember = "LogoNameCode";
  155. // this.ftcLogo.ValueMember = "LogoID";
  156. //}
  157. }
  158. else
  159. {
  160. this.Text = "编辑模具标签信息";
  161. this.chkValueFlag.Visible = true;
  162. //DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  163. //if (logoInfo != null && logoInfo.Tables.Count > 0)
  164. //{
  165. // this.ftcLogo.DataSource = logoInfo.Tables[0];
  166. // this.ftcLogo.DisplayMember = "LogoNameCode";
  167. // this.ftcLogo.ValueMember = "LogoID";
  168. //}
  169. ClientRequestEntity cre = new ClientRequestEntity();
  170. cre.NameSpace = "MouldLableLayout";
  171. cre.Name = "GetMouldLablePrintLayoutInfo";
  172. cre.Properties["LayoutID"] = LayoutID;
  173. ServiceResultEntity sre = SystemModuleProxy.Service.DoBarCodePrint(cre);
  174. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  175. {
  176. DataRow layout = sre.Data.Tables[0].Rows[0];
  177. // 产品类别
  178. this.scbGoodsType.CheckedData = sre.Data.Tables[0];
  179. this.scbGoodsType.Text = layout["GoodsTypeName"].ToString();
  180. this.txtInvoiceName.Text = layout["layoutName"].ToString();
  181. this.txtRemark.Text = layout["Remarks"].ToString();
  182. this.chkValueFlag.Checked = (layout["valueflag"].ToString() == "1");
  183. //if (this.LogoID.HasValue)
  184. //{
  185. // this.ftcLogo.SelectedValue = this.LogoID.Value;
  186. //}
  187. //else
  188. //{
  189. // this.ftcLogo.SelectedValue = DBNull.Value;
  190. //}
  191. //this.ftcLogo.InitValue(layout["LogoNameCode"].ToString(), layout["LogoID"]);
  192. }
  193. }
  194. }
  195. catch (Exception ex)
  196. {
  197. // 对异常进行共通处理
  198. ExceptionManager.HandleEventException(this.ToString(),
  199. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  200. }
  201. }
  202. /// <summary>
  203. /// 确定按钮按下
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void btnOK_Click(object sender, EventArgs e)
  208. {
  209. try
  210. {
  211. // 判断票据名称输入是否正确
  212. if (string.IsNullOrEmpty(this.txtInvoiceName.Text.Trim()))
  213. {
  214. MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "标签名称"), this.Text,
  215. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  216. this.txtInvoiceName.Focus();
  217. return;
  218. }
  219. // 判断系统是否存在相同的票据
  220. bool isExistSameInvoice = this.IsExistInvoice();
  221. // 存在相同的票据
  222. if (isExistSameInvoice)
  223. {
  224. MessageBox.Show(string.Format("不允许进行该操作,原因:{0}。", "在该产品类别中已存在标签模板"), this.Text,
  225. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  226. this.scbGoodsType.Focus();
  227. return;
  228. }
  229. // 导入
  230. if (this.FromForm == 2)
  231. {
  232. }
  233. // 编辑
  234. else if (this.FromForm == 3)
  235. {
  236. ServiceResultEntity result = this.SaveEditLayout();
  237. if (result.Status == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ServiceResultStatus.Success)
  238. {
  239. MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "编辑模具标签信息", "保存"),
  240. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  241. this.DialogResult = DialogResult.OK;
  242. this.Close();
  243. }
  244. }
  245. // 另存为
  246. else
  247. {
  248. this.GoodsTypeID = scbGoodsType.SearchedPKMember;
  249. this.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  250. this.GoodsTypeName = scbGoodsType.SearchedText;
  251. this.LayoutName = this.txtInvoiceName.Text.Trim();
  252. this.Remarks = this.txtRemark.Text.Trim();
  253. //object objLogoID = this.ftcLogo.SelectedValue;
  254. //if (objLogoID != null && objLogoID != DBNull.Value)
  255. //{
  256. // this.LogoID = Convert.ToInt32(objLogoID);
  257. //}
  258. //else
  259. //{
  260. // this.LogoID = null;
  261. //}
  262. //this.LogoName = this.ftcLogo.Text.Trim();
  263. this.DialogResult = DialogResult.OK;
  264. }
  265. }
  266. catch (Exception ex)
  267. {
  268. // 对异常进行共通处理
  269. ExceptionManager.HandleEventException(this.ToString(),
  270. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  271. }
  272. }
  273. /// <summary>
  274. /// 取消按钮按下
  275. /// </summary>
  276. /// <param name="sender"></param>
  277. /// <param name="e"></param>
  278. private void btnCancel_Click(object sender, EventArgs e)
  279. {
  280. this.DialogResult = DialogResult.Cancel;
  281. this.Close();
  282. }
  283. #endregion
  284. #region 私有方法或者函数
  285. /// <summary>
  286. /// 页面初始化给各控件文本赋值
  287. /// </summary>
  288. private void InitializeControlText()
  289. {
  290. // 设置控件的文本内容
  291. this.btnOK.Text = ButtonText.BTN_OK;
  292. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  293. }
  294. /// <summary>
  295. /// 判断系统是否存在相同的票据
  296. /// </summary>
  297. /// <returns>
  298. /// false:不存在
  299. /// true:存在
  300. /// </returns>
  301. private bool IsExistInvoice()
  302. {
  303. try
  304. {
  305. int? goodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]);
  306. //if (!goodsTypeID.HasValue)
  307. //{
  308. // return true;
  309. //}
  310. //object value = this.ftcLogo.SelectedValue;
  311. //if (value == null)
  312. //{
  313. // return true;
  314. //}
  315. this._clientRequestEntity = new ClientRequestEntity();
  316. this._clientRequestEntity.NameSpace = "MouldLableLayout";
  317. this._clientRequestEntity.Name = "IsExistMouldLablePrintLayout";
  318. this._clientRequestEntity.Properties["GoodsTypeID"] = goodsTypeID;
  319. this._clientRequestEntity.Properties["layoutid"] = LayoutID;
  320. //this._clientRequestEntity.Properties["LogoID"] = value;
  321. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  322. {
  323. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  324. }
  325. );
  326. return Convert.ToBoolean(sre.Result);
  327. }
  328. catch (Exception ex)
  329. {
  330. throw ex;
  331. }
  332. }
  333. /// <summary>
  334. /// 编辑新建票据数据
  335. /// </summary>
  336. /// <returns>
  337. /// 0:保存失败
  338. /// 其他:保存成功返回新建票据ID
  339. /// </returns>
  340. private ServiceResultEntity SaveEditLayout()
  341. {
  342. try
  343. {
  344. this._clientRequestEntity = new ClientRequestEntity();
  345. this._clientRequestEntity.NameSpace = "MouldLableLayout";
  346. this._clientRequestEntity.Name = "SaveEditMouldLablePrintLayoutInfo";
  347. this._clientRequestEntity.Properties["LayoutID"] = LayoutID;
  348. this._clientRequestEntity.Properties["LayoutName"] = this.txtInvoiceName.Text.Trim();
  349. this._clientRequestEntity.Properties["Remarks"] = this.txtRemark.Text.Trim();
  350. this._clientRequestEntity.Properties["GoodsTypeID"] = scbGoodsType.SearchedPKMember;
  351. //this._clientRequestEntity.Properties["LogoID"] = this.ftcLogo.SelectedValue;
  352. this._clientRequestEntity.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue;
  353. this._clientRequestEntity.Properties["GoodsTypeName"] = scbGoodsType.SearchedText;
  354. // 正常标识
  355. if (this.chkValueFlag.Checked)
  356. {
  357. this._clientRequestEntity.Properties["ValueFlag"] = "1";
  358. }
  359. else
  360. {
  361. this._clientRequestEntity.Properties["ValueFlag"] = "0";
  362. }
  363. // 编辑
  364. ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
  365. {
  366. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  367. });
  368. return result;
  369. }
  370. catch (Exception ex)
  371. {
  372. throw ex;
  373. }
  374. }
  375. #endregion
  376. private bool _canChangedText = true;
  377. private void txtInvoiceName_TextChanged(object sender, EventArgs e)
  378. {
  379. this._canChangedText = false;
  380. }
  381. }
  382. }