| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187 |
- /*******************************************************************************
- * 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.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- 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;
- using Dongke.WinForm.Controls.InvoiceLayout;
- namespace Dongke.IBOSS.PRD.Client.Controls
- {
- public partial class F_MST_012003 : DKFormBase
- {
- #region 成员变量
- private float _paperHeight; // Layout的纸张的高
- private float _paperWidth; // Layout的纸张的宽
- private int _goodstypeid; // 产品类别ID
- private string _goodstypeCode; // 产品类别编码
- private string _goodstypeName; // 产品类别名称
- private int? _logoid; // 产品商标ID
- private bool _zooming = false; // 缩放标识
- private int _invoiceLayoutID; // 票据ID
- private DataTable _invoiceLayoutDataTable; // 票据主信息数据
- private DataSet _saveData; // 保存票据数据时的数据集
- private bool _layoutSelectionChanging; // 选择标识
- private bool _isFormDataChanged = false; // 画面的数据是否有改变
- private ClientRequestEntity _clientRequestEntity; // 查询条件实体
- //private string _remarks; // 总单备注
- //xuwei add 2019-11-20
- private int? _printType; //打印类别
- #endregion
- #region 属性
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_MST_012003(int goodstypeID, string goodstypeCode, string goodstypeName, int? logoid, string logoname,
- float paperWidth, float paperHeight, string layoutName,int printType, string remarks)
- {
- InitializeComponent();
- this.Text = string.Format(F_MST_012001.TITLE_F_MST_012001_NEW, layoutName);
- this.cbxMagnification.SelectedIndex = 3;
- this.txtGoodsType.Text = goodstypeName + "【" + goodstypeCode + "】";
- this.txtLogo.Text = logoname;
- this.txtInvoiceName.Text = layoutName;
- this._paperHeight = paperHeight;
- this._paperWidth = paperWidth;
- this._invoiceLayoutID = 0;
- this._goodstypeid = goodstypeID;
- this._goodstypeCode = goodstypeCode;
- this._goodstypeName = goodstypeName;
- this._logoid = logoid;
- this.txtRemarks.Text = remarks;
- this.lbxInvoice.LayoutMode = LayoutMode.Edit;
- this._printType = printType;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_MST_012003(int layoutID)
- {
- InitializeComponent();
- this.cbxMagnification.SelectedIndex = 3;
- this._invoiceLayoutID = layoutID;
- this.lbxInvoice.LayoutMode = LayoutMode.Edit;
- }
- #endregion
- #region 控件事件
- #region 窗体控件事件
- /// <summary>
- /// 显示比率选项发生改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbxMagnification_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- try
- {
- _zooming = true;
- // 选择了全体显示
- if (cbxMagnification.SelectedItem.ToString().Equals("全体"))
- {
- lbxInvoice.ZoomType = ZoomType.Whole;
- }
- else
- {
- // 选择了其他选择
- lbxInvoice.Zoom = Convert.ToInt32(cbxMagnification.SelectedItem.ToString().Replace("%", ""));
- }
- _zooming = false;
- }
- catch (Exception ex)
- {
- _zooming = false;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 保存按钮按下,保存票据数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnSave_Click(object sender, System.EventArgs e)
- {
- try
- {
- _saveData = new DataSet();
- // 更新票据主信息的DataTable
- this.SetSaveLayoutData(ref _saveData, this._invoiceLayoutID);
- // 组成票据项目信息的DataTable
- this.SetSaveLayoutItemData(ref _saveData);
- // 新建票据的情况
- if (this._invoiceLayoutID == 0)
- {
- ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
- {
- return this.SaveAddLayoutData();
- });
- int invoiceLayoutID = Convert.ToInt32(result.Result);
- if (invoiceLayoutID > 0)
- {
- MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "新建条码打印格式", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- // 新建成功后,将画面修改成编辑状态
- this._invoiceLayoutID = invoiceLayoutID;
- this.Text = string.Format(F_MST_012001.TITLE_F_MST_012002_EDIT, this.txtInvoiceName.Text.Trim());
- this._invoiceLayoutDataTable = _saveData.Tables[0];
- this.tsbtnSaveAs.Enabled = true;
- this.tsmiSaveAs.Enabled = true;
- }
- else
- {
- MessageBox.Show(string.Format("{0}的{1}操作没有更新任何数据,请确认该数据是否存在。", "新建条码打印", "保存"),
- this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning);
- }
- }
- else
- {
- ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
- {
- return this.SaveEditLayoutData();
- });
- int returnAffectRows = Convert.ToInt32(result.Result);
- if (returnAffectRows > 0)
- {
- MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "编辑条码打印格式", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show(string.Format("{0}的{1}操作没有更新任何数据,请确认该数据是否存在。", "编辑条码打印", "保存"),
- this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning);
- }
- }
- this.lbxInvoice.AcceptChange();
- _isFormDataChanged = true;
- }
- 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 tsmiSave_Click(object sender, System.EventArgs e)
- {
- this.tsbtnSave_Click(sender, e);
- }
- /// <summary>
- /// 另存为按钮按下,另存票据数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnSaveAs_Click(object sender, System.EventArgs e)
- {
- try
- {
- F_MST_012004 frmINV0302 = new F_MST_012004();
- frmINV0302.LayoutName = this.txtInvoiceName.Text.Trim();
- frmINV0302.Remarks = this.txtRemarks.Text.Trim();
- frmINV0302.GoodsTypeID = this._goodstypeid;
- frmINV0302.GoodsTypeCode = this._goodstypeCode;
- frmINV0302.GoodsTypeName = this._goodstypeName;
- frmINV0302.LogoID = this._logoid;
- frmINV0302.LogoName = this.txtLogo.Text;
- //xuwei add 2019-11-20
- frmINV0302.PrintType = this._printType;
- frmINV0302.FromForm = 1;
- DialogResult dialogResult = frmINV0302.ShowDialog();
- if (DialogResult.OK == dialogResult)
- {
- // 将另存为页面信息传递到本页面
- this.txtInvoiceName.Text = frmINV0302.LayoutName;
- this.txtRemarks.Text = frmINV0302.Remarks;
- this._goodstypeid = frmINV0302.GoodsTypeID;
- this._goodstypeCode = frmINV0302.GoodsTypeCode;
- this._goodstypeName = frmINV0302.GoodsTypeName;
- this.txtGoodsType.Text = _goodstypeName + "【" + _goodstypeCode + "】";
- this._logoid = frmINV0302.LogoID;
- this.txtLogo.Text = frmINV0302.LogoName;
- //xuwei add 2019-11-20
- this._printType = frmINV0302.PrintType;
- _saveData = new DataSet();
- // 更新票据主信息的DataTable
- this.SetSaveLayoutData(ref _saveData, 0);
- // 组成票据项目信息的DataTable
- this.SetSaveLayoutItemData(ref _saveData);
- // 另存票据的情况
- ServiceResultEntity result = this.DoAsync<ServiceResultEntity>(() =>
- {
- return this.SaveAddLayoutData();
- });
- int invoiceLayoutID = Convert.ToInt32(result.Result);
- if (invoiceLayoutID > 0)
- {
- // 将窗体标题修改成另存为的标题
- MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "另存条码打印格式", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- // 新建成功后,将画面修改成编辑状态
- this._invoiceLayoutID = invoiceLayoutID;
- this.Text = string.Format(F_MST_012001.TITLE_F_MST_012002_EDIT, this.txtInvoiceName.Text.Trim());
- this._invoiceLayoutDataTable = _saveData.Tables[0];
- }
- else
- {
- MessageBox.Show(string.Format("{0}的{1}操作没有更新任何数据,请确认该数据是否存在。", "另存条码打印格式", "保存"),
- this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning);
- }
- this.lbxInvoice.AcceptChange();
- _isFormDataChanged = true;
- }
- }
- 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 tsmiSaveAs_Click(object sender, System.EventArgs e)
- {
- this.tsbtnSaveAs_Click(sender, e);
- }
- /// <summary>
- /// 关闭菜单按钮按下,关闭页面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiClose_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 窗体关闭时检测页面是否有变动,提示保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_INV_0301_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
- {
- try
- {
- // 新建票据时,关闭窗体设置窗体的DialogResult属性
- if (this._invoiceLayoutID == 0)
- {
- // 提示是否保存数据
- DialogResult dialogResult = MessageBox.Show("当前页面的数据有过更改,请确认需要保存吗?", this.Text,
- MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (DialogResult.Yes == dialogResult)
- {
- // 保存数据
- tsbtnSave_Click(sender, e);
- this.DialogResult = DialogResult.OK;
- }
- else if (DialogResult.Cancel == dialogResult)
- {
- e.Cancel = true;
- }
- else
- {
- if (_isFormDataChanged)
- {
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- this.DialogResult = DialogResult.Cancel;
- }
- }
- }
- // 编辑票据
- else
- {
- _saveData = new DataSet();
- if (this.lbxInvoice.Dirty)
- {
- // 提示是否保存数据
- DialogResult dialogResult = MessageBox.Show("当前页面的数据有过更改,请确认需要保存吗?", this.Text,
- MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (DialogResult.Yes == dialogResult)
- {
- // 保存数据
- tsbtnSave_Click(sender, e);
- this.DialogResult = DialogResult.OK;
- }
- else if (DialogResult.Cancel == dialogResult)
- {
- e.Cancel = true;
- }
- else
- {
- if (_isFormDataChanged)
- {
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- this.DialogResult = DialogResult.Cancel;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 票据功能按钮事件
- /// <summary>
- /// 剪切按钮按下,剪切项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnCut_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.CutItem();
- }
- /// <summary>
- /// 剪切菜单按下,剪切项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiCut_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.CutItem();
- }
- /// <summary>
- /// 复制按钮按下,复制项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnCopy_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.CopyItem();
- }
- /// <summary>
- /// 复制菜单按下,复制项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiCopy_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.CopyItem();
- }
- /// <summary>
- /// 粘贴按钮按下,粘贴项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnPaste_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.PasteItem();
- }
- /// <summary>
- /// 粘贴菜单按下,粘贴项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiPaste_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.PasteItem();
- }
- /// <summary>
- /// 删除按钮按下,删除项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnDelete_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.DeleteItem();
- }
- /// <summary>
- /// 删除菜单按钮,删除项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiDelete_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.DeleteItem();
- }
- /// <summary>
- /// 固定文字按钮按下,新建固定文字
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnNewTextItem_Click(object sender, EventArgs e)
- {
- try
- {
- TextItem newTextItem = this.lbxInvoice.NewItem(ItemType.Text, true) as TextItem;
- if (newTextItem != null)
- {
- newTextItem.DataMember = string.Empty;
- }
- }
- 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 tsmiCharacter_Click(object sender, EventArgs e)
- {
- this.tsbtnNewTextItem_Click(sender, e);
- }
- /// <summary>
- /// 表格按钮按下,新建表格
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnDataGrid_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.lbxInvoice.OneGridItem != null)
- {
- MessageBox.Show("票据中已经存在一个表格了\r\n\r\n*一个票据中只能有一个格", this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.lbxInvoice.SelectItemSingle(this.lbxInvoice.OneGridItem, true);
- return;
- }
- this.lbxInvoice.NewItem(ItemType.Grid, true);
- }
- 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 tsmiTable_Click(object sender, EventArgs e)
- {
- this.tsbtnDataGrid_Click(sender, e);
- }
- /// <summary>
- /// 固定列按钮按下,新建列
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAddGridColumn_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.lbxInvoice.OneGridItem == null)
- {
- this.lbxInvoice.NewItem(ItemType.Grid, false);
- }
- string name = this.lbxInvoice.OneGridItem.Columns.GeNewColumnName();
- this.lbxInvoice.OneGridItem.Columns.Add(name, name);
- this.lbxInvoice.Refresh();
- }
- 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 tsmiColumn_Click(object sender, EventArgs e)
- {
- this.tsbtnAddGridColumn_Click(sender, e);
- }
- /// <summary>
- /// 添加图片按钮按下,添加图片项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAddImage_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.NewItem(ItemType.Image, true);
- }
- 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 tsmiImage_Click(object sender, EventArgs e)
- {
- this.tsbtnAddImage_Click(sender, e);
- }
- /// <summary>
- /// 页码按钮按下,添加页码项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnPageNumber_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.NewItem(ItemType.PageNum, true);
- }
- 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 tsmiPageNumber_Click(object sender, EventArgs e)
- {
- this.tsbtnPageNumber_Click(sender, e);
- }
- /// <summary>
- /// 金额按钮按下,添加金额项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAddAmount_Click(object sender, EventArgs e)
- {
- try
- {
- TotalTextItem textItem
- = this.lbxInvoice.NewItem(ItemType.TotalText, false) as TotalTextItem;
- textItem.ShowItemPropertyDialog();
- }
- 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 tsmiMoney_Click(object sender, EventArgs e)
- {
- this.tsbtnAddAmount_Click(sender, e);
- }
- /// <summary>
- /// 纸张尺寸按钮按下,调整纸张尺寸
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnPaperSize_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.ShowPaperPropertyDialog();
- }
- 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 tsmiPaperSize_Click(object sender, EventArgs e)
- {
- this.tsbtnPaperSize_Click(sender, e);
- }
- /// <summary>
- /// 背景图片按钮按下,添加背景图片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnBackgroundImage_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.ShowBackgroundSettingDialog();
- }
- 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 tsmiBackgroundImage_Click(object sender, EventArgs e)
- {
- this.tsbtnBackgroundImage_Click(sender, e);
- }
- /// <summary>
- /// 矩形按钮按下,新建矩形项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnRectangle_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.NewItem(ItemType.Rectangle, true);
- }
- 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 tsmiRectangle_Click(object sender, EventArgs e)
- {
- this.tsbtnRectangle_Click(sender, e);
- }
- /// <summary>
- /// 椭圆按钮按下,新建椭圆项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnCircle_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.NewItem(ItemType.Ellipse, true);
- }
- 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 tsmiCircular_Click(object sender, EventArgs e)
- {
- this.tsbtnCircle_Click(sender, e);
- }
- /// <summary>
- /// 项目水平左对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAlignmentLeft_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsLeft();
- }
- /// <summary>
- /// 项目水平左对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiAlignmentLeft_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsLeft();
- }
- /// <summary>
- /// 水平居中对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAlignmentCenter_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsHorizontalCenter();
- }
- /// <summary>
- /// 水平居中对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiAlignmentCenter_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsHorizontalCenter();
- }
- /// <summary>
- /// 水平右对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAlignmentRight_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsRight();
- }
- /// <summary>
- /// 水平右对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiAlignmentRight_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsRight();
- }
- /// <summary>
- /// 垂直顶端对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAlignmentTop_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsTop();
- }
- /// <summary>
- /// 垂直顶端对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiAlignmentTop_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsTop();
- }
- /// <summary>
- /// 垂直居中对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAlignmentMiddle_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsVerticalCenter();
- }
- /// <summary>
- /// 垂直居中对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiAlignmentMiddle_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsVerticalCenter();
- }
- /// <summary>
- /// 垂直底端对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAlignmentBottom_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsBottom();
- }
- /// <summary>
- /// 垂直底端对齐
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiAlignmentBottom_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ArrangeItemsBottom();
- }
- /// <summary>
- /// 置于顶层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnMoveTop_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderForemost();
- }
- /// <summary>
- /// 置于顶层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiFrontMost_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderForemost();
- }
- /// <summary>
- /// 上移一层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnMoveFront_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderFront();
- }
- /// <summary>
- /// 上移一层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiFront_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderFront();
- }
- /// <summary>
- /// 下移一层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnMoveUnder_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderBack();
- }
- /// <summary>
- /// 下移一层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiBack_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderBack();
- }
- /// <summary>
- /// 置于底层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnMoveBottom_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderAftermost();
- }
- /// <summary>
- /// 置于底层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsmiBackMost_Click(object sender, EventArgs e)
- {
- this.lbxInvoice.ChangeItemsOrderAftermost();
- }
- /// <summary>
- /// 详细按钮按下,查看项目详细信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnDetail_Click(object sender, EventArgs e)
- {
- try
- {
- this.lbxInvoice.ShowItemPropertyDialog();
- }
- 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 tsmiDetail_Click(object sender, EventArgs e)
- {
- this.tsbtnDetail_Click(sender, e);
- }
- #endregion
- #region 票据控件事件
- /// <summary>
- /// 票据显示比率改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbxInvoice_ZoomChanged(object sender, EventArgs e)
- {
- if (!_zooming)
- {
- if (lbxInvoice.ZoomType == ZoomType.Whole)
- {
- cbxMagnification.SelectedIndex = 0;
- }
- else if (lbxInvoice.Zoom == 500)
- {
- cbxMagnification.SelectedIndex = 1;
- }
- else if (lbxInvoice.Zoom == 200)
- {
- cbxMagnification.SelectedIndex = 2;
- }
- else if (lbxInvoice.Zoom == 100)
- {
- cbxMagnification.SelectedIndex = 3;
- }
- else if (lbxInvoice.Zoom == 75)
- {
- cbxMagnification.SelectedIndex = 4;
- }
- else if (lbxInvoice.Zoom == 50)
- {
- cbxMagnification.SelectedIndex = 5;
- }
- else if (lbxInvoice.Zoom == 33)
- {
- cbxMagnification.SelectedIndex = 6;
- }
- else if (lbxInvoice.Zoom == 25)
- {
- cbxMagnification.SelectedIndex = 7;
- }
- else if (lbxInvoice.Zoom == 10)
- {
- cbxMagnification.SelectedIndex = 8;
- }
- }
- }
- /// <summary>
- /// 票据纸张尺寸改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbxInvoice_PaperSizeChanged(object sender, EventArgs e)
- {
- this.txtInvoiceSize.Text = string.Format("{0:0.0}mm×{1:0.0}mm",
- lbxInvoice.PaperWidth,
- lbxInvoice.PaperHeight);
- }
- /// <summary>
- /// layoutbox控件中项目的选择状态改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbxInvoice_UserSelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this._layoutSelectionChanging)
- {
- return;
- }
- this._layoutSelectionChanging = true;
- if (this.lbxInvoice.SelectedItems.Count == 0)
- {
- dgvText.ClearSelection();
- dgvDetail.ClearSelection();
- this._layoutSelectionChanging = false;
- return;
- }
- int textItemID = -1;
- foreach (LayoutItem item in this.lbxInvoice.SelectedItems)
- {
- if (item.ItemType == ItemType.Text ||
- item.ItemType == ItemType.QRcode ||
- item.ItemType == ItemType.Barcode)
- {
- TextItem textItem = item as TextItem;
- if (textItem != null
- )
- {
- textItemID = textItem.ID;
- break;
- }
- }
- else if (item.ItemType == ItemType.TotalText)
- {
- TotalTextItem totalTextItem = item as TotalTextItem;
- if (totalTextItem != null
- )
- {
- textItemID = totalTextItem.ID;
- break;
- }
- }
- }
- if (0 < textItemID)
- {
- int itemID = 0;
- foreach (DataGridViewRow row in this.dgvText.Rows)
- {
- if (!row.IsNewRow)
- {
- itemID = System.Convert.ToInt32(row.Cells["LayoutItemID"].Value);
- if (0 < itemID && textItemID == itemID)
- {
- dgvText.CurrentCell = row.Cells[0];
- break;
- }
- else
- {
- //row.Selected = false;
- }
- }
- else
- {
- //row.Selected = false;
- }
- }
- }
- else
- {
- dgvText.ClearSelection();
- }
- this._layoutSelectionChanging = false;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 改变layoutbox控件中项目的选择状态
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbxInvoice_ItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e)
- {
- this.SetLayoutBoxFunctionButtonStatus();
- }
- /// <summary>
- /// 改变layoutbox控件中项目的属性
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbxInvoice_ItemChanged(object sender, Dongke.WinForm.Controls.InvoiceLayout.ItemChangedEventArgs e)
- {
- try
- {
- if (e.ChangedType == ItemChangeType.Modified
- && e.Item.ItemType == ItemType.Grid
- && "Columns".Equals(e.Property))
- {
- DataTable layoutItem = this.dgvDetail.DataSource as DataTable;
- DataRow[] drLayoutItems = layoutItem.Select();
- Dongke.WinForm.Controls.InvoiceLayout.GridItem gridItem = e.Item as Dongke.WinForm.Controls.InvoiceLayout.GridItem;
- foreach (DataRow dr in drLayoutItems)
- {
- int colID = Convert.ToInt32(dr["LayoutItemID"]);
- if (!gridItem.Columns.Contains(colID))
- {
- dr.Delete();
- }
- }
- }
- else if (e.ChangedType == ItemChangeType.Deleted
- && e.Item.ItemType == ItemType.Grid)
- {
- DataTable layoutItem = this.dgvDetail.DataSource as DataTable;
- DataRow[] drLayoutItems = layoutItem.Select();
- foreach (DataRow dr in drLayoutItems)
- {
- dr.Delete();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 向layoutbox控件中添加项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbxInvoice_UserAddedItem(object sender, Dongke.WinForm.Controls.InvoiceLayout.ItemChangedEventArgs e)
- {
- try
- {
- if (e.Item.ItemType == ItemType.Text)
- {
- TextItem textItem = e.Item as TextItem;
- if (textItem != null && !string.IsNullOrEmpty(textItem.ItemCode))
- {
- DataTable layoutItem = this.dgvText.DataSource as DataTable;
- DataRow drLayoutItem = layoutItem.NewRow();
- drLayoutItem["LayoutItemID"] = e.Item.ID;
- drLayoutItem["ItemCode"] = textItem.ItemCode;
- layoutItem.Rows.Add(drLayoutItem);
- }
- }
- else if (e.Item.ItemType == ItemType.TotalText)
- {
- TotalTextItem totalTextItem = e.Item as TotalTextItem;
- if (totalTextItem != null && !string.IsNullOrWhiteSpace(totalTextItem.ItemCode))
- {
- DataTable layoutItem = this.dgvText.DataSource as DataTable;
- DataRow drLayoutItem = layoutItem.NewRow();
- drLayoutItem["LayoutItemID"] = e.Item.ID;
- drLayoutItem["ItemCode"] = totalTextItem.ItemCode;
- layoutItem.Rows.Add(drLayoutItem);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 票据项目事件
- /// <summary>
- /// 文本项目DataGridView项目获得焦点事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvText_CellEnter(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
- {
- try
- {
- C_DataGridView dataGridView = sender as C_DataGridView;
- if (dataGridView != null && !dataGridView.Rows[dataGridView.CurrentCell.RowIndex].IsNewRow)
- {
- dataGridView.CurrentRow.ReadOnly = true;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 文本项目DataGridView项目选择内容之后事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvText_CellValueChanged(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
- {
- try
- {
- C_DataGridView dataGridView = sender as C_DataGridView;
- if (dataGridView == null || dataGridView.CurrentCell == null
- || !string.IsNullOrEmpty(dataGridView.Rows[dataGridView
- .CurrentCell.RowIndex].Cells["LayoutItemID"].Value + ""))
- {
- return;
- }
- if (!dataGridView.CurrentCell.ReadOnly)
- {
- ComboBox comboBox = dataGridView.EditingControl as ComboBox;
- if (comboBox == null || comboBox.SelectedIndex < 0)
- {
- return;
- }
- DataRowView dataRowView = (dataGridView.EditingControl as ComboBox).SelectedItem as DataRowView;
- // 当Item是金额时,使用金额TotalTextItem
- if (Convert.ToInt32(ItemStyle.TotalText) == System.Convert.ToInt32(dataRowView["ItemStyle"]))
- {
- TotalTextItem totalTextItem = this.lbxInvoice.NewItem(ItemType.TotalText, false) as TotalTextItem;
- if (totalTextItem != null)
- {
- totalTextItem.DataMember = dataRowView["ControlCode"].ToString();
- totalTextItem.DisplayValue = dataRowView["ItemSample"].ToString();
- totalTextItem.ItemCode = dataRowView["ItemCode"].ToString();
- totalTextItem.TextItemName = dataRowView["ItemName"].ToString();
- totalTextItem.ItemSample = dataRowView["ItemSample"].ToString();
- totalTextItem.ItemStyle = (ItemStyle)System.Convert.ToInt32(dataRowView["ItemStyle"]);
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["LayoutItemID"].Value = totalTextItem.ID;
- // 增加票据项目编码
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["ItemCode"].Value = dataRowView["ItemCode"].ToString();
- totalTextItem.ShowItemPropertyDialog();
- }
- else
- {
- dgvText.Rows.RemoveAt(e.RowIndex);
- }
- }
- // 当Item是线性图时 xuwei add 2024-04-12 ===========================================
- else if (Convert.ToInt32(ItemStyle.LinearGraph) == System.Convert.ToInt32(dataRowView["ItemStyle"]))
- {
- TextItem textItem = lbxInvoice.NewItem(ItemType.LinearGraph, false) as TextItem;
- if (textItem != null)
- {
- textItem.DataMember = dataRowView["ControlCode"].ToString();
- textItem.DisplayValue = dataRowView["ItemSample"].ToString();
- textItem.ItemCode = dataRowView["ItemCode"].ToString();
- textItem.TextItemName = dataRowView["ItemName"].ToString();
- textItem.ItemSample = dataRowView["ItemSample"].ToString();
- textItem.ItemStyle = (ItemStyle)System.Convert.ToInt32(dataRowView["ItemStyle"]);
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["LayoutItemID"].Value = textItem.ID;
- // 增加票据项目编码
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["ItemCode"].Value = dataRowView["ItemCode"].ToString();
- textItem.ShowItemPropertyDialog();
- }
- else
- {
- dgvText.Rows.RemoveAt(e.RowIndex);
- }
- }
- //xuwei end =============================================
- // 当Item是条形码时
- else if (Convert.ToInt32(ItemStyle.Barcode) == System.Convert.ToInt32(dataRowView["ItemStyle"]))
- {
- TextItem textItem = lbxInvoice.NewItem(ItemType.Barcode, false) as TextItem;
- if (textItem != null)
- {
- textItem.DataMember = dataRowView["ControlCode"].ToString();
- textItem.DisplayValue = dataRowView["ItemSample"].ToString();
- textItem.ItemCode = dataRowView["ItemCode"].ToString();
- textItem.TextItemName = dataRowView["ItemName"].ToString();
- textItem.ItemSample = dataRowView["ItemSample"].ToString();
- textItem.ItemStyle = (ItemStyle)System.Convert.ToInt32(dataRowView["ItemStyle"]);
- if (textItem.ItemCode == "ZWLJC")
- {
- textItem.BarcodeFormat = "EAN_13";
- }
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["LayoutItemID"].Value = textItem.ID;
- // 增加票据项目编码
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["ItemCode"].Value = dataRowView["ItemCode"].ToString();
- textItem.ShowItemPropertyDialog();
- }
- else
- {
- dgvText.Rows.RemoveAt(e.RowIndex);
- }
- }
- // 当Item是二维码时
- else if (Convert.ToInt32(ItemStyle.QRCode) == System.Convert.ToInt32(dataRowView["ItemStyle"]))
- {
- TextItem textItem = lbxInvoice.NewItem(ItemType.QRcode, false) as TextItem;
- if (textItem != null)
- {
- textItem.DataMember = dataRowView["ControlCode"].ToString();
- textItem.DisplayValue = dataRowView["ItemSample"].ToString();
- textItem.ItemCode = dataRowView["ItemCode"].ToString();
- textItem.TextItemName = dataRowView["ItemName"].ToString();
- textItem.ItemSample = dataRowView["ItemSample"].ToString();
- textItem.ItemStyle = (ItemStyle)System.Convert.ToInt32(dataRowView["ItemStyle"]);
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["LayoutItemID"].Value = textItem.ID;
- // 增加票据项目编码
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["ItemCode"].Value = dataRowView["ItemCode"].ToString();
- textItem.ShowItemPropertyDialog();
- }
- else
- {
- dgvText.Rows.RemoveAt(e.RowIndex);
- }
- }
- else
- {
- TextItem textItem = lbxInvoice.NewItem(ItemType.Text, false) as TextItem;
- if (textItem != null)
- {
- textItem.DataMember = dataRowView["ControlCode"].ToString();
- textItem.DisplayValue = dataRowView["ItemSample"].ToString();
- textItem.ItemCode = dataRowView["ItemCode"].ToString();
- textItem.TextItemName = dataRowView["ItemName"].ToString();
- textItem.ItemSample = dataRowView["ItemSample"].ToString();
- textItem.ItemStyle = (ItemStyle)System.Convert.ToInt32(dataRowView["ItemStyle"]);
- if (textItem.ItemStyle == ItemStyle.Date)
- {
- textItem.Format = "yyyy-MM-dd";
- textItem.Culture = "en-US";
- }
- else if (textItem.ItemStyle == ItemStyle.Sign)
- {
- textItem.Format = "√";
- }
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["LayoutItemID"].Value = textItem.ID;
- // 增加票据项目编码
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["ItemCode"].Value = dataRowView["ItemCode"].ToString();
- textItem.ShowItemPropertyDialog();
- }
- else
- {
- dgvText.Rows.RemoveAt(e.RowIndex);
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 改变文本grid选择状态
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvText_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this._layoutSelectionChanging || this.lbxInvoice.ItemSelectionChanging)
- {
- return;
- }
- this._layoutSelectionChanging = true;
- // 取消选择
- if (this.dgvText.SelectedRows.Count == 0
- || (this.dgvText.SelectedRows.Count == 1
- && this.dgvText.SelectedRows[0].IsNewRow))
- {
- this.lbxInvoice.ClearSelection();
- this._layoutSelectionChanging = false;
- return;
- }
- foreach (DataGridViewRow row in dgvText.SelectedRows)
- {
- if (!row.IsNewRow)
- {
- int itemID = System.Convert.ToInt32(row.Cells["LayoutItemID"].Value);
- if (0 < itemID)
- {
- LayoutItem layoutItem = this.lbxInvoice.GetItem(itemID);
- if (layoutItem != null)
- {
- this.lbxInvoice.SelectItemSingle(layoutItem, row.Selected);
- }
- }
- }
- }
- this._layoutSelectionChanging = false;
- }
- catch (Exception ex)
- {
- this._layoutSelectionChanging = false;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 删除文本grid中的一行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvText_UserDeletingRow(object sender, System.Windows.Forms.DataGridViewRowCancelEventArgs e)
- {
- try
- {
- C_DataGridView dataGridView = sender as C_DataGridView;
- int itemID = System.Convert.ToInt32(e.Row.Cells["LayoutItemID"].Value);
- DataRowView dataRowView = e.Row.DataBoundItem as DataRowView;
- if (0 < itemID)
- {
- if (4 == System.Convert.ToInt32(dataRowView["ItemStyle"]))
- {
- TotalTextItem totalTextItem = this.lbxInvoice.GetItem(itemID) as TotalTextItem;
- this.lbxInvoice.DeletetItem(totalTextItem);
- }
- else
- {
- TextItem textItem = this.lbxInvoice.GetItem(itemID) as TextItem;
- this.lbxInvoice.DeletetItem(textItem);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 列表DataGridView项目选择内容之后事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvDetail == null || this.dgvDetail.CurrentCell == null
- || !string.IsNullOrEmpty(this.dgvDetail.Rows[this.dgvDetail
- .CurrentCell.RowIndex].Cells["LayoutGridItemID"].Value + ""))
- {
- return;
- }
- TextItem textItem = lbxInvoice.NewItem(ItemType.Text, false) as TextItem;
- if (textItem != null)
- {
- DataRowView dataRowView = (this.dgvDetail.EditingControl as ComboBox).SelectedItem as DataRowView;
- this.dgvDetail.Rows[this.dgvDetail.CurrentCell.RowIndex].Cells["LayoutGridItemID"].Value = textItem.ID;
- // 增加票据项目编码
- this.dgvDetail.Rows[this.dgvDetail.CurrentCell.RowIndex].Cells["ItemCodeDetail"].Value
- = dataRowView["ItemCode"].ToString();
- }
- else
- {
- dgvText.Rows.RemoveAt(e.RowIndex);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 列表项目DataGridView项目获得焦点事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_CellEnter(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
- {
- try
- {
- C_DataGridView dataGridView = sender as C_DataGridView;
- if (dataGridView != null && !dataGridView.Rows[dataGridView.CurrentCell.RowIndex].IsNewRow)
- {
- dataGridView.CurrentRow.ReadOnly = true;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 列表项目DataGridView项目选择内容之后事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_CellValidated(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
- {
- try
- {
- // 取得当前DataGridView的当前单元格
- C_DataGridView dataGridView = sender as C_DataGridView;
- // 当前单元格是新建单元格
- if (!dataGridView.CurrentCell.ReadOnly)
- {
- ComboBox comboBox = dataGridView.EditingControl as ComboBox;
- if (comboBox == null || comboBox.SelectedIndex < 0)
- {
- return;
- }
- // 取得当前行的信息
- DataRowView dataRowView = (dataGridView.EditingControl as ComboBox).SelectedItem as DataRowView;
- Dongke.WinForm.Controls.InvoiceLayout.GridItem gridItem = this.lbxInvoice.OneGridItem;
- // 如果当前选中的项目中没有Grid,则自动生成一个新的Grid
- if (gridItem == null)
- {
- gridItem = this.lbxInvoice.NewItem(ItemType.Grid, false) as Dongke.WinForm.Controls.InvoiceLayout.GridItem;
- }
- // 生成新的Grid之后,赋值,在票据控件上显示
- if (gridItem != null)
- {
- GridItemColumn gridItemColumn
- = new GridItemColumn(gridItem.Columns.GeNewColumnName(), dataRowView["ItemName"].ToString());
- gridItemColumn.DataPropertyName = dataRowView["ControlCode"].ToString();
- gridItemColumn.DisplayValue = dataRowView["ItemSample"].ToString();
- gridItemColumn.ItemStyle = (ItemStyle)System.Convert.ToInt32(dataRowView["ItemStyle"]);
- if (gridItemColumn.ItemStyle == ItemStyle.Date)
- {
- gridItemColumn.Format = "yyyy/MM/dd";
- gridItemColumn.Culture = "en-US";
- }
- else if (gridItemColumn.ItemStyle == ItemStyle.Sign)
- {
- gridItemColumn.Format = "√";
- }
- else if (gridItemColumn.ItemStyle == ItemStyle.Barcode)
- {
- gridItemColumn.PicColumn = true;
- }
- gridItem.Columns.Add(gridItemColumn);
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["LayoutGridItemID"].Value = gridItemColumn.ID;
- this.lbxInvoice.Refresh();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 改变列表grid选择状态
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this._layoutSelectionChanging || this.lbxInvoice.ItemSelectionChanging)
- {
- return;
- }
- this._layoutSelectionChanging = true;
- // 取消选择
- if (this.dgvDetail.SelectedRows.Count == 0 || this.lbxInvoice.OneGridItem == null)
- {
- this.lbxInvoice.ClearSelection();
- this._layoutSelectionChanging = false;
- return;
- }
- this.lbxInvoice.SelectItemSingle(this.lbxInvoice.OneGridItem, true);
- this._layoutSelectionChanging = false;
- }
- catch (Exception ex)
- {
- this._layoutSelectionChanging = false;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 删除列表grid中的一行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_UserDeletingRow(object sender, System.Windows.Forms.DataGridViewRowCancelEventArgs e)
- {
- try
- {
- if (this.lbxInvoice.OneGridItem == null)
- {
- return;
- }
- int itemID = System.Convert.ToInt32(e.Row.Cells["LayoutGridItemID"].Value);
- if (0 < itemID)
- {
- this.lbxInvoice.OneGridItem.Columns.RemoveAtByID(itemID);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 初始化LayoutBox样式及数据
- /// </summary>
- private void InitLayoutBoxStyle()
- {
- // 编辑的状况下加载票据格式数据
- if (this._invoiceLayoutID == 0)
- {
- this.lbxInvoice.SetPaperAreaSize(_paperWidth, _paperHeight);
- }
- this.txtInvoiceSize.Text = string.Format("{0:0}mm×{1:0}mm",
- lbxInvoice.PaperWidth,
- lbxInvoice.PaperHeight);
- }
- /// <summary>
- /// 只有当票据选择了一个以上的项目该功能才可用
- /// </summary>
- /// <param name="status">可用/不可用</param>
- private void SetLayoutBoxFunctionButtonStatus()
- {
- // 复制、剪切、删除
- this.tsmiCut.Enabled = (this.lbxInvoice.SelectedItems.Count > 0);
- this.tsmiCopy.Enabled = this.tsmiCut.Enabled;
- this.tsmiDelete.Enabled = this.tsmiCut.Enabled;
- this.tsbtnCut.Enabled = this.tsmiCut.Enabled;
- this.tsbtnCopy.Enabled = this.tsmiCut.Enabled;
- this.tsbtnDelete.Enabled = this.tsmiCut.Enabled;
- // 详细或者移动
- this.tsmiDetail.Enabled = (this.lbxInvoice.SelectedItems.Count == 1);
- this.tsbtnDetail.Enabled = this.tsmiDetail.Enabled;
- this.tsmiFrontMost.Enabled = this.tsmiDetail.Enabled;
- this.tsmiFront.Enabled = this.tsmiDetail.Enabled;
- this.tsmiBack.Enabled = this.tsmiDetail.Enabled;
- this.tsmiBackMost.Enabled = this.tsmiDetail.Enabled;
- this.tsbtnMoveTop.Enabled = this.tsmiDetail.Enabled;
- this.tsbtnMoveFront.Enabled = this.tsmiDetail.Enabled;
- this.tsbtnMoveUnder.Enabled = this.tsmiDetail.Enabled;
- this.tsbtnMoveBottom.Enabled = this.tsmiDetail.Enabled;
- // 对齐按钮或者菜单
- this.tsbtnAlignmentLeft.Enabled = (this.lbxInvoice.SelectedItems.Count > 1);
- this.tsbtnAlignmentLeft.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsbtnAlignmentCenter.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsbtnAlignmentRight.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsbtnAlignmentTop.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsbtnAlignmentMiddle.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsbtnAlignmentBottom.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsmiAlignmentLeft.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsmiAlignmentCenter.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsmiAlignmentRight.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsmiAlignmentTop.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsmiAlignmentMiddle.Enabled = this.tsbtnAlignmentLeft.Enabled;
- this.tsmiAlignmentBottom.Enabled = this.tsbtnAlignmentLeft.Enabled;
- // 粘贴按钮或者菜单
- this.tsmiPaste.Enabled = Clipboard.ContainsData(this.lbxInvoice.ClipboardFormat.Name);
- this.tsbtnPaste.Enabled = Clipboard.ContainsData(this.lbxInvoice.ClipboardFormat.Name);
- }
- /// <summary>
- /// 为票据设定的项目列表赋值
- /// </summary>
- private void SetLayoutGridDataSource()
- {
- try
- {
- ServiceResultEntity sre = GetInvoiceData();
- DataSet LayoutDataSet = sre.Data;
- if (LayoutDataSet != null && LayoutDataSet.Tables.Count > 1)
- {
- _invoiceLayoutDataTable = LayoutDataSet.Tables[0];
- //DataTable tempTable = LayoutDataSet.Tables[1].Clone();
- //DataTable tempDetailTable = LayoutDataSet.Tables[1].Clone();
- //// 文本数据赋值
- //DataRow[] invoiceItemRow = LayoutDataSet.Tables[1].Copy().Select("ItemType = 0");
- //for (int i = 0; i < invoiceItemRow.Length; i++)
- //{
- // tempTable.ImportRow(invoiceItemRow[i]);
- //}
- this.dgvText.DataSource = LayoutDataSet.Tables[1];
- //// 列表项目赋值
- //invoiceItemRow = LayoutDataSet.Tables[1].Copy().Select("ItemType = 1");
- //for (int i = 0; i < invoiceItemRow.Length; i++)
- //{
- // tempDetailTable.ImportRow(invoiceItemRow[i]);
- //}
- //this.dgvDetail.DataSource = tempDetailTable;
- // 编辑的状况下加载票据格式数据
- if (this._invoiceLayoutID != 0)
- {
- if (1 == LayoutDataSet.Tables[0].Rows.Count)
- {
- this.txtGoodsType.Text = LayoutDataSet.Tables[0].Rows[0]["goodstypename"].ToString() + "【" + LayoutDataSet.Tables[0].Rows[0]["goodstypecode"].ToString() + "】";
- this.txtInvoiceName.Text = LayoutDataSet.Tables[0].Rows[0]["LayoutName"].ToString();
- this.Text = string.Format(F_MST_012001.TITLE_F_MST_012002_EDIT, this.txtInvoiceName.Text.Trim());
- this.txtRemarks.Text = LayoutDataSet.Tables[0].Rows[0]["Remarks"].ToString();
- this.txtLogo.Text = LayoutDataSet.Tables[0].Rows[0]["LogoName"].ToString();
- this._goodstypeid = Convert.ToInt32(LayoutDataSet.Tables[0].Rows[0]["goodstypeid"]);
- this._goodstypeCode = LayoutDataSet.Tables[0].Rows[0]["goodstypecode"].ToString();
- this._goodstypeName = LayoutDataSet.Tables[0].Rows[0]["goodstypename"].ToString();
- object objLogoID = LayoutDataSet.Tables[0].Rows[0]["logoid"];
- if (objLogoID != null && objLogoID != DBNull.Value)
- {
- this._logoid = Convert.ToInt32(objLogoID);
- }
- else
- {
- this._logoid = null;
- }
- byte[] bytes = LayoutDataSet.Tables[0].Rows[0]["LayoutData"] as byte[];
- if (bytes != null)
- {
- this.lbxInvoice.ReadLayout(bytes);
- }
- }
- this.tsbtnSaveAs.Enabled = true;
- this.tsmiSaveAs.Enabled = true;
- }
- else
- {
- this.tsbtnSaveAs.Enabled = false;
- this.tsmiSaveAs.Enabled = false;
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 设定保存票据主信息的DataTable
- /// </summary>
- /// <param name="saveDataSet"></param>
- private void SetSaveLayoutData(ref DataSet saveDataSet, int layoutID)
- {
- try
- {
- DataTable layout = _invoiceLayoutDataTable.Copy();
- byte[] bytes = this.lbxInvoice.WriteLayout();
- if (0 < layoutID)
- {
- if (layout != null && layout.Rows.Count > 0)
- {
- // 新建后转成编辑模式,但是数据源中无id
- layout.Rows[0]["layoutid"] = layoutID;
- if (bytes != null)
- {
- layout.Rows[0]["LayoutData"] = bytes;
- }
- layout.Rows[0]["Width"] = lbxInvoice.PaperWidth;
- layout.Rows[0]["Height"] = lbxInvoice.PaperHeight;
- }
- }
- else
- {
- DataRow tempDataRow = layout.NewRow();
- tempDataRow["layoutid"] = 0;
- tempDataRow["LayoutName"] = this.txtInvoiceName.Text.Trim();
- if (bytes != null)
- {
- tempDataRow["LayoutData"] = bytes;
- }
- tempDataRow["logoid"] = (this._logoid.HasValue ? (object)this._logoid.Value : DBNull.Value);
- tempDataRow["goodstypeid"] = this._goodstypeid;
- tempDataRow["goodstypecode"] = this._goodstypeCode;
- tempDataRow["goodstypename"] = this._goodstypeName;
- tempDataRow["Width"] = lbxInvoice.PaperWidth;
- tempDataRow["Height"] = lbxInvoice.PaperHeight;
- tempDataRow["Remarks"] = this.txtRemarks.Text.Trim();
- //xuwei add 2019-11-20
- tempDataRow["PrintType"] = this._printType;
- layout.Rows.Clear();
- layout.Rows.Add(tempDataRow);
- }
- saveDataSet.Tables.Add(layout);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 另存为时,设定保存票据主信息的DataTable
- /// </summary>
- /// <param name="saveDataSet"></param>
- private void SetSaveAsLayoutData(ref DataSet saveDataSet, int layoutID)
- {
- try
- {
- byte[] bytes = this.lbxInvoice.WriteLayout();
- _invoiceLayoutDataTable.Rows[0]["InvoiceLayoutName"] = this.txtInvoiceName.Text.Trim();
- if (bytes != null)
- {
- _invoiceLayoutDataTable.Rows[0]["InvoiceLayoutData"] = bytes;
- }
- //_invoiceLayoutDataTable.Rows[0]["InvoiceCode"] = this.cbxInvoiceType.SelectedValue;
- //_invoiceLayoutDataTable.Rows[0]["OrganizationID"] = this.sbxOrganization.SearchedValue;
- //_invoiceLayoutDataTable.Rows[0]["OrganizationCode"] = this.OrganizationCode;
- //_invoiceLayoutDataTable.Rows[0]["OrganizationName"] = this.sbxOrganization.Text;
- //_invoiceLayoutDataTable.Rows[0]["Width"] = lbxInvoice.PaperWidth;
- //_invoiceLayoutDataTable.Rows[0]["Height"] = lbxInvoice.PaperHeight;
- saveDataSet.Tables.Add(_invoiceLayoutDataTable.Copy());
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 设定保存票据项目的DataTable
- /// </summary>
- /// <param name="saveDataSet"></param>
- private void SetSaveLayoutItemData(ref DataSet saveDataSet)
- {
- try
- {
- DataTable textDataTable = (DataTable)this.dgvText.DataSource;
- //DataTable itemDataTable = (DataTable)this.dgvDetail.DataSource;
- //DataTable tempDataTable = textDataTable.Clone();
- //for (int i = 0; i < textDataTable.Rows.Count; i++)
- //{
- // if (textDataTable.Rows[i].RowState == DataRowState.Deleted
- // || textDataTable.Rows[i].RowState == DataRowState.Detached)
- // {
- // continue;
- // }
- // textDataTable.Rows[i]["ItemType"] = 0;
- //}
- //for (int i = 0; i < itemDataTable.Rows.Count; i++)
- //{
- // if (itemDataTable.Rows[i].RowState == DataRowState.Deleted
- // || itemDataTable.Rows[i].RowState == DataRowState.Detached)
- // {
- // continue;
- // }
- // itemDataTable.Rows[i]["ItemType"] = 1;
- //}
- //DataRow[] invoiceItemRow = textDataTable.Copy().Select("ItemType = 0");
- //for (int i = 0; i < invoiceItemRow.Length; i++)
- //{
- // tempDataTable.ImportRow(invoiceItemRow[i]);
- //}
- //invoiceItemRow = itemDataTable.Copy().Select("ItemType = 1");
- //for (int i = 0; i < invoiceItemRow.Length; i++)
- //{
- // tempDataTable.ImportRow(invoiceItemRow[i]);
- //}
- saveDataSet.Tables.Add(textDataTable.Copy());
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 根据票据格式ID取得票据数据及票据项目数据
- /// </summary>
- /// <returns></returns>
- private ServiceResultEntity GetInvoiceData()
- {
- try
- {
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "InvoiceLayout";
- this._clientRequestEntity.Name = "GetBarCodePrintLayout";
- this._clientRequestEntity.Properties["LayoutID"] = _invoiceLayoutID;
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 保存新建票据数据
- /// </summary>
- /// <returns>
- /// 0:保存失败
- /// 其他:保存成功返回新建票据ID
- /// </returns>
- private ServiceResultEntity SaveAddLayoutData()
- {
- try
- {
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "InvoiceLayout";
- this._clientRequestEntity.Name = "SaveAddBarCodePrintLayoutData";
- this._clientRequestEntity.Data = _saveData;
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 保存编辑票据数据
- /// </summary>
- /// <returns>更新数据时影响的行数</returns>
- private ServiceResultEntity SaveEditLayoutData()
- {
- try
- {
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "InvoiceLayout";
- this._clientRequestEntity.Name = "SaveEditBarCodePrintLayoutData";
- this._clientRequestEntity.Data = _saveData;
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- private void tsmiBarcode_Click(object sender, EventArgs e)
- {
- try
- {
- TextItem newTextItem = this.lbxInvoice.NewItem(ItemType.Barcode, true) as TextItem;
- if (newTextItem != null)
- {
- newTextItem.DataMember = string.Empty;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void tsmiQRcode_Click(object sender, EventArgs e)
- {
- try
- {
- TextItem newTextItem = this.lbxInvoice.NewItem(ItemType.QRcode, true) as TextItem;
- if (newTextItem != null)
- {
- newTextItem.DataMember = string.Empty;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void F_MST_012003_Load(object sender, EventArgs e)
- {
- try
- {
- // 加载打印项目
- //controlDataSource = this.GetMSTSourse2().Data.Tables[0];
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "InvoiceLayout";
- cre.Name = "GetBarCodePrintItem";
- ServiceResultEntity sre = SystemModuleProxy.Service.DoBarCodePrint(cre);
- if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
- {
- this.InvoiceItemName.DataSource = sre.Data.Tables[0];
- this.InvoiceItemName.DisplayMember = "ItemName";
- this.InvoiceItemName.ValueMember = "ItemCode";
- }
- // 为票据设定的项目列表赋值
- this.dgvText.AutoGenerateColumns = false;
- this.dgvDetail.AutoGenerateColumns = false;
- this.SetLayoutGridDataSource();
- // LayoutBox赋值
- this.InitLayoutBoxStyle();
- // 设置票据功能按钮状态
- this.SetLayoutBoxFunctionButtonStatus();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void lbxInvoice_UserDeletedItem(object sender, WinForm.Controls.InvoiceLayout.ItemChangedEventArgs e)
- {
- try
- {
- if (e.Item.ItemType == ItemType.Text ||
- e.Item.ItemType == ItemType.Barcode ||
- e.Item.ItemType == ItemType.QRcode)
- {
- TextItem textItem = e.Item as TextItem;
- if (textItem != null
- && !string.IsNullOrEmpty(textItem.DataMember))
- {
- DataTable layoutItem = this.dgvText.DataSource as DataTable;
- DataRow[] drLayoutItems = layoutItem.Select("LayoutItemID = " + e.Item.ID);
- if (drLayoutItems != null && 0 < drLayoutItems.Length)
- {
- drLayoutItems[0].Delete();
- }
- }
- }
- else if (e.Item.ItemType == ItemType.TotalText)
- {
- TotalTextItem totalTextItem = e.Item as TotalTextItem;
- if (totalTextItem != null)
- {
- DataTable layoutItem = this.dgvText.DataSource as DataTable;
- DataRow[] drLayoutItems = layoutItem.Select("LayoutItemID = " + e.Item.ID);
- if (drLayoutItems != null && 0 < drLayoutItems.Length)
- {
- drLayoutItems[0].Delete();
- }
- }
- }
- else if (e.Item.ItemType == ItemType.Grid)
- {
- DataTable layoutItem = this.dgvDetail.DataSource as DataTable;
- DataRow[] drLayoutItems = layoutItem.Select();
- foreach (DataRow dr in drLayoutItems)
- {
- dr.Delete();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void tsbtnPrintPreview_Click(object sender, EventArgs e)
- {
- F_MST_012005 frm012005 = new F_MST_012005();
- frm012005.LayoutName = this.txtInvoiceName.Text;
- frm012005.PageSizeName = this.txtInvoiceSize.Text;
- frm012005.GoodsTypeName = this.txtGoodsType.Text;
- frm012005.Remarks = this.txtRemarks.Text;
- frm012005.LayoutData = this.lbxInvoice.WriteLayout();
- frm012005.LogoName = this.txtLogo.Text;
- frm012005.ShowDialog();
- }
- }
- }
|