| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156 |
- /*******************************************************************************
- * 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是条形码时
- 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"]);
- 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();
- }
- }
- }
|