using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.StudioDataSet
{
public partial class DefaultPrinterSetFormMain : LYFZ.Software.UI.StudioDataSet.DefaultPrinterSetFormMain
{
public DefaultPrinterSetFormMain()
{
this.Load += DefaultPrinterSetFormMain_Load;
//this.dgvData_A4_Size.CellMouseDown += dgvData_A4_Size_CellMouseDown;
//this.dgvData_A4_Path.CellMouseDown += dgvData_A4_Path_CellMouseDown;
//this.dgvData_DMX_Dots.CellMouseDown += dgvData_DMX_Dots_CellMouseDown;
//this.dgvData_DMX_Path.CellMouseDown += dgvData_DMX_Path_CellMouseDown;
//this.dgvData_STicket_Path.CellMouseDown += dgvData_STicket_Path_CellMouseDown;
//this.dgvData_DMX_PrintTitles.CellMouseDown += dgvData_DMX_PrintTitles_CellMouseDown;
//this.contextMenuStripEx1.ItemClicked += contextMenuStripEx1_ItemClicked;
//this.dgvData_DMX_PrintTitles.CellMouseDoubleClick += dgvData_DMX_PrintTitles_CellMouseDoubleClick;
//this.txtPrintTitles.Leave += txtPrintTitles_Leave;
}
LYFZ.BLL.BLL_ErpPrinterSet psbll = new BLL.BLL_ErpPrinterSet();
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
///
/// 窗体加载
///
///
///
void DefaultPrinterSetFormMain_Load(object sender, EventArgs e)
{
string StrShopName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
//A4路径设置
string ExecuteSql = orbll.GetView_CustomReturnExecuteSql("tb_ErpPrinterSet", StrWhere: "ps_PrintAppliesType = '适用于(A4纸打印机)' and ps_DividedShop = '" + StrShopName + "'", ShowColumnName: "ID , row_number() over(order by ps_SingleSort) AS 序号, ps_SingleName AS 打印单名称,ps_PrinterName AS 打印机名称,ps_PrinterPath AS 打印机路径,ps_PrintAppliesType AS 适用打印类型");
//针式分辨率设置
ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("tb_ErpPrinterSet", StrWhere: "ps_PrintAppliesType = '适用于(针式打印机)' and ps_DividedShop = '" + StrShopName + "'", ShowColumnName: "ID , row_number() over(order by ps_SingleSort) AS 序号, ps_SingleName AS 打印单名称,(case ps_PaperFeed when '0' then '前进纸' else (case ps_PaperFeed when '1' then '后进纸' else '' end) end) AS 针式进纸设置,ps_ResolutionName AS 针式分辨率,ps_ResolutionX,ps_ResolutionY,ps_PrintAppliesType AS 适用打印类型");
//A4打印字体设置
ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("tb_ErpPrinterSet", StrWhere: "ps_SingleName = '订单打印' and ps_DividedShop = '" + StrShopName + "'", ShowColumnName: "ID , row_number() over(order by ps_SingleSort) AS 序号, ps_SingleName AS 打印单名称,dbo.Get_StrArrayStrOfIndex(dbo.Get_StrArrayStrOfIndex(ps_FontSize,',',1),':',1) AS 详情内容,dbo.Get_StrArrayStrOfIndex(dbo.Get_StrArrayStrOfIndex(ps_FontSize,',',1),':',2) AS 详情内容Tag, dbo.Get_StrArrayStrOfIndex(dbo.Get_StrArrayStrOfIndex(ps_FontSize,',',2),':',1) AS 注意事项, dbo.Get_StrArrayStrOfIndex(dbo.Get_StrArrayStrOfIndex(ps_FontSize,',',2),':',2) AS 注意事项Tag, ps_PrintAppliesType AS 适用打印类型");
//热敏小票设置
ExecuteSql += orbll.GetView_CustomReturnExecuteSql("tb_ErpPrinterSet", StrWhere: "ps_PrintAppliesType = '适用于(针式打印机)' and ps_DividedShop = '" + StrShopName + "'", ShowColumnName: "ID , row_number() over(order by ps_SingleSort) AS 序号, ps_SingleName AS 打印单名称, ps_SmallTicketPrintName AS 打印机名称, ps_SmallTicketPrintPath AS 打印机路径, '适用于(小票打印机)' AS 适用打印类型");
//针式纸路径设置
ExecuteSql += orbll.GetView_CustomReturnExecuteSql("tb_ErpPrinterSet", StrWhere: "ps_PrintAppliesType = '适用于(针式打印机)' and ps_DividedShop = '" + StrShopName + "'", ShowColumnName: "ID , row_number() over(order by ps_SingleSort) AS 序号, ps_SingleName AS 打印单名称, ps_PrinterName AS 打印机名称, ps_PrinterPath AS 打印机路径, ps_PrintAppliesType AS 适用打印类型");
//针式打印标题设置
ExecuteSql += orbll.GetView_CustomReturnExecuteSql("tb_ErpPrinterSet", StrWhere: "ps_PrintAppliesType = '适用于(针式打印机)' and ps_DividedShop = '" + StrShopName + "'", ShowColumnName: "ID , row_number() over(order by ps_SingleSort) AS 序号, ps_SingleName AS 打印单名称, ps_PrintTitles AS 打印标题, ps_PrintAppliesType AS 适用打印类型");
DataSet dtSet = orbll.GetView_Custom(ExecuteSql);
//A4打印机路径设置
this.dgvData_A4_Path.DataSource(dtSet.Tables[0]);
this.dgvData_A4_Path.Columns["ID"].Visible = false;
this.dgvData_A4_Path.Columns["序号"].FillWeight = 20;
this.dgvData_A4_Path.Columns["打印单名称"].FillWeight = 70;
//A4打印机字体大小设置
#region A4打印机字体大小设置
DataTable tbl3 = dtSet.Tables[2];
if (this.dgvData_A4_Size.Columns.Count <= 0)
{
DataGridViewColumn dgvColumn = null;
for (int i = 0; i < tbl3.Columns.Count; i++)
{
if (tbl3.Columns[i].ColumnName.Trim() != "详情内容Tag" && tbl3.Columns[i].ColumnName.Trim() != "注意事项Tag")
{
dgvColumn = new DataGridViewColumn();
dgvColumn.ReadOnly = true;
dgvColumn.Name = tbl3.Columns[i].ColumnName.Trim();
dgvColumn.HeaderText = tbl3.Columns[i].ColumnName.Trim();
dgvColumn.ToolTipText = tbl3.Columns[i].ColumnName.Trim();
if (tbl3.Columns[i].ColumnName.Trim() == "ID")
{ dgvColumn.Visible = false; }
if (tbl3.Columns[i].ColumnName.Trim() == "序号")
{ dgvColumn.FillWeight = 20; }
this.dgvData_A4_Size.Columns.Add(dgvColumn);
}
}
}
this.dgvData_A4_Size.Rows.Clear();
for (int i = 0; i < tbl3.Rows.Count; i++)
{
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = tbl3.Rows[i]["ID"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl3.Rows[i]["序号"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl3.Rows[i]["打印单名称"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl3.Rows[i]["详情内容"].ToString().Trim();
cell.Tag = tbl3.Rows[i]["详情内容Tag"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl3.Rows[i]["注意事项"].ToString().Trim();
cell.Tag = tbl3.Rows[i]["注意事项Tag"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl3.Rows[i]["适用打印类型"].ToString().Trim();
dgvr.Cells.Add(cell);
this.dgvData_A4_Size.Rows.Add(dgvr);
}
#endregion
//针式打印机路径设置
this.dgvData_DMX_Path.DataSource(dtSet.Tables[4]);
this.dgvData_DMX_Path.Columns["ID"].Visible = false;
this.dgvData_DMX_Path.Columns["序号"].FillWeight = 20;
this.dgvData_DMX_Path.Columns["打印单名称"].FillWeight = 70;
//针式打印机分辨率设置
this.dgvData_DMX_Dots.DataSource(dtSet.Tables[1]);
this.dgvData_DMX_Dots.Columns["ID"].Visible = false;
this.dgvData_DMX_Dots.Columns["序号"].FillWeight = 20;
this.dgvData_DMX_Dots.Columns["ps_ResolutionX"].Visible = false;
this.dgvData_DMX_Dots.Columns["ps_ResolutionY"].Visible = false;
//热敏打印机路径设置
this.dgvData_STicket_Path.DataSource(dtSet.Tables[3]);
this.dgvData_STicket_Path.Columns["ID"].Visible = false;
this.dgvData_STicket_Path.Columns["序号"].FillWeight = 20;
//针式打印标题设置
this.dgvData_DMX_PrintTitles.DataSource(dtSet.Tables[5]);
this.dgvData_DMX_PrintTitles.Columns["ID"].Visible = false;
this.dgvData_DMX_PrintTitles.Columns["序号"].FillWeight = 20;
}
///
/// A4打印机打印机路径设置 列表列点击事件(右键)
///
///
///
void dgvData_A4_Path_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStripEx1.Items.Clear();
this.contextMenuStripEx1.Show(MousePosition.X, MousePosition.Y);
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "清空值";
item.Tag = "StrPrinter";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "设置打印机";
item.Tag = "StrPrinter";
contextMenuStripEx1.Items.Add(item);
}
}
}
///
/// A4纸字体大小设置 列表列点击事件(右键)
///
///
///
void dgvData_A4_Size_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStripEx1.Items.Clear();
//弹出操作菜单
this.contextMenuStripEx1.Show(MousePosition.X, MousePosition.Y);
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
if (this.dgvData_A4_Size.Columns[e.ColumnIndex].Name.Trim() == "详情内容" || this.dgvData_A4_Size.Columns[e.ColumnIndex].Name.Trim() == "打印单名称")
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "17号";
item.Name = "17";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "16号";
item.Name = "16";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "15号";
item.Name = "15";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "14号";
item.Name = "14";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "13号";
item.Name = "13";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "12号";
item.Name = "12";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "11号";
item.Name = "11";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "10号";
item.Name = "10";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "9号";
item.Name = "9";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "8号";
item.Name = "8";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "7号";
item.Name = "7";
item.Tag = "StrFontSize_Detail";
contextMenuStripEx1.Items.Add(item);
}
else if (this.dgvData_A4_Size.Columns[e.ColumnIndex].Name.Trim() == "注意事项" || this.dgvData_A4_Size.Columns[e.ColumnIndex].Name.Trim() == "适用打印类型")
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "17号";
item.Name = "17";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "16号";
item.Name = "16";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "15号";
item.Name = "15";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "14号";
item.Name = "14";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "13号";
item.Name = "13";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "12号";
item.Name = "12";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "11号";
item.Name = "11";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "10号";
item.Name = "10";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "9号";
item.Name = "9";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "8号";
item.Name = "8";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "7号";
item.Name = "7";
item.Tag = "StrFontSize_Note";
contextMenuStripEx1.Items.Add(item);
}
}
}
}
///
/// 针式打印分辨率设置 列表列点击事件(右键)
///
///
///
void dgvData_DMX_Dots_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStripEx1.Items.Clear();
//弹出操作菜单
this.contextMenuStripEx1.Show(MousePosition.X, MousePosition.Y);
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
ToolStripMenuItem item = new ToolStripMenuItem();
if (this.dgvData_DMX_Dots.Columns[e.ColumnIndex].Name.Trim() == "针式进纸设置" || this.dgvData_DMX_Dots.Columns[e.ColumnIndex].Name.Trim() == "打印单名称")
{
item.Text = "前进纸";
item.Tag = "StrPaperFeed";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "后进纸";
item.Tag = "StrPaperFeed";
contextMenuStripEx1.Items.Add(item);
}
else if (this.dgvData_DMX_Dots.Columns[e.ColumnIndex].Name.Trim() == "针式分辨率" || this.dgvData_DMX_Dots.Columns[e.ColumnIndex].Name.Trim() == "适用打印类型")
{
DataTable tbl = orbll.GetView_Custom("tb_ErpPrinterSet", StrWhere: "ID = '" + Convert.ToInt32(this.dgvData_DMX_Dots.Rows[e.RowIndex].Cells["ID"].Value) + "'", ShowColumnName: "ps_PrinterPath").Tables[0];
if (tbl.Rows.Count > 0)
{
if (tbl.Rows[0]["ps_PrinterPath"].ToString().Trim() == "")
{ MessageBoxCustom.Show("未设置打印机,无法获取打印机分辨率!"); return; }
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = tbl.Rows[0]["ps_PrinterPath"].ToString().Trim();
int dlgCount = pd.PrinterSettings.PrinterResolutions.Count;
for (int i = 0; i < dlgCount; i++)
{
int dlg_X = pd.PrinterSettings.PrinterResolutions[i].X;
int dlg_Y = pd.PrinterSettings.PrinterResolutions[i].Y;
item = new ToolStripMenuItem();
item.Text = "X:" + dlg_X + " Y:" + dlg_Y;
item.Name = "X:" + dlg_X + "|Y:" + dlg_Y;
item.Tag = "StrResolution";
contextMenuStripEx1.Items.Add(item);
}
}
}
}
}
}
}
///
/// 针式打印机路径设置 列表点击事件(右键)
///
///
///
void dgvData_DMX_Path_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStripEx1.Items.Clear();
this.contextMenuStripEx1.Show(MousePosition.X, MousePosition.Y);
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "清空值";
item.Tag = "StrPrinter_DMX";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "设置打印机";
item.Tag = "StrPrinter_DMX";
contextMenuStripEx1.Items.Add(item);
}
}
}
///
/// 热敏(小票)打印机路径设置 列表点击事件(右键)
///
///
///
void dgvData_STicket_Path_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStripEx1.Items.Clear();
this.contextMenuStripEx1.Show(MousePosition.X, MousePosition.Y);
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "清空值";
item.Tag = "StrPrinter_STicket";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "设置打印机";
item.Tag = "StrPrinter_STicket";
contextMenuStripEx1.Items.Add(item);
}
}
}
///
/// 热敏(小票)打印标题设置 列表点击事件(右键)
///
///
///
void dgvData_DMX_PrintTitles_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStripEx1.Items.Clear();
this.contextMenuStripEx1.Show(MousePosition.X, MousePosition.Y);
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = "清空值";
item.Tag = "StrPrinter_PrintTitles";
contextMenuStripEx1.Items.Add(item);
item = new ToolStripMenuItem();
item.Text = "设置打印标题";
item.Tag = "StrPrinter_PrintTitles";
contextMenuStripEx1.Items.Add(item);
}
}
}
///
/// 右键菜单选择项事件
///
///
///
void contextMenuStripEx1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
DateTime StrTime = SDateTime.Now;
try
{
#region 权限
if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PrinterSetup, LYFZ.CustomAttributes.OperatingAuthority.Setting))
{ MessageBoxCustom.Show("您无权限修改!"); return; }
#endregion
ToolStripItem item = e.ClickedItem;
string StrName = "";
string StrPath = "";
string StrEmployeeID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
Hashtable htData = new Hashtable();
if (item.Tag.ToString().Trim() == "StrPrinter")
{
#region A4打印机路径设置
if (item.Text.Trim() == "设置打印机")
{
PrintDialog dlg = new PrintDialog();
this.contextMenuStripEx1.Visible = false;
if (dlg.ShowDialog() == DialogResult.OK)
{
StrName = dlg.PrinterSettings.PrinterName;
StrPath = System.IO.Path.GetFileName(StrName);
}
else
{ return; }
}
for (int i = 0; i < this.dgvData_A4_Path.SelectedRows.Count; i++)
{
htData["where ID = '" + this.dgvData_A4_Path.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_PrinterName = '" + StrPath + "',ps_PrinterPath = '" + StrName + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_A4_Path.SelectedRows[i].Cells["打印机名称"].Value = StrPath;
this.dgvData_A4_Path.SelectedRows[i].Cells["打印机路径"].Value = StrName;
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrFontSize_Detail")
{
#region A4纸详情内容字体大小设置
for (int i = 0; i < this.dgvData_A4_Size.Rows.Count; i++)
{
htData["where ID = '" + this.dgvData_A4_Size.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_FontSize = '" + item.Text.Trim() + ":" + item.Name.Trim() + "," + this.dgvData_A4_Size.SelectedRows[i].Cells["注意事项"].Value + ":" + this.dgvData_A4_Size.SelectedRows[i].Cells["注意事项"].Tag.ToString().Trim() + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_A4_Size.Rows[i].Cells["详情内容"].Value = item.Text.Trim();
this.dgvData_A4_Size.Rows[i].Cells["详情内容"].Tag = item.Name.Trim();
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrFontSize_Note")
{
#region A4纸注意事项字体大小设置
for (int i = 0; i < this.dgvData_A4_Size.Rows.Count; i++)
{
htData["where ID = '" + this.dgvData_A4_Size.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_FontSize = '" + this.dgvData_A4_Size.SelectedRows[i].Cells["详情内容"].Value + ":" + this.dgvData_A4_Size.SelectedRows[i].Cells["详情内容"].Tag.ToString().Trim() + "," + item.Text.Trim() + ":" + item.Name.Trim() + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_A4_Size.Rows[i].Cells["注意事项"].Value = item.Text.Trim();
this.dgvData_A4_Size.Rows[i].Cells["注意事项"].Tag = item.Name.Trim();
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrPaperFeed")
{
#region 针式进纸设置
for (int i = 0; i < this.dgvData_DMX_Dots.SelectedRows.Count; i++)
{
if (this.dgvData_DMX_Dots.SelectedRows[i].Cells["适用打印类型"].Value.ToString().ToString().Trim() == "适用于(针式打印机)")
{
string strValue = "0";
if (item.Text.Trim() == "后进纸")
{ strValue = "1"; }
htData["where ID = '" + this.dgvData_DMX_Dots.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_PaperFeed = '" + strValue + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_DMX_Dots.SelectedRows[i].Cells["针式进纸设置"].Value = item.Text.Trim();
}
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrResolution")
{
#region 针式打印分辨率
string StrX_Y = item.Text.Trim();
string StrX = "";
string StrY = "";
if (StrX_Y != "")
{
string[] StrNameSplit = item.Name.Trim().Split('|');
StrX = StrNameSplit[0].Trim().Split(':')[1];
StrY = StrNameSplit[1].Trim().Split(':')[1];
}
for (int i = 0; i < this.dgvData_DMX_Dots.SelectedRows.Count; i++)
{
if (this.dgvData_DMX_Dots.SelectedRows[i].Cells["适用打印类型"].Value.ToString().ToString().Trim() == "适用于(针式打印机)")
{
htData["where ID = '" + this.dgvData_DMX_Dots.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_ResolutionName = '" + StrX_Y + "',ps_ResolutionX='" + StrX + "',ps_ResolutionY='" + StrY + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_DMX_Dots.SelectedRows[i].Cells["针式分辨率"].Value = StrX_Y;
}
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrPrinter_DMX")
{
#region 针式打印机路径设置
if (item.Text.Trim() == "设置打印机")
{
PrintDialog dlg = new PrintDialog();
this.contextMenuStripEx1.Visible = false;
if (dlg.ShowDialog() == DialogResult.OK)
{
StrName = dlg.PrinterSettings.PrinterName;
StrPath = System.IO.Path.GetFileName(StrName);
}
else
{ return; }
}
for (int i = 0; i < this.dgvData_DMX_Path.SelectedRows.Count; i++)
{
htData["where ID = '" + this.dgvData_DMX_Path.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_PrinterName = '" + StrPath + "',ps_PrinterPath = '" + StrName + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_DMX_Path.SelectedRows[i].Cells["打印机名称"].Value = StrPath;
this.dgvData_DMX_Path.SelectedRows[i].Cells["打印机路径"].Value = StrName;
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrPrinter_STicket")
{
#region 针式打印机路径设置
if (item.Text.Trim() == "设置打印机")
{
PrintDialog dlg = new PrintDialog();
this.contextMenuStripEx1.Visible = false;
if (dlg.ShowDialog() == DialogResult.OK)
{
StrName = dlg.PrinterSettings.PrinterName;
StrPath = System.IO.Path.GetFileName(StrName);
}
else
{ return; }
}
for (int i = 0; i < this.dgvData_STicket_Path.SelectedRows.Count; i++)
{
htData["where ID = '" + this.dgvData_STicket_Path.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_SmallTicketPrintName = '" + StrPath + "',ps_SmallTicketPrintPath = '" + StrName + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_STicket_Path.SelectedRows[i].Cells["打印机名称"].Value = StrPath;
this.dgvData_STicket_Path.SelectedRows[i].Cells["打印机路径"].Value = StrName;
}
#endregion
}
else if (item.Tag.ToString().Trim() == "StrPrinter_PrintTitles")
{
#region 针式打印标题设置
if (item.Text.Trim() == "设置打印标题")
{
LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetTextSuperSmallForm frm = new CameraControlBook.SuperSmallForm.GetTextSuperSmallForm();
frm.ShowDialog();
this.contextMenuStripEx1.Visible = false;
if (frm.IsOK)
{ StrName = frm.StrValue; }
else
{ return; }
if (StrName.Trim().Length > 40)
{ MessageBoxCustom.Show("标题名称长度不能超过40字符!"); return; }
}
for (int i = 0; i < this.dgvData_DMX_PrintTitles.SelectedRows.Count; i++)
{
htData["where ID = '" + this.dgvData_DMX_PrintTitles.SelectedRows[i].Cells["ID"].Value + "'"] = " ps_PrintTitles = '" + StrName + "', ps_UpdateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss") + "', ps_UpdateName = '" + StrEmployeeID + "'";
this.dgvData_DMX_PrintTitles.SelectedRows[i].Cells["打印标题"].Value = StrName;
}
#endregion
}
psbll.UpdatePrinterSet(htData);
}
catch { MessageBoxCustom.Show(StrTime.ToString()); }
}
///
/// 打印标题设置
///
///
///
void dgvData_DMX_PrintTitles_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.RowIndex != -1 && e.ColumnIndex != -1)
{
this.txtPrintTitles.Visible = false;
if (this.dgvData_DMX_PrintTitles.Columns[e.ColumnIndex].Name == "打印标题")//
{
DataGridViewCell cell = this.dgvData_DMX_PrintTitles.Rows[e.RowIndex].Cells[e.ColumnIndex];
Rectangle rect = this.dgvData_DMX_PrintTitles.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true);
this.txtPrintTitles.Location = new Point(rect.Location.X + this.dgvData_DMX_PrintTitles.Location.X, rect.Location.Y + this.dgvData_DMX_PrintTitles.Location.Y);
this.txtPrintTitles.Size = rect.Size;
this.txtPrintTitles.Visible = true;
this.txtPrintTitles.Text = cell.Value.ToString().Trim();
this.txtPrintTitles.Tag = "PT";
this.txtPrintTitles.Focus();
}
}
}
///
/// 离开事件
///
///
///
void txtPrintTitles_Leave(object sender, EventArgs e)
{
if (this.txtPrintTitles.Tag != null)
{
if (this.txtPrintTitles.Tag.ToString().Trim() == "PT")
{
this.dgvData_DMX_PrintTitles.CurrentRow.Cells["打印标题"].Value = this.txtPrintTitles.Text.Trim();
LYFZ.Model.Model_ErpPrinterSet model = psbll.GetModel(Convert.ToInt32(this.dgvData_DMX_PrintTitles.CurrentRow.Cells["ID"].Value));
model.Ps_printtitles = this.txtPrintTitles.Text.Trim();
if (!psbll.Update(model))
{ MessageBoxCustom.Show("设置打印标题失败!"); return; }
}
this.txtPrintTitles.Visible = false;
}
}
}
}