| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_013002.cs
- * 2.功能描述:新票据信息操作
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2016/02/18 1.00 新建
- * 周兴 2016/03/11 1.00 编辑
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.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_013003 : 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; // 总单备注
- #endregion
- #region 属性
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_MST_013003(int? goodstypeID, string goodstypeCode, string goodstypeName, int? logoid, string logoname,
- float paperWidth, float paperHeight, string layoutName, string remarks)
- {
- InitializeComponent();
- this.Text = string.Format(F_MST_013001.TITLE_F_MST_013001_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;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_MST_013003(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_013001.TITLE_F_MST_013002_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_013004 frmINV0302 = new F_MST_013004();
- 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;
- 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;
- if (_goodstypeid.HasValue)
- {
- this.txtGoodsType.Text = _goodstypeName + "【" + _goodstypeCode + "】";
- }
- else
- {
- this.txtGoodsType.Text = null;
- }
- this._logoid = frmINV0302.LogoID;
- this.txtLogo.Text = frmINV0302.LogoName;
- _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_013001.TITLE_F_MST_013002_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)
- {
- object objgoodstypeid = LayoutDataSet.Tables[0].Rows[0]["goodstypeid"];
- if (objgoodstypeid != null && objgoodstypeid != DBNull.Value)
- {
- this._goodstypeid = Convert.ToInt32(objgoodstypeid);
- }
- else
- {
- this._goodstypeid = null;
- }
- //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();
- if (this._goodstypeid.HasValue)
- {
- this.txtGoodsType.Text = LayoutDataSet.Tables[0].Rows[0]["goodstypename"].ToString() + "【" + LayoutDataSet.Tables[0].Rows[0]["goodstypecode"].ToString() + "】";
- }
- else
- {
- this.txtGoodsType.Text = null;
- }
- this.txtInvoiceName.Text = LayoutDataSet.Tables[0].Rows[0]["LayoutName"].ToString();
- this.Text = string.Format(F_MST_013001.TITLE_F_MST_013002_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();
- //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.HasValue ? (object)this._goodstypeid.Value : DBNull.Value);
- tempDataRow["goodstypecode"] = this._goodstypeCode;
- tempDataRow["goodstypename"] = this._goodstypeName;
- tempDataRow["Width"] = lbxInvoice.PaperWidth;
- tempDataRow["Height"] = lbxInvoice.PaperHeight;
- tempDataRow["Remarks"] = this.txtRemarks.Text.Trim();
- 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 = "MouldLableLayout";
- this._clientRequestEntity.Name = "GetMouldLablePrintLayout";
- 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 = "MouldLableLayout";
- this._clientRequestEntity.Name = "SaveAddMouldLablePrintLayoutData";
- 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 = "MouldLableLayout";
- this._clientRequestEntity.Name = "SaveEditMouldLablePrintLayoutData";
- 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_013003_Load(object sender, EventArgs e)
- {
- try
- {
- // 加载打印项目
- //controlDataSource = this.GetMSTSourse2().Data.Tables[0];
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MouldLableLayout";
- cre.Name = "GetMouldLablePrintItem";
- 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_013005 frm012005 = new F_MST_013005();
- 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();
- }
- }
- }
|