| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_013002.cs
- * 2.功能描述:新票据信息操作
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2016/02/18 1.00 新建
- * 周兴 2016/03/11 1.00 编辑
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing.Printing;
- using System.Reflection;
- 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_013002 : DKFormBase
- {
- #region 成员变量
- //private string _invoiceLayoutID; // 票据设置ID
- private static DataTable _paperSizes; // 纸张尺寸一览
- private int _indexA4 = -1;
- private bool _isSizeChanged = false;
- private bool _allowChangeSize = false;
- private List<int> _invoiceLayoutIDList; // 新建票据ID列表
- private ClientRequestEntity _clientRequestEntity = null; // 查询条件实体
- #endregion
- #region 构造函数
- public F_MST_013002()
- {
- InitializeComponent();
- dgrdPaperSize.AutoGenerateColumns = false;
- InitializePaperSize();
- dgrdPaperSize.ClearSelection();
- this._allowChangeSize = true;
- // 设定按钮文本及窗体文本
- this.btnSave.Text = ButtonText.BTN_OK;
- this.btnCancel.Text = ButtonText.BTN_CANCEL;
- this.Text = F_MST_013001.TITLE_F_MST_013001_ADD;
- //if (this.FormType == WinForm.Controls.FormType.Add)
- //{
- // this.ActiveControl = this.cbxInvoiceType;
- //}
- //else
- //{
- // this.Text = F_MST_013001.TITLE_F_MST_013001_EDIT;
- //}
- //this._invoiceLayoutID = base.FormCode;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 纸张的宽(mm)
- /// </summary>
- [DefaultValue(210)]
- public float PaperWidth
- {
- get
- {
- return System.Convert.ToSingle(numerWidth.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numerWidth.Minimum)
- {
- d = numerWidth.Minimum;
- }
- else if (numerWidth.Maximum < d)
- {
- d = numerWidth.Maximum;
- }
- if (numerWidth.Value != d)
- {
- _isSizeChanged = true;
- numerWidth.Value = d;
- }
- }
- }
- /// <summary>
- /// 纸张的高(mm)
- /// </summary>
- [DefaultValue(297)]
- public float PaperHeight
- {
- get
- {
- return System.Convert.ToSingle(numerHeight.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numerHeight.Minimum)
- {
- d = numerHeight.Minimum;
- }
- else if (numerHeight.Maximum < d)
- {
- d = numerHeight.Maximum;
- }
- if (numerHeight.Value != d)
- {
- _isSizeChanged = true;
- numerHeight.Value = d;
- }
- }
- }
- /// <summary>
- /// 新建票据ID集合
- /// </summary>
- public List<int> InvoiceLayoutIDList
- {
- get
- {
- return _invoiceLayoutIDList;
- }
- set
- {
- _invoiceLayoutIDList = value;
- }
- }
- #endregion
- #region 控件事件
- 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 dgrdPaperSize_SelectionChanged(object sender, System.EventArgs e)
- {
- if (dgrdPaperSize.CurrentRow != null && _allowChangeSize
- && 0 < dgrdPaperSize.SelectedRows.Count)
- {
- PaperHeight =
- System.Convert.ToSingle(dgrdPaperSize.CurrentRow.Cells["colHeight"].Value);
- PaperWidth =
- System.Convert.ToSingle(dgrdPaperSize.CurrentRow.Cells["colWidth"].Value);
- }
- }
- /// <summary>
- /// 列表失去焦点事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgrdPaperSize_Leave(object sender, System.EventArgs e)
- {
- dgrdPaperSize.ClearSelection();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOK_Click(object sender, System.EventArgs e)
- {
- try
- {
- // 判断票据名称输入是否正确
- 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;
- }
- //object objLogoID = this.ftcLogo.SelectedValue;
- //int? logoid = null;
- //if (objLogoID != null && objLogoID != DBNull.Value)
- //{
- // logoid = Convert.ToInt32(objLogoID);
- //}
- // 给票据编辑画面赋值,并打开
- F_MST_013003 frmINV0301 = new F_MST_013003(scbGoodsType.SearchedPKMember,
- scbGoodsType.SearchedValue + "",
- scbGoodsType.SearchedText,
- null,
- null,
- this.PaperWidth,
- this.PaperHeight,
- this.txtInvoiceName.Text.Trim(),
- this.txtRemark.Text.Trim());
- this.Hide();
- DialogResult dialogresult = frmINV0301.ShowDialog();
- if (DialogResult.OK == dialogresult)
- {
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- this.DialogResult = DialogResult.Cancel;
- }
- this.Close();
- }
- 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, System.EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- /// <summary>
- /// 画面打开
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_013002_Load(object sender, EventArgs e)
- {
- //try
- //{
- // 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";
- // }
- //}
- //catch (Exception ex)
- //{
- // // 对异常进行共通处理
- // ExceptionManager.HandleEventException(this.ToString(),
- // MethodBase.GetCurrentMethod().Name, this.Text, ex);
- //}
- }
- #endregion
- #region 重写方法
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 根据本机的打印机取得纸张的信息
- /// </summary>
- private void InitializePaperSize()
- {
- if (_paperSizes == null)
- {
- _paperSizes = new DataTable();
- _paperSizes.TableName = "PaperSizes";
- _paperSizes.Columns.Add("SizeName", typeof(string));
- _paperSizes.Columns.Add("Width", typeof(float));
- _paperSizes.Columns.Add("Height", typeof(float));
- }
- else
- {
- _paperSizes.Clear();
- }
- float height = 0;
- float width = 0;
- int index = 0;
- PrintDocument pd = new PrintDocument();
- foreach (PaperSize ps in pd.PrinterSettings.PaperSizes)
- {
- DataRow dataRow = _paperSizes.NewRow();
- height = Dongke.IBOSS.PRD.Basics.Library.Utility.Inch100ToMillimeter(ps.Height);
- width = Dongke.IBOSS.PRD.Basics.Library.Utility.Inch100ToMillimeter(ps.Width);
- dataRow[0] = string.Format("{0} {1:0}mm×{2:0}mm", ps.PaperName, width, height);
- dataRow[1] = Math.Round(width);
- dataRow[2] = Math.Round(height);
- _paperSizes.Rows.Add(dataRow);
- if (ps.PaperName.StartsWith("A4") && 210.0f.Equals(dataRow[1]) && 297.0f.Equals(dataRow[2]) && _indexA4 < 0)
- {
- _indexA4 = index;
- }
- index++;
- }
- dgrdPaperSize.DataSource = _paperSizes;
- }
- /// <summary>
- /// 判断系统是否存在相同的票据
- /// </summary>
- /// <returns>
- /// false:不存在
- /// true:存在
- /// </returns>
- private bool IsExistInvoice()
- {
- try
- {
- int? goodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]);
- //if (!goodsTypeID.HasValue)
- //{
- // return true;
- //}
- //if (this.ftcLogo.SelectedValue == null)
- //{
- // return true;
- //}
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "MouldLableLayout";
- this._clientRequestEntity.Name = "IsExistMouldLablePrintLayout";
- this._clientRequestEntity.Properties["GoodsTypeID"] = goodsTypeID;
- //this._clientRequestEntity.Properties["LogoID"] = this.ftcLogo.SelectedValue;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- }
- );
- return Convert.ToBoolean(sre.Result);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|