F_MST_012004.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_012002.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_012004 : 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. /// 打印类型 xuwei add 2019-11-20
  96. /// </summary>
  97. public int? PrintType
  98. {
  99. get;
  100. set;
  101. }
  102. /// <summary>
  103. /// 备注
  104. /// </summary>
  105. public string Remarks
  106. {
  107. get;
  108. set;
  109. }
  110. #endregion
  111. #region 构造函数
  112. /// <summary>
  113. /// 构造函数
  114. /// </summary>
  115. public F_MST_012004()
  116. {
  117. InitializeComponent();
  118. this.InitializeControlText();
  119. }
  120. #endregion
  121. #region 控件事件
  122. /// <summary>
  123. /// 页面加载事件
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. private void F_MST_012004_Load(object sender, System.EventArgs e)
  128. {
  129. try
  130. {
  131. //加载 打印类型 xuwei begin 2019-11-20
  132. this.ddlPrintType.DisplayMember = "PRINTTYPENAME";
  133. this.ddlPrintType.ValueMember = "PRINTTYPEID";
  134. ClientRequestEntity ptCre = new ClientRequestEntity();
  135. ptCre.NameSpace = "PrintInfo";
  136. ptCre.Name = "GetPrintType";
  137. DataTable dtPrintType = SystemModuleProxy.Service.DoBarCodePrint(ptCre).Data.Tables[0];
  138. this.ddlPrintType.DataSource = dtPrintType;
  139. //加载 打印类型 xuwei end
  140. if (1 == FromForm)
  141. {
  142. this.chkValueFlag.Checked = true;
  143. this.chkValueFlag.Visible = false;
  144. this.Text = "票据另存为...";
  145. DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  146. if (logoInfo != null && logoInfo.Tables.Count > 0)
  147. {
  148. this.ftcLogo.DataSource = logoInfo.Tables[0];
  149. this.ftcLogo.DisplayMember = "LogoNameCode";
  150. this.ftcLogo.ValueMember = "LogoID";
  151. }
  152. if (this.LogoID.HasValue)
  153. {
  154. this.ftcLogo.SelectedValue = this.LogoID.Value;
  155. }
  156. else
  157. {
  158. this.ftcLogo.SelectedValue = DBNull.Value;
  159. }
  160. }
  161. else if (2 == FromForm)
  162. {
  163. this.chkValueFlag.Checked = true;
  164. this.chkValueFlag.Visible = false;
  165. this.txtInvoiceName.Text = this.LayoutName;
  166. this.Text = "导入票据";
  167. DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  168. if (logoInfo != null && logoInfo.Tables.Count > 0)
  169. {
  170. this.ftcLogo.DataSource = logoInfo.Tables[0];
  171. this.ftcLogo.DisplayMember = "LogoNameCode";
  172. this.ftcLogo.ValueMember = "LogoID";
  173. }
  174. }
  175. else
  176. {
  177. this.Text = "编辑条码打印信息";
  178. this.chkValueFlag.Visible = true;
  179. DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
  180. if (logoInfo != null && logoInfo.Tables.Count > 0)
  181. {
  182. this.ftcLogo.DataSource = logoInfo.Tables[0];
  183. this.ftcLogo.DisplayMember = "LogoNameCode";
  184. this.ftcLogo.ValueMember = "LogoID";
  185. }
  186. ClientRequestEntity cre = new ClientRequestEntity();
  187. cre.NameSpace = "InvoiceLayout";
  188. cre.Name = "GetBarCodePrintLayoutInfo";
  189. cre.Properties["LayoutID"] = LayoutID;
  190. ServiceResultEntity sre = SystemModuleProxy.Service.DoBarCodePrint(cre);
  191. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  192. {
  193. DataRow layout = sre.Data.Tables[0].Rows[0];
  194. //this.scbGoodsType.GoodsTypeID = Convert.ToInt32(layout["GoodsTypeID"]);
  195. //this.scbGoodsType.GoodsTypeCode = layout["GoodsTypeCode"].ToString();
  196. //this.scbGoodsType.GoodsTypeName = layout["GoodsTypeName"].ToString();
  197. this.scbGoodsType.CheckedData = sre.Data.Tables[0];
  198. this.scbGoodsType.Text = layout["GoodsTypeName"].ToString();
  199. this.txtInvoiceName.Text = layout["layoutName"].ToString();
  200. this.txtRemark.Text = layout["Remarks"].ToString();
  201. this.chkValueFlag.Checked = (layout["valueflag"].ToString() == "1");
  202. //if (this.LogoID.HasValue)
  203. //{
  204. // this.ftcLogo.SelectedValue = this.LogoID.Value;
  205. //}
  206. //else
  207. //{
  208. // this.ftcLogo.SelectedValue = DBNull.Value;
  209. //}
  210. this.ftcLogo.InitValue(layout["LogoNameCode"].ToString(), layout["LogoID"]);
  211. //xuwei add 2019-11-20
  212. if(layout["PrintType"].ToString()!="")
  213. this.ddlPrintType.SelectedValue = layout["PrintType"].ToString();
  214. }
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. // 对异常进行共通处理
  220. ExceptionManager.HandleEventException(this.ToString(),
  221. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  222. }
  223. }
  224. /// <summary>
  225. /// 确定按钮按下
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void btnOK_Click(object sender, EventArgs e)
  230. {
  231. try
  232. {
  233. // 判断票据类型输入是否正确
  234. if ("".Equals(this.scbGoodsType.Text.Trim()))
  235. {
  236. MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "产品类别"), this.Text,
  237. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  238. this.scbGoodsType.Focus();
  239. return;
  240. }
  241. //// 判断票据类型输入是否正确
  242. //if (this.ftcLogo.SelectedValue == null)
  243. //{
  244. // MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "产品商标"), this.Text,
  245. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  246. // this.ftcLogo.Focus();
  247. // return;
  248. //}
  249. // 判断票据名称输入是否正确
  250. if (string.IsNullOrEmpty(this.txtInvoiceName.Text.Trim()))
  251. {
  252. MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "模板名称"), this.Text,
  253. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  254. this.txtInvoiceName.Focus();
  255. return;
  256. }
  257. // 判断系统是否存在相同的票据
  258. bool isExistSameInvoice = this.IsExistInvoice();
  259. // 存在相同的票据
  260. if (isExistSameInvoice)
  261. {
  262. MessageBox.Show(string.Format("不允许进行该操作,原因:{0}。", "在该产品类别和商标中已存在打印模板"), this.Text,
  263. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  264. this.scbGoodsType.Focus();
  265. return;
  266. }
  267. // 导入
  268. if (this.FromForm == 2)
  269. {
  270. }
  271. // 编辑
  272. else if (this.FromForm == 3)
  273. {
  274. ServiceResultEntity result = this.SaveEditLayout();
  275. if (result.Status == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ServiceResultStatus.Success)
  276. {
  277. MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "编辑条码打印信息", "保存"),
  278. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  279. this.DialogResult = DialogResult.OK;
  280. this.Close();
  281. }
  282. }
  283. // 另存为
  284. else
  285. {
  286. this.GoodsTypeID = scbGoodsType.SearchedPKMember;
  287. this.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  288. this.GoodsTypeName = scbGoodsType.SearchedText;
  289. this.LayoutName = this.txtInvoiceName.Text.Trim();
  290. this.Remarks = this.txtRemark.Text.Trim();
  291. //xuwei add 2019-11-20
  292. this.PrintType = Convert.ToInt32(ddlPrintType.SelectedValue);
  293. object objLogoID = this.ftcLogo.SelectedValue;
  294. if (objLogoID != null && objLogoID != DBNull.Value)
  295. {
  296. this.LogoID = Convert.ToInt32(objLogoID);
  297. }
  298. else
  299. {
  300. this.LogoID = null;
  301. }
  302. this.LogoName = this.ftcLogo.Text.Trim();
  303. this.DialogResult = DialogResult.OK;
  304. }
  305. }
  306. catch (Exception ex)
  307. {
  308. // 对异常进行共通处理
  309. ExceptionManager.HandleEventException(this.ToString(),
  310. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  311. }
  312. }
  313. /// <summary>
  314. /// 取消按钮按下
  315. /// </summary>
  316. /// <param name="sender"></param>
  317. /// <param name="e"></param>
  318. private void btnCancel_Click(object sender, EventArgs e)
  319. {
  320. this.DialogResult = DialogResult.Cancel;
  321. this.Close();
  322. }
  323. #endregion
  324. #region 私有方法或者函数
  325. /// <summary>
  326. /// 页面初始化给各控件文本赋值
  327. /// </summary>
  328. private void InitializeControlText()
  329. {
  330. // 设置控件的文本内容
  331. this.btnOK.Text = ButtonText.BTN_OK;
  332. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  333. }
  334. /// <summary>
  335. /// 判断系统是否存在相同的票据
  336. /// </summary>
  337. /// <returns>
  338. /// false:不存在
  339. /// true:存在
  340. /// </returns>
  341. private bool IsExistInvoice()
  342. {
  343. try
  344. {
  345. int? goodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]);
  346. if (!goodsTypeID.HasValue)
  347. {
  348. return true;
  349. }
  350. object value = this.ftcLogo.SelectedValue;
  351. //if (value == null)
  352. //{
  353. // return true;
  354. //}
  355. this._clientRequestEntity = new ClientRequestEntity();
  356. this._clientRequestEntity.NameSpace = "InvoiceLayout";
  357. this._clientRequestEntity.Name = "IsExistBarCodePrintLayout";
  358. this._clientRequestEntity.Properties["GoodsTypeID"] = goodsTypeID.Value;
  359. this._clientRequestEntity.Properties["layoutid"] = LayoutID;
  360. this._clientRequestEntity.Properties["LogoID"] = value;
  361. //xuwei add 2019-11-20
  362. this._clientRequestEntity.Properties["PrintType"] = this.ddlPrintType.SelectedValue;
  363. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  364. {
  365. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  366. }
  367. );
  368. return Convert.ToBoolean(sre.Result);
  369. }
  370. catch (Exception ex)
  371. {
  372. throw ex;
  373. }
  374. }
  375. /// <summary>
  376. /// 编辑新建票据数据
  377. /// </summary>
  378. /// <returns>
  379. /// 0:保存失败
  380. /// 其他:保存成功返回新建票据ID
  381. /// </returns>
  382. private ServiceResultEntity SaveEditLayout()
  383. {
  384. try
  385. {
  386. this._clientRequestEntity = new ClientRequestEntity();
  387. this._clientRequestEntity.NameSpace = "InvoiceLayout";
  388. this._clientRequestEntity.Name = "SaveEditBarCodePrintLayoutInfo";
  389. this._clientRequestEntity.Properties["LayoutID"] = LayoutID;
  390. this._clientRequestEntity.Properties["LayoutName"] = this.txtInvoiceName.Text.Trim();
  391. this._clientRequestEntity.Properties["Remarks"] = this.txtRemark.Text.Trim();
  392. this._clientRequestEntity.Properties["LogoID"] = this.ftcLogo.SelectedValue;
  393. this._clientRequestEntity.Properties["GoodsTypeID"] = scbGoodsType.SearchedPKMember;
  394. this._clientRequestEntity.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue;
  395. this._clientRequestEntity.Properties["GoodsTypeName"] = scbGoodsType.SearchedText;
  396. //xuwei add 2019-11-20
  397. this._clientRequestEntity.Properties["PrintType"] = this.ddlPrintType.SelectedValue;
  398. // 正常标识
  399. if (this.chkValueFlag.Checked)
  400. {
  401. this._clientRequestEntity.Properties["ValueFlag"] = "1";
  402. }
  403. else
  404. {
  405. this._clientRequestEntity.Properties["ValueFlag"] = "0";
  406. }
  407. // 编辑
  408. ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
  409. {
  410. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  411. });
  412. return result;
  413. }
  414. catch (Exception ex)
  415. {
  416. throw ex;
  417. }
  418. }
  419. #endregion
  420. private bool _canChangedText = true;
  421. private void txtInvoiceName_TextChanged(object sender, EventArgs e)
  422. {
  423. this._canChangedText = false;
  424. }
  425. /// <summary>
  426. /// 产品类别改变事件
  427. /// </summary>
  428. /// <param name="sender"></param>
  429. /// <param name="e"></param>
  430. private void scbGoodsType_SearchedItemChanged(object sender, EventArgs e)
  431. {
  432. if (this.FromForm == 1 && this._canChangedText)
  433. {
  434. this.txtInvoiceName.Text = this.scbGoodsType.Text
  435. + "【" + this.ftcLogo.Text + "】";
  436. this._canChangedText = true;
  437. }
  438. }
  439. private void ftcLogo_SelectedIndexChanged(object sender, EventArgs e)
  440. {
  441. if (this.FromForm == 1 && this._canChangedText)
  442. {
  443. this.txtInvoiceName.Text = this.scbGoodsType.Text
  444. + "【" + this.ftcLogo.Text + "】";
  445. this._canChangedText = true;
  446. }
  447. }
  448. }
  449. }