/******************************************************************************* * 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 属性 /// /// 打开本窗体的来源窗体 /// 1:另存为 /// 2:导入 /// 3:编辑 /// public int FromForm { get; set; } /// /// 模板ID /// public int LayoutID { get; set; } /// /// 模板名 /// public string LayoutName { get; set; } /// /// 产品类别ID /// public int GoodsTypeID { get; set; } /// /// 产品类别编码 /// public string GoodsTypeCode { get; set; } /// /// 产品类别名 /// public string GoodsTypeName { get; set; } /// /// 产品商标ID /// public int? LogoID { get; set; } /// /// 产品商标Name /// public string LogoName { get; set; } /// /// 打印类型 xuwei add 2019-11-20 /// public int? PrintType { get; set; } /// /// 备注 /// public string Remarks { get; set; } #endregion #region 构造函数 /// /// 构造函数 /// public F_MST_012004() { InitializeComponent(); this.InitializeControlText(); } #endregion #region 控件事件 /// /// 页面加载事件 /// /// /// 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 2019-11-20 if(layout["PrintType"].ToString()!="") this.ddlPrintType.SelectedValue = layout["PrintType"].ToString(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 确定按钮按下 /// /// /// 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); } } /// /// 取消按钮按下 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } #endregion #region 私有方法或者函数 /// /// 页面初始化给各控件文本赋值 /// private void InitializeControlText() { // 设置控件的文本内容 this.btnOK.Text = ButtonText.BTN_OK; this.btnCancel.Text = ButtonText.BTN_CANCEL; } /// /// 判断系统是否存在相同的票据 /// /// /// false:不存在 /// true:存在 /// 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(() => { return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity); } ); return Convert.ToBoolean(sre.Result); } catch (Exception ex) { throw ex; } } /// /// 编辑新建票据数据 /// /// /// 0:保存失败 /// 其他:保存成功返回新建票据ID /// 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(() => { 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; } /// /// 产品类别改变事件 /// /// /// 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; } } } }