| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_012002.cs
- * 2.功能描述:新票据信息操作
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2016/02/18 1.00 新建
- * 周兴 2016/03/11 1.00 编辑
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.WinForm.Controls;
- namespace Dongke.IBOSS.PRD.Client.Controls
- {
- public partial class F_MST_012004 : DKFormBase
- {
- #region 成员变量
- private ClientRequestEntity _clientRequestEntity = null;
- #endregion
- #region 属性
- /// <summary>
- /// 打开本窗体的来源窗体
- /// 1:另存为
- /// 2:导入
- /// 3:编辑
- /// </summary>
- public int FromForm
- {
- get;
- set;
- }
- /// <summary>
- /// 模板ID
- /// </summary>
- public int LayoutID
- {
- get;
- set;
- }
- /// <summary>
- /// 模板名
- /// </summary>
- public string LayoutName
- {
- get;
- set;
- }
- /// <summary>
- /// 产品类别ID
- /// </summary>
- public int GoodsTypeID
- {
- get;
- set;
- }
- /// <summary>
- /// 产品类别编码
- /// </summary>
- public string GoodsTypeCode
- {
- get;
- set;
- }
- /// <summary>
- /// 产品类别名
- /// </summary>
- public string GoodsTypeName
- {
- get;
- set;
- }
- /// <summary>
- /// 产品商标ID
- /// </summary>
- public int? LogoID
- {
- get;
- set;
- }
- /// <summary>
- /// 产品商标Name
- /// </summary>
- public string LogoName
- {
- get;
- set;
- }
- /// <summary>
- /// 打印类型 xuwei add 2019-11-20
- /// </summary>
- public int? PrintType
- {
- get;
- set;
- }
- /// <summary>
- /// 备注
- /// </summary>
- public string Remarks
- {
- get;
- set;
- }
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_MST_012004()
- {
- InitializeComponent();
- this.InitializeControlText();
- }
- #endregion
- #region 控件事件
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_012004_Load(object sender, System.EventArgs e)
- {
- try
- {
- //加载 打印类型 xuwei begin 2019-11-20
- this.ddlPrintType.DisplayMember = "PRINTTYPENAME";
- this.ddlPrintType.ValueMember = "PRINTTYPEID";
- ClientRequestEntity ptCre = new ClientRequestEntity();
- ptCre.NameSpace = "PrintInfo";
- ptCre.Name = "GetPrintType";
- DataTable dtPrintType = SystemModuleProxy.Service.DoBarCodePrint(ptCre).Data.Tables[0];
- this.ddlPrintType.DataSource = dtPrintType;
- //加载 打印类型 xuwei end
- if (1 == FromForm)
- {
- this.chkValueFlag.Checked = true;
- this.chkValueFlag.Visible = false;
- this.Text = "票据另存为...";
- DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
- if (logoInfo != null && logoInfo.Tables.Count > 0)
- {
- this.ftcLogo.DataSource = logoInfo.Tables[0];
- this.ftcLogo.DisplayMember = "LogoNameCode";
- this.ftcLogo.ValueMember = "LogoID";
- }
- if (this.LogoID.HasValue)
- {
- this.ftcLogo.SelectedValue = this.LogoID.Value;
- }
- else
- {
- this.ftcLogo.SelectedValue = DBNull.Value;
- }
- }
- else if (2 == FromForm)
- {
- this.chkValueFlag.Checked = true;
- this.chkValueFlag.Visible = false;
- this.txtInvoiceName.Text = this.LayoutName;
- this.Text = "导入票据";
- DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
- if (logoInfo != null && logoInfo.Tables.Count > 0)
- {
- this.ftcLogo.DataSource = logoInfo.Tables[0];
- this.ftcLogo.DisplayMember = "LogoNameCode";
- this.ftcLogo.ValueMember = "LogoID";
- }
- }
- else
- {
- this.Text = "编辑条码打印信息";
- this.chkValueFlag.Visible = true;
- DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
- if (logoInfo != null && logoInfo.Tables.Count > 0)
- {
- this.ftcLogo.DataSource = logoInfo.Tables[0];
- this.ftcLogo.DisplayMember = "LogoNameCode";
- this.ftcLogo.ValueMember = "LogoID";
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "InvoiceLayout";
- cre.Name = "GetBarCodePrintLayoutInfo";
- cre.Properties["LayoutID"] = LayoutID;
- ServiceResultEntity sre = SystemModuleProxy.Service.DoBarCodePrint(cre);
- if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
- {
- DataRow layout = sre.Data.Tables[0].Rows[0];
- //this.scbGoodsType.GoodsTypeID = Convert.ToInt32(layout["GoodsTypeID"]);
- //this.scbGoodsType.GoodsTypeCode = layout["GoodsTypeCode"].ToString();
- //this.scbGoodsType.GoodsTypeName = layout["GoodsTypeName"].ToString();
- this.scbGoodsType.CheckedData = sre.Data.Tables[0];
- this.scbGoodsType.Text = layout["GoodsTypeName"].ToString();
- this.txtInvoiceName.Text = layout["layoutName"].ToString();
- this.txtRemark.Text = layout["Remarks"].ToString();
- this.chkValueFlag.Checked = (layout["valueflag"].ToString() == "1");
- //if (this.LogoID.HasValue)
- //{
- // this.ftcLogo.SelectedValue = this.LogoID.Value;
- //}
- //else
- //{
- // this.ftcLogo.SelectedValue = DBNull.Value;
- //}
- this.ftcLogo.InitValue(layout["LogoNameCode"].ToString(), layout["LogoID"]);
- //xuwei add 2020-01-03
- if(layout["PrintType"] is object)
- this.ddlPrintType.SelectedValue = layout["PrintType"].ToString();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 确定按钮按下
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- // 判断票据类型输入是否正确
- if ("".Equals(this.scbGoodsType.Text.Trim()))
- {
- MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "产品类别"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.scbGoodsType.Focus();
- return;
- }
- //xuwei add 2019-11-26
- if ("".Equals(this.ddlPrintType.Text.Trim()))
- {
- MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "打印类型"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.ddlPrintType.Focus();
- return;
- }
- //// 判断票据类型输入是否正确
- //if (this.ftcLogo.SelectedValue == null)
- //{
- // MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "产品商标"), this.Text,
- // MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.ftcLogo.Focus();
- // return;
- //}
- // 判断票据名称输入是否正确
- if (string.IsNullOrEmpty(this.txtInvoiceName.Text.Trim()))
- {
- MessageBox.Show(string.Format("{0}是必须输入项目,请输入{0}。", "模板名称"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtInvoiceName.Focus();
- return;
- }
- // 判断系统是否存在相同的票据
- bool isExistSameInvoice = this.IsExistInvoice();
- // 存在相同的票据
- if (isExistSameInvoice)
- {
- MessageBox.Show(string.Format("不允许进行该操作,原因:{0}。", "在该产品类别和商标中已存在打印模板"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.scbGoodsType.Focus();
- return;
- }
- // 导入
- if (this.FromForm == 2)
- {
- }
- // 编辑
- else if (this.FromForm == 3)
- {
- ServiceResultEntity result = this.SaveEditLayout();
- if (result.Status == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "编辑条码打印信息", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- }
- // 另存为
- else
- {
- this.GoodsTypeID = scbGoodsType.SearchedPKMember;
- this.GoodsTypeCode = scbGoodsType.SearchedValue + "";
- this.GoodsTypeName = scbGoodsType.SearchedText;
- this.LayoutName = this.txtInvoiceName.Text.Trim();
- this.Remarks = this.txtRemark.Text.Trim();
- //xuwei add 2019-11-20
- this.PrintType = Convert.ToInt32(ddlPrintType.SelectedValue);
- object objLogoID = this.ftcLogo.SelectedValue;
- if (objLogoID != null && objLogoID != DBNull.Value)
- {
- this.LogoID = Convert.ToInt32(objLogoID);
- }
- else
- {
- this.LogoID = null;
- }
- this.LogoName = this.ftcLogo.Text.Trim();
- this.DialogResult = DialogResult.OK;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 取消按钮按下
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- #endregion
- #region 私有方法或者函数
- /// <summary>
- /// 页面初始化给各控件文本赋值
- /// </summary>
- private void InitializeControlText()
- {
- // 设置控件的文本内容
- this.btnOK.Text = ButtonText.BTN_OK;
- this.btnCancel.Text = ButtonText.BTN_CANCEL;
- }
- /// <summary>
- /// 判断系统是否存在相同的票据
- /// </summary>
- /// <returns>
- /// false:不存在
- /// true:存在
- /// </returns>
- private bool IsExistInvoice()
- {
- try
- {
- int? goodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]);
- if (!goodsTypeID.HasValue)
- {
- return true;
- }
- object value = this.ftcLogo.SelectedValue;
- //if (value == null)
- //{
- // return true;
- //}
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "InvoiceLayout";
- this._clientRequestEntity.Name = "IsExistBarCodePrintLayout";
- this._clientRequestEntity.Properties["GoodsTypeID"] = goodsTypeID.Value;
- this._clientRequestEntity.Properties["layoutid"] = LayoutID;
- this._clientRequestEntity.Properties["LogoID"] = value;
- //xuwei add 2019-11-20
- this._clientRequestEntity.Properties["PrintType"] = this.ddlPrintType.SelectedValue;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- }
- );
- return Convert.ToBoolean(sre.Result);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 编辑新建票据数据
- /// </summary>
- /// <returns>
- /// 0:保存失败
- /// 其他:保存成功返回新建票据ID
- /// </returns>
- private ServiceResultEntity SaveEditLayout()
- {
- try
- {
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "InvoiceLayout";
- this._clientRequestEntity.Name = "SaveEditBarCodePrintLayoutInfo";
- this._clientRequestEntity.Properties["LayoutID"] = LayoutID;
- this._clientRequestEntity.Properties["LayoutName"] = this.txtInvoiceName.Text.Trim();
- this._clientRequestEntity.Properties["Remarks"] = this.txtRemark.Text.Trim();
- this._clientRequestEntity.Properties["LogoID"] = this.ftcLogo.SelectedValue;
- this._clientRequestEntity.Properties["GoodsTypeID"] = scbGoodsType.SearchedPKMember;
- this._clientRequestEntity.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue;
- this._clientRequestEntity.Properties["GoodsTypeName"] = scbGoodsType.SearchedText;
- //xuwei add 2019-11-20
- this._clientRequestEntity.Properties["PrintType"] = this.ddlPrintType.SelectedValue;
- // 正常标识
- if (this.chkValueFlag.Checked)
- {
- this._clientRequestEntity.Properties["ValueFlag"] = "1";
- }
- else
- {
- this._clientRequestEntity.Properties["ValueFlag"] = "0";
- }
- // 编辑
- ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- });
- return result;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- private bool _canChangedText = true;
- private void txtInvoiceName_TextChanged(object sender, EventArgs e)
- {
- this._canChangedText = false;
- }
- /// <summary>
- /// 产品类别改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void scbGoodsType_SearchedItemChanged(object sender, EventArgs e)
- {
- if (this.FromForm == 1 && this._canChangedText)
- {
- this.txtInvoiceName.Text = this.scbGoodsType.Text
- + "【" + this.ftcLogo.Text + "】";
- this._canChangedText = true;
- }
- }
- private void ftcLogo_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.FromForm == 1 && this._canChangedText)
- {
- this.txtInvoiceName.Text = this.scbGoodsType.Text
- + "【" + this.ftcLogo.Text + "】";
- this._canChangedText = true;
- }
- }
- }
- }
|