687 lines
28 KiB
C#
687 lines
28 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Configuration;
|
||
using System.Data;
|
||
using System.Text;
|
||
using System.Drawing;
|
||
using System.Drawing.Printing;
|
||
using System.Windows.Forms;
|
||
using SuperMap.RealEstate.CoreFrameWork;
|
||
using SuperMap.RealEstate.ServiceModel;
|
||
using SuperMap.RealEstate.HighWay.Storage.Business;
|
||
|
||
namespace SuperMap.RealEstate.HighWay.PrintGoods
|
||
{
|
||
public partial class frmPrintMain : Windows.Forms.FormBase
|
||
{
|
||
/// <summary>
|
||
/// 存储坐标偏移量
|
||
/// </summary>
|
||
private int offsetX = 0;
|
||
private int offsetY = 0;
|
||
private string ServerPart_ID = "";
|
||
private int SelectNum = 0;
|
||
private int printcount = 1;
|
||
private string Commodity_id = "";
|
||
//private HighWay.Running.Business.HIGHWAYPROINST _HighWayProinst = null;
|
||
protected string _BUSINESSTYPE = ConfigurationManager.AppSettings["BUSINESSTYPE"].ToString();
|
||
|
||
string frmUserName = string.Empty;
|
||
//string UserNameID = string.Empty;
|
||
/// <summary>
|
||
/// 这里数据查询时就缓存房屋数据,来避免每次选择一个房屋后去数据查询数据。
|
||
/// </summary>
|
||
private List<COMMODITY> _TempCommodityInfoCollection = new List<COMMODITY>();
|
||
|
||
/// <summary>
|
||
/// 缓存选中的节点数据,待更改
|
||
/// </summary>
|
||
private List<COMMODITY> _TempPrintCommodityCollection = new List<COMMODITY>();
|
||
|
||
public frmPrintMain()
|
||
//HighWay.Running.Business.HIGHWAYPROINST _HIGHWAYPROINST = null
|
||
//string ModuleGuid, string UserName = "", : base(ModuleGuid, UserName, Password)
|
||
{
|
||
//_HighWayProinst = new Running.Business.HIGHWAYPROINST(this.Transaction);
|
||
foreach (SERVERPART _SERVERPART in new SERVERPART(Transaction).FillCollection("where SERVERPART_NAME IN (" +
|
||
System.Configuration.ConfigurationManager.AppSettings["SERVERPART_NAME"].ToString() + ") ORDER BY SERVERPART_CODE"))
|
||
{
|
||
ServerPart_ID += ServerPart_ID == "" ? _SERVERPART.SERVERPART_ID.ToString() : "," + _SERVERPART.SERVERPART_ID;
|
||
}
|
||
InitializeComponent();
|
||
//frmUserName = UserName;
|
||
//UserNameID = _UserNameID;
|
||
this.StartPosition = FormStartPosition.CenterScreen;
|
||
}
|
||
|
||
private void frmPrintMain_Load(object sender, EventArgs e)
|
||
{
|
||
txtSearch.Text = "";
|
||
SetControlLocation();
|
||
SetOffsetToControl();
|
||
InitInvoiceControlValue();
|
||
TreeViewBinding();
|
||
}
|
||
|
||
#region 方法 -> 选择商品列表
|
||
private void BtnSelect_Click(object sender, EventArgs e)
|
||
{
|
||
foreach (TreeNode treeNode in CommodityList.Nodes)
|
||
{
|
||
if (treeNode.Checked && Commodity_id.IndexOf("," + treeNode.Tag.ToString() + ",") < 0)
|
||
{
|
||
Commodity_id += Commodity_id == "" ? treeNode.Tag.ToString() : "," + treeNode.Tag.ToString();
|
||
}
|
||
}
|
||
treeView1Binding();
|
||
}
|
||
|
||
private void BtnReset_Click(object sender, EventArgs e)
|
||
{
|
||
Commodity_id = "0";
|
||
treeView1Binding();
|
||
}
|
||
#endregion
|
||
|
||
#region TreeViewBinding
|
||
private void treeView1Binding()
|
||
{
|
||
treeView1.Nodes.Clear();
|
||
//DataTable dt = _HighWayProinst.ExecuteDataTable(
|
||
// "SELECT * FROM HIGHWAY_STORAGE.T_COMMODITY WHERE COMMODITY_ID in (" + Commodity_id + ")");
|
||
foreach (COMMODITY _COMMODITY in new COMMODITY(Transaction).FillCollection(
|
||
"WHERE COMMODITY_ID in (" + Commodity_id + ")"))//DataRow dataRow in dt.Rows)
|
||
{
|
||
TreeNode treeNode = new TreeNode();
|
||
treeNode.Text = _COMMODITY.COMMODITY_NAME + "【" + _COMMODITY.COMMODITY_BARCODE + "】";
|
||
treeNode.Tag = _COMMODITY.COMMODITY_ID.ToString();
|
||
treeNode.Name = "COMMODITY";
|
||
treeNode.Checked = true;
|
||
treeView1.Nodes.Add(treeNode);
|
||
treeView1.ExpandAll();
|
||
}
|
||
}
|
||
|
||
private void TreeViewBinding()
|
||
{
|
||
COMMODITYTYPE _COMMODITYTYPE = new Storage.Business.COMMODITYTYPE(this.Transaction);
|
||
CommodityList.Nodes.Clear();
|
||
BindingTreeView("-1", this.CommodityList.Nodes, this.txtSearch.Text.Trim() + "$" + BarCode.Text.Trim(), ServerPart_ID);
|
||
}
|
||
|
||
#region BindingTreeView
|
||
public void BindingTreeView(string pid, TreeNodeCollection nodes, string obscureName, string _ServerPart_ID)
|
||
{
|
||
if (_ServerPart_ID == "")
|
||
{
|
||
return;
|
||
}
|
||
DataTable bindingDataSource = this.GetBindingDataSource(pid, obscureName, _ServerPart_ID);
|
||
foreach (DataRow dataRow in bindingDataSource.Rows)
|
||
{
|
||
TreeNode treeNode = new TreeNode();
|
||
treeNode.Text = dataRow["COMMODITY_NAME"].ToString() + "【" + dataRow["COMMODITY_BARCODE"].ToString() + "】";
|
||
treeNode.Tag = dataRow["COMMODITY_ID"].ToString();
|
||
treeNode.Name = "COMMODITY";
|
||
|
||
nodes.Add(treeNode);
|
||
//treeNode.PopulateOnDemand = true;
|
||
//this.BindingTreeView(dataRow["COMMODITY_TYPE"].ToString(), treeNode.Nodes, obscureName, _ServerPart_ID);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region GetBindingDataSource
|
||
public DataTable GetBindingDataSource(string pid, string ServerPart_ID)
|
||
{
|
||
return this.GetBindingDataSource(pid, string.Empty, ServerPart_ID);
|
||
}
|
||
|
||
public DataTable GetBindingDataSource(string pid, string obscureName, string ServerPart_ID)
|
||
{
|
||
string arg2 = string.Empty;
|
||
arg2 = string.IsNullOrEmpty(obscureName.Split('$')[0]) ? "" :
|
||
("and COMMODITY_NAME like '%" + obscureName.Split('$')[0] + "%'");
|
||
arg2 += string.IsNullOrEmpty(obscureName.Split('$')[1]) ? "" :
|
||
("and COMMODITY_BARCODE like '%" + obscureName.Split('$')[1] + "%'");
|
||
|
||
return new COMMODITY(Transaction).ExecuteDataTable(@"SELECT * FROM HIGHWAY_STORAGE.T_COMMODITY
|
||
WHERE COMMODITY_STATE = 1 AND BUSINESSTYPE IN (" + _BUSINESSTYPE + ") AND SERVERPART_ID IN (" + ServerPart_ID + ")" +
|
||
(arg2 == "" ? " AND 1 != 1" : arg2) + " order by COMMODITY_CODE,COMMODITY_TYPE,COMMODITY_NAME");
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region btnSearch_Click 查询
|
||
private void btnSearch_Click(object sender, EventArgs e)
|
||
{
|
||
InitInvoiceControlValue();
|
||
|
||
try
|
||
{
|
||
TreeViewBinding();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex.Message);
|
||
}
|
||
finally
|
||
{
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region btnPrint_Click 打印
|
||
private void btnPrint_Click(object sender, EventArgs e)
|
||
{
|
||
InitCommodityCollection();
|
||
string billOffset = PrintHelper.GetRegistData("BillOffset");
|
||
offsetX = Int32.Parse(billOffset.Split(',')[0]);
|
||
offsetY = Int32.Parse(billOffset.Split(',')[1]);
|
||
|
||
PageSetupDialog pageSetupDialog1 = new PageSetupDialog();
|
||
//创建打印文档
|
||
PrintDocument printDocument1 = new PrintDocument();
|
||
//开始打印的时候
|
||
printDocument1.BeginPrint += new PrintEventHandler(printDocument1_BeginPrint);
|
||
//输送打印数据
|
||
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
|
||
//打印结束的时候
|
||
printDocument1.EndPrint += new PrintEventHandler(printDocument1_EndPrint);
|
||
//将打印文档赋给打印组件
|
||
pageSetupDialog1.Document = printDocument1;
|
||
//纸张及页边距设置
|
||
pageSetupDialog1.PageSettings.Margins = new Margins(0, 0, 0, 0);
|
||
if (DialogResult.OK == pageSetupDialog1.ShowDialog())
|
||
{
|
||
printDocument1.Print();
|
||
}
|
||
printDocument1.Dispose();
|
||
//打印完毕后记得清空临时数据,释放内存,不管别的地方有没有清
|
||
_TempPrintCommodityCollection.Clear();
|
||
}
|
||
#endregion
|
||
|
||
#region InitCommodityCollection 获取选中商品信息集合
|
||
/// <summary>
|
||
/// 获取打印对象,房屋信息集合
|
||
/// </summary>
|
||
private void InitCommodityCollection()
|
||
{
|
||
_TempPrintCommodityCollection.Clear();
|
||
//事务
|
||
ServiceModel.Transaction _Transaction = new Transaction();
|
||
|
||
StringBuilder _StringBuilder = new StringBuilder();
|
||
foreach (TreeNode treeNode in treeView1.Nodes)
|
||
{
|
||
if (treeNode.Checked && treeNode.Name == "COMMODITY")
|
||
{
|
||
_StringBuilder.Append("," + treeNode.Tag.ToString());
|
||
}
|
||
_StringBuilder = GetCommodityId(treeNode.Nodes, _StringBuilder);
|
||
}
|
||
if (_StringBuilder.Length > 0)
|
||
_StringBuilder.Remove(0, 1);
|
||
if (_StringBuilder.Length == 0)
|
||
{
|
||
//MessageBox.Show("没有选择要打印的户室信息,请选择要打印的户室信息!", "系统操作提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||
return;
|
||
}
|
||
foreach (COMMODITY _House in new COMMODITY(_Transaction).FillCollection(
|
||
" where COMMODITY_ID in ( " + _StringBuilder.ToString() + " )"))
|
||
{
|
||
_TempPrintCommodityCollection.Add(_House);
|
||
}
|
||
}
|
||
|
||
private StringBuilder GetCommodityId(TreeNodeCollection nodes, StringBuilder _StringBuilder)
|
||
{
|
||
foreach (TreeNode treeNode in nodes)
|
||
{
|
||
if (treeNode.Checked && treeNode.Name == "COMMODITY")
|
||
{
|
||
_StringBuilder.Append("," + treeNode.Tag.ToString());
|
||
}
|
||
_StringBuilder = GetCommodityId(treeNode.Nodes, _StringBuilder);
|
||
}
|
||
return _StringBuilder;
|
||
}
|
||
#endregion
|
||
|
||
#region 打印事件__开始-->打印-->结束
|
||
/// <summary>
|
||
/// 开始打印的时候
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
public void printDocument1_BeginPrint(object sender, PrintEventArgs e)
|
||
{
|
||
///--------------这里也不要随便改,这里只管把预先准备好的数据丢进去-----------------///
|
||
//获取选中房屋集合
|
||
InitCommodityCollection();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打印事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
public void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
|
||
{
|
||
int ShowCount = _TempPrintCommodityCollection.Count * int.Parse(PrintCount.Text) - (printcount - 1);
|
||
//初始化打印控件
|
||
InitInvoiceControlValue();
|
||
/**先把数据送给界面上的控件,来精确定位数据动态,这里在每循环完一次后,要跳出一次循环,
|
||
* 并且移除当前循环到的对象数据,让下面的e.HasMorePages = true;来触发下次循环**/
|
||
if (_TempPrintCommodityCollection.Count > 0)
|
||
{
|
||
if (ShowCount > 12)
|
||
ShowCount = 12;
|
||
for (int CurrentNum = 0; CurrentNum < ShowCount; CurrentNum++)
|
||
{
|
||
//财政票据
|
||
InitInvoiceControlValue(_TempPrintCommodityCollection[0], CurrentNum);
|
||
//移除本次,循环数据
|
||
if (PrintCount.Text == printcount.ToString())
|
||
{
|
||
_TempPrintCommodityCollection.RemoveAt(0);
|
||
printcount = 1;
|
||
}
|
||
else
|
||
printcount++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
//得到打印界面所有控件数据
|
||
Control.ControlCollection ControlColl = null;
|
||
ControlColl = panel3.Controls;
|
||
//当第二次加载的数据的时候,要把第一调用的画布,清除一遍,记得这是很重要的一句话!
|
||
e.Graphics.Clear(Color.White);
|
||
///
|
||
Brush brush = null;
|
||
//这里的循环结束一次,才表示一张票据的数据输送完毕
|
||
for (int i = 0; i < ControlColl.Count; i++)
|
||
{
|
||
try
|
||
{
|
||
ShowCount = int.Parse(ControlColl[i].Name.Substring(ControlColl[i].Name.Length - 2));
|
||
}
|
||
catch
|
||
{
|
||
ShowCount = int.Parse(ControlColl[i].Name.Substring(ControlColl[i].Name.Length - 1));
|
||
}
|
||
brush = new SolidBrush(Color.Black);
|
||
e.Graphics.DrawString(ControlColl[i].Text, ControlColl[i].Font, brush, new PointF(ControlColl[i].Location.X + offsetX,
|
||
ControlColl[i].Location.Y + offsetY + int.Parse(PrintHelper.GetRegistData("BillOffset").Split(',')[(ShowCount + 2) / 2])));
|
||
}
|
||
//e.Graphics.DrawImage(Barcode.Image, new PointF(Barcode.Location.X + offsetX, Barcode.Location.Y + offsetY));
|
||
//分页,分页数=选中节点数 HasMorePages 用来设置自动触发打印事件
|
||
if (_TempPrintCommodityCollection.Count == 0)
|
||
{
|
||
e.HasMorePages = false;
|
||
}
|
||
else
|
||
{
|
||
e.HasMorePages = true;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打印结束的时候
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
public void printDocument1_EndPrint(object sender, PrintEventArgs e)
|
||
{
|
||
_TempPrintCommodityCollection.Clear();
|
||
}
|
||
#endregion
|
||
|
||
#region InitInvoiceControlValue 商品标价签==》初始化 || 赋值
|
||
|
||
#region 初始化
|
||
/// <summary>
|
||
/// 票据内容---》初始化
|
||
/// </summary>
|
||
private void InitInvoiceControlValue()
|
||
{
|
||
//第一组
|
||
COMMODITY_NAME0.Text = "";
|
||
COMMODITY_ORI0.Text = "";
|
||
COMMODITY_UNIT0.Text = "";
|
||
COMMODITY_RULE0.Text = "";
|
||
COMMODITY_RETAILPRICE0.Text = "";
|
||
COMMODITY_GRADE0.Text = "";
|
||
//第二组
|
||
COMMODITY_NAME1.Text = "";
|
||
COMMODITY_ORI1.Text = "";
|
||
COMMODITY_UNIT1.Text = "";
|
||
COMMODITY_RULE1.Text = "";
|
||
COMMODITY_RETAILPRICE1.Text = "";
|
||
COMMODITY_GRADE1.Text = "";
|
||
//第三组
|
||
COMMODITY_NAME2.Text = "";
|
||
COMMODITY_ORI2.Text = "";
|
||
COMMODITY_UNIT2.Text = "";
|
||
COMMODITY_RULE2.Text = "";
|
||
COMMODITY_RETAILPRICE2.Text = "";
|
||
COMMODITY_GRADE2.Text = "";
|
||
//第四组
|
||
COMMODITY_NAME3.Text = "";
|
||
COMMODITY_ORI3.Text = "";
|
||
COMMODITY_UNIT3.Text = "";
|
||
COMMODITY_RULE3.Text = "";
|
||
COMMODITY_RETAILPRICE3.Text = "";
|
||
COMMODITY_GRADE3.Text = "";
|
||
//第五组
|
||
COMMODITY_NAME4.Text = "";
|
||
COMMODITY_ORI4.Text = "";
|
||
COMMODITY_UNIT4.Text = "";
|
||
COMMODITY_RULE4.Text = "";
|
||
COMMODITY_RETAILPRICE4.Text = "";
|
||
COMMODITY_GRADE4.Text = "";
|
||
//第六组
|
||
COMMODITY_NAME5.Text = "";
|
||
COMMODITY_ORI5.Text = "";
|
||
COMMODITY_UNIT5.Text = "";
|
||
COMMODITY_RULE5.Text = "";
|
||
COMMODITY_RETAILPRICE5.Text = "";
|
||
COMMODITY_GRADE5.Text = "";
|
||
//第七组
|
||
COMMODITY_NAME6.Text = "";
|
||
COMMODITY_ORI6.Text = "";
|
||
COMMODITY_UNIT6.Text = "";
|
||
COMMODITY_RULE6.Text = "";
|
||
COMMODITY_RETAILPRICE6.Text = "";
|
||
COMMODITY_GRADE6.Text = "";
|
||
//第八组
|
||
COMMODITY_NAME7.Text = "";
|
||
COMMODITY_ORI7.Text = "";
|
||
COMMODITY_UNIT7.Text = "";
|
||
COMMODITY_RULE7.Text = "";
|
||
COMMODITY_RETAILPRICE7.Text = "";
|
||
COMMODITY_GRADE7.Text = "";
|
||
//第九组
|
||
COMMODITY_NAME8.Text = "";
|
||
COMMODITY_ORI8.Text = "";
|
||
COMMODITY_UNIT8.Text = "";
|
||
COMMODITY_RULE8.Text = "";
|
||
COMMODITY_RETAILPRICE8.Text = "";
|
||
COMMODITY_GRADE8.Text = "";
|
||
//第十组
|
||
COMMODITY_NAME9.Text = "";
|
||
COMMODITY_ORI9.Text = "";
|
||
COMMODITY_UNIT9.Text = "";
|
||
COMMODITY_RULE9.Text = "";
|
||
COMMODITY_RETAILPRICE9.Text = "";
|
||
COMMODITY_GRADE9.Text = "";
|
||
//第十一组
|
||
COMMODITY_NAME10.Text = "";
|
||
COMMODITY_ORI10.Text = "";
|
||
COMMODITY_UNIT10.Text = "";
|
||
COMMODITY_RULE10.Text = "";
|
||
COMMODITY_RETAILPRICE10.Text = "";
|
||
COMMODITY_GRADE10.Text = "";
|
||
//第十二组
|
||
COMMODITY_NAME11.Text = "";
|
||
COMMODITY_ORI11.Text = "";
|
||
COMMODITY_UNIT11.Text = "";
|
||
COMMODITY_RULE11.Text = "";
|
||
COMMODITY_RETAILPRICE11.Text = "";
|
||
COMMODITY_GRADE11.Text = "";
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 票据---》赋值
|
||
/// </summary>
|
||
/// <param name="_COMMODITY"></param>
|
||
private void InitInvoiceControlValue(COMMODITY _COMMODITY, int CurrentNum)
|
||
{
|
||
string PrintControlLocation = PrintHelper.GetRegistData("PrintControlLocation");
|
||
ServiceModel.Transaction _Transaction = new Transaction();
|
||
TextBox _COMMODITY_NAME = panel3.Controls.Find("COMMODITY_NAME" + CurrentNum.ToString(), true)[0] as TextBox;
|
||
TextBox _COMMODITY_ORI = panel3.Controls.Find("COMMODITY_ORI" + CurrentNum.ToString(), true)[0] as TextBox;
|
||
string commodityname = string.IsNullOrEmpty(_COMMODITY.COMMODITY_ALLNAME) ? _COMMODITY.COMMODITY_NAME : _COMMODITY.COMMODITY_ALLNAME;
|
||
if (commodityname.Length > 7)
|
||
{
|
||
_COMMODITY_NAME.Location = new Point(int.Parse(PrintControlLocation.Split('|')[CurrentNum].Split(',')[0]),
|
||
int.Parse(PrintControlLocation.Split('|')[CurrentNum].Split(',')[1]) - 10);
|
||
_COMMODITY_NAME.Height = _COMMODITY_NAME.Height + 10;
|
||
_COMMODITY_NAME.Text = commodityname.Substring(0, 7) + "\r\n" +
|
||
commodityname.Substring(7, commodityname.Length - 7);
|
||
}
|
||
else
|
||
{
|
||
_COMMODITY_NAME.Location = new Point(int.Parse(PrintControlLocation.Split('|')[CurrentNum].Split(',')[0]),
|
||
int.Parse(PrintControlLocation.Split('|')[CurrentNum].Split(',')[1]));
|
||
_COMMODITY_NAME.Height = _COMMODITY_ORI.Height;
|
||
_COMMODITY_NAME.Text = commodityname;
|
||
}
|
||
//if (_COMMODITY.COMMODITY_NAME.Length < 10)
|
||
_COMMODITY_ORI.Text = _COMMODITY.COMMODITY_ORI;
|
||
(panel3.Controls.Find("COMMODITY_UNIT" + CurrentNum.ToString(), true)[0] as TextBox).Text = _COMMODITY.COMMODITY_UNIT;
|
||
(panel3.Controls.Find("COMMODITY_RULE" + CurrentNum.ToString(), true)[0] as TextBox).Text = _COMMODITY.COMMODITY_RULE;
|
||
(panel3.Controls.Find("COMMODITY_RETAILPRICE" + CurrentNum.ToString(), true)[0] as TextBox).Text =
|
||
_COMMODITY.COMMODITY_RETAILPRICE.Value.ToString("F2") + "元";
|
||
try
|
||
{
|
||
(panel3.Controls.Find("COMMODITY_GRADE" + CurrentNum.ToString(), true)[0] as TextBox).Text =
|
||
DictionaryHelper.GetFieldEnumName("COMMODITYGRADE", _COMMODITY.COMMODITY_GRADE.ToString(), new Transaction());
|
||
}
|
||
catch
|
||
{
|
||
(panel3.Controls.Find("COMMODITY_GRADE" + CurrentNum.ToString(), true)[0] as TextBox).Text = "";
|
||
}
|
||
|
||
#region 获取条形码
|
||
//string fix_value = "";
|
||
//byte[] fix_image01 = new byte[1024];
|
||
|
||
//fix_value = Commodity_Barcode.Text;
|
||
|
||
//BarCode _code13 = new BarCode();
|
||
//_code13.Height = 18;
|
||
//_code13.Magnify = 0;
|
||
//_code13.FontSize = 20;
|
||
|
||
//System.Drawing.Image[] _image = new System.Drawing.Image[1];
|
||
//System.IO.MemoryStream _stream = new System.IO.MemoryStream();
|
||
//FileStream[] fs = new FileStream[1];
|
||
//string jpg = "";
|
||
//jpg = "d:\\" + fix_value.ToString() + ".jpeg";
|
||
//if (fix_value.Length == 13)
|
||
//{
|
||
// _image[0] = _code13.GetCodeImage(fix_value);
|
||
// _image[0].Save(_stream, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||
// //_image[0].Save(jpg);
|
||
|
||
// Barcode.Image = _image[0];
|
||
//}
|
||
//else
|
||
// Barcode.Image = null;
|
||
#endregion
|
||
}
|
||
#endregion
|
||
|
||
#region 获取控件初始位置
|
||
private void SetControlLocation()
|
||
{
|
||
string[] ControlLocation = new string[12];
|
||
string PrintControlLocation = "";
|
||
foreach (Control _Control in panel3.Controls)
|
||
{
|
||
switch (_Control.Name)
|
||
{
|
||
case "COMMODITY_NAME0":
|
||
ControlLocation[0] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME1":
|
||
ControlLocation[1] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME2":
|
||
ControlLocation[2] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME3":
|
||
ControlLocation[3] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME4":
|
||
ControlLocation[4] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME5":
|
||
ControlLocation[5] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME6":
|
||
ControlLocation[6] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME7":
|
||
ControlLocation[7] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME8":
|
||
ControlLocation[8] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME9":
|
||
ControlLocation[9] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME10":
|
||
ControlLocation[10] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
case "COMMODITY_NAME11":
|
||
ControlLocation[11] = _Control.Location.X + "," + _Control.Location.Y;
|
||
break;
|
||
}
|
||
}
|
||
foreach (string str in ControlLocation)
|
||
{
|
||
PrintControlLocation += (PrintControlLocation == "" ? "" : "|") + str;
|
||
}
|
||
PrintHelper.WriteRegedit("PrintControlLocation", PrintControlLocation);
|
||
}
|
||
#endregion
|
||
|
||
#region XY 位置偏移
|
||
private void SetOffsetToControl()
|
||
{
|
||
string offset = string.Empty;
|
||
offset = PrintHelper.GetRegistData("BillOffset");
|
||
txtX.Text = offset.Split(',')[0];
|
||
txtY.Text = offset.Split(',')[1];
|
||
}
|
||
|
||
private void btnSet_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(txtX.Text) && !string.IsNullOrEmpty(txtY.Text))
|
||
{
|
||
int i = 0;
|
||
string billoffset = string.Format("{0},{1}", txtX.Text.Trim(), txtY.Text.Trim());
|
||
foreach (string str in PrintHelper.GetRegistData("BillOffset").Split(','))
|
||
{
|
||
if (i > 1)
|
||
{
|
||
billoffset += "," + str;
|
||
}
|
||
i++;
|
||
}
|
||
PrintHelper.WriteRegedit("BillOffset", billoffset);
|
||
if (MessageBox.Show("保存成功!", "操作结果", MessageBoxButtons.OK) == DialogResult.OK)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region treeView1_AfterCheck 选择复选框
|
||
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
|
||
{
|
||
ServiceModel.Transaction _Transaction = new Transaction();
|
||
//e.Node.ExpandAll();
|
||
treeView_Checked(e.Node.Nodes, e.Node.Checked);
|
||
COMMODITY _COMMODITY = new COMMODITY(_Transaction);
|
||
if (e.Node.Name == "COMMODITY")
|
||
{
|
||
if (_COMMODITY.Select(int.Parse(e.Node.Tag.ToString())))
|
||
{
|
||
InitInvoiceControlValue(_COMMODITY, SelectNum % 12);
|
||
SelectNum++;
|
||
}
|
||
else
|
||
InitInvoiceControlValue();
|
||
}
|
||
}
|
||
|
||
private void treeView_Checked(TreeNodeCollection nodes, bool Checked)
|
||
{
|
||
foreach (TreeNode treeNode in nodes)
|
||
{
|
||
treeNode.Checked = Checked;
|
||
}
|
||
}
|
||
|
||
private void CommodityList_AfterSelect(object sender, TreeViewEventArgs e)
|
||
{
|
||
e.Node.Checked = !e.Node.Checked;
|
||
}
|
||
#endregion
|
||
|
||
#region treeView1_AfterSelect 选择树节点
|
||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||
{
|
||
ServiceModel.Transaction _Transaction = new Transaction();
|
||
COMMODITY _COMMODITY = new COMMODITY(_Transaction);
|
||
if (e.Node.Name == "COMMODITY")
|
||
{
|
||
if (_COMMODITY.Select(int.Parse(e.Node.Tag.ToString())))
|
||
{
|
||
InitInvoiceControlValue(_COMMODITY, 0);
|
||
}
|
||
else
|
||
InitInvoiceControlValue();
|
||
}
|
||
else
|
||
{
|
||
treeView_Show(e.Node, _Transaction);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 呈现商品标价签
|
||
bool treeView_Show(TreeNode _TreeNode, ServiceModel.Transaction _Transaction)
|
||
{
|
||
int CurrentNum = 0;
|
||
COMMODITY _COMMODITY = new COMMODITY(_Transaction);
|
||
foreach (TreeNode treeNode in _TreeNode.Nodes)
|
||
{
|
||
if (treeNode.Name == "COMMODITY")
|
||
{
|
||
if (_COMMODITY.Select(int.Parse(treeNode.Tag.ToString())))
|
||
{
|
||
InitInvoiceControlValue(_COMMODITY, CurrentNum);
|
||
CurrentNum++;
|
||
}
|
||
else if (CurrentNum % 12 == 0)
|
||
InitInvoiceControlValue();
|
||
return true;
|
||
}
|
||
if (treeView_Show(treeNode, _Transaction))
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
#endregion
|
||
|
||
#region 设置行间距
|
||
private void BtnSetRow_Click(object sender, EventArgs e)
|
||
{
|
||
SetRowXY _SetRowXY = new SetRowXY();
|
||
_SetRowXY.Show();
|
||
}
|
||
#endregion
|
||
}
|
||
}
|