F_MST_012004.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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 2020-01-03
  212. if(layout["PrintType"] is object)
  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. //xuwei add 2019-11-26
  242. if ("".Equals(this.ddlPrintType.Text.Trim()))
  243. {
  244. MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "打印类型"), this.Text,
  245. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  246. this.ddlPrintType.Focus();
  247. return;
  248. }
  249. //// 判断票据类型输入是否正确
  250. //if (this.ftcLogo.SelectedValue == null)
  251. //{
  252. // MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "产品商标"), this.Text,
  253. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  254. // this.ftcLogo.Focus();
  255. // return;
  256. //}
  257. // 判断票据名称输入是否正确
  258. if (string.IsNullOrEmpty(this.txtInvoiceName.Text.Trim()))
  259. {
  260. MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "模板名称"), this.Text,
  261. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  262. this.txtInvoiceName.Focus();
  263. return;
  264. }
  265. // 判断系统是否存在相同的票据
  266. bool isExistSameInvoice = this.IsExistInvoice();
  267. // 存在相同的票据
  268. if (isExistSameInvoice)
  269. {
  270. MessageBox.Show(string.Format("不允许进行该操作,原因:{0}。", "在该产品类别和商标中已存在打印模板"), this.Text,
  271. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  272. this.scbGoodsType.Focus();
  273. return;
  274. }
  275. // 导入
  276. if (this.FromForm == 2)
  277. {
  278. }
  279. // 编辑
  280. else if (this.FromForm == 3)
  281. {
  282. ServiceResultEntity result = this.SaveEditLayout();
  283. if (result.Status == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ServiceResultStatus.Success)
  284. {
  285. MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "编辑条码打印信息", "保存"),
  286. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  287. this.DialogResult = DialogResult.OK;
  288. this.Close();
  289. }
  290. }
  291. // 另存为
  292. else
  293. {
  294. this.GoodsTypeID = scbGoodsType.SearchedPKMember;
  295. this.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  296. this.GoodsTypeName = scbGoodsType.SearchedText;
  297. this.LayoutName = this.txtInvoiceName.Text.Trim();
  298. this.Remarks = this.txtRemark.Text.Trim();
  299. //xuwei add 2019-11-20
  300. this.PrintType = Convert.ToInt32(ddlPrintType.SelectedValue);
  301. object objLogoID = this.ftcLogo.SelectedValue;
  302. if (objLogoID != null && objLogoID != DBNull.Value)
  303. {
  304. this.LogoID = Convert.ToInt32(objLogoID);
  305. }
  306. else
  307. {
  308. this.LogoID = null;
  309. }
  310. this.LogoName = this.ftcLogo.Text.Trim();
  311. this.DialogResult = DialogResult.OK;
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. // 对异常进行共通处理
  317. ExceptionManager.HandleEventException(this.ToString(),
  318. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  319. }
  320. }
  321. /// <summary>
  322. /// 取消按钮按下
  323. /// </summary>
  324. /// <param name="sender"></param>
  325. /// <param name="e"></param>
  326. private void btnCancel_Click(object sender, EventArgs e)
  327. {
  328. this.DialogResult = DialogResult.Cancel;
  329. this.Close();
  330. }
  331. #endregion
  332. #region 私有方法或者函数
  333. /// <summary>
  334. /// 页面初始化给各控件文本赋值
  335. /// </summary>
  336. private void InitializeControlText()
  337. {
  338. // 设置控件的文本内容
  339. this.btnOK.Text = ButtonText.BTN_OK;
  340. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  341. }
  342. /// <summary>
  343. /// 判断系统是否存在相同的票据
  344. /// </summary>
  345. /// <returns>
  346. /// false:不存在
  347. /// true:存在
  348. /// </returns>
  349. private bool IsExistInvoice()
  350. {
  351. try
  352. {
  353. int? goodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]);
  354. if (!goodsTypeID.HasValue)
  355. {
  356. return true;
  357. }
  358. object value = this.ftcLogo.SelectedValue;
  359. //if (value == null)
  360. //{
  361. // return true;
  362. //}
  363. this._clientRequestEntity = new ClientRequestEntity();
  364. this._clientRequestEntity.NameSpace = "InvoiceLayout";
  365. this._clientRequestEntity.Name = "IsExistBarCodePrintLayout";
  366. this._clientRequestEntity.Properties["GoodsTypeID"] = goodsTypeID.Value;
  367. this._clientRequestEntity.Properties["layoutid"] = LayoutID;
  368. this._clientRequestEntity.Properties["LogoID"] = value;
  369. //xuwei add 2019-11-20
  370. this._clientRequestEntity.Properties["PrintType"] = this.ddlPrintType.SelectedValue;
  371. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  372. {
  373. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  374. }
  375. );
  376. return Convert.ToBoolean(sre.Result);
  377. }
  378. catch (Exception ex)
  379. {
  380. throw ex;
  381. }
  382. }
  383. /// <summary>
  384. /// 编辑新建票据数据
  385. /// </summary>
  386. /// <returns>
  387. /// 0:保存失败
  388. /// 其他:保存成功返回新建票据ID
  389. /// </returns>
  390. private ServiceResultEntity SaveEditLayout()
  391. {
  392. try
  393. {
  394. this._clientRequestEntity = new ClientRequestEntity();
  395. this._clientRequestEntity.NameSpace = "InvoiceLayout";
  396. this._clientRequestEntity.Name = "SaveEditBarCodePrintLayoutInfo";
  397. this._clientRequestEntity.Properties["LayoutID"] = LayoutID;
  398. this._clientRequestEntity.Properties["LayoutName"] = this.txtInvoiceName.Text.Trim();
  399. this._clientRequestEntity.Properties["Remarks"] = this.txtRemark.Text.Trim();
  400. this._clientRequestEntity.Properties["LogoID"] = this.ftcLogo.SelectedValue;
  401. this._clientRequestEntity.Properties["GoodsTypeID"] = scbGoodsType.SearchedPKMember;
  402. this._clientRequestEntity.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue;
  403. this._clientRequestEntity.Properties["GoodsTypeName"] = scbGoodsType.SearchedText;
  404. //xuwei add 2019-11-20
  405. this._clientRequestEntity.Properties["PrintType"] = this.ddlPrintType.SelectedValue;
  406. // 正常标识
  407. if (this.chkValueFlag.Checked)
  408. {
  409. this._clientRequestEntity.Properties["ValueFlag"] = "1";
  410. }
  411. else
  412. {
  413. this._clientRequestEntity.Properties["ValueFlag"] = "0";
  414. }
  415. // 编辑
  416. ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
  417. {
  418. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  419. });
  420. return result;
  421. }
  422. catch (Exception ex)
  423. {
  424. throw ex;
  425. }
  426. }
  427. #endregion
  428. private bool _canChangedText = true;
  429. private void txtInvoiceName_TextChanged(object sender, EventArgs e)
  430. {
  431. this._canChangedText = false;
  432. }
  433. /// <summary>
  434. /// 产品类别改变事件
  435. /// </summary>
  436. /// <param name="sender"></param>
  437. /// <param name="e"></param>
  438. private void scbGoodsType_SearchedItemChanged(object sender, EventArgs e)
  439. {
  440. if (this.FromForm == 1 && this._canChangedText)
  441. {
  442. this.txtInvoiceName.Text = this.scbGoodsType.Text
  443. + "【" + this.ftcLogo.Text + "】";
  444. this._canChangedText = true;
  445. }
  446. }
  447. private void ftcLogo_SelectedIndexChanged(object sender, EventArgs e)
  448. {
  449. if (this.FromForm == 1 && this._canChangedText)
  450. {
  451. this.txtInvoiceName.Text = this.scbGoodsType.Text
  452. + "【" + this.ftcLogo.Text + "】";
  453. this._canChangedText = true;
  454. }
  455. }
  456. }
  457. }