730 lines
29 KiB
C#
730 lines
29 KiB
C#
//#define isSysEidt
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using System.Data.SQLite;
|
||
using ryCommon;
|
||
|
||
namespace ryPrint.Mod
|
||
{
|
||
public partial class frmAddMod : Form
|
||
{
|
||
public frmAddMod()
|
||
{
|
||
InitializeComponent();
|
||
cbbType.SelectedIndex = 0;
|
||
}
|
||
bool isDataChanged = false;
|
||
#region 添加控件函数
|
||
private myLabel AddControl(string name, string title, ClsProperty.En_Type sType, string format, string value)
|
||
{
|
||
return AddControl(name, title, sType, format, value,"");
|
||
}
|
||
private myLabel AddControl(string name, string title, ClsProperty.En_Type sType, string format, string value,string DataSource)
|
||
{
|
||
isDataChanged = true;
|
||
myLabel ct = new myLabel();
|
||
ct.Size = new Size(100, 25);
|
||
ct.BackColor = Color.Transparent;
|
||
ct.Text = title;
|
||
ct.Name = name;
|
||
ct.Parent = picExpress;
|
||
//ct.ReadOnly = true;
|
||
ct.BackColor = Color.Transparent;
|
||
ct.Cursor = Cursors.Arrow;
|
||
ct.Font = new Font("黑体",10,FontStyle.Regular);
|
||
//ct.MouseDown += new MouseEventHandler(ct_MouseDown);
|
||
ct.KeyUp += Ct_KeyUp;
|
||
ct.KeyDown += new KeyEventHandler(ct_KeyDown);
|
||
//ct.MouseMove += new MouseEventHandler(ct_MouseMove);
|
||
//ct.MouseUp += new MouseEventHandler(ct_MouseUp);
|
||
ct.SizeChanged += new EventHandler(ct_SizeChanged);
|
||
ct.Click += new EventHandler(ct_Click);
|
||
//ct.sType = sType;
|
||
//ct.title = title;
|
||
//ct.format = format;
|
||
//ct.value = value;
|
||
ct.Property.DataSource = DataSource;
|
||
ct.Property.Type = sType;
|
||
ct.Property.Title = title;
|
||
ct.Property.CustomFormat = format;
|
||
ct.Property.Value = value;
|
||
ct.Property.FontSize = ct.Font.Size;
|
||
ct.Property.Size = new SizeF(rySet.pixeltomm(ct.Size.Width), rySet.pixeltomm(ct.Size.Height));
|
||
ct.Property.Postion = new PointF(rySet.pixeltomm(ct.Location.X), rySet.pixeltomm(ct.Location.Y));
|
||
new DragControl.MoveControl(ct);
|
||
picExpress.Controls.Add(ct);
|
||
return ct;
|
||
}
|
||
private void Ct_KeyUp(object sender, KeyEventArgs e)
|
||
{
|
||
//if (e.KeyCode == Keys.Up)
|
||
//{
|
||
// isDataChanged = true;
|
||
// myLabel ct = (myLabel)sender;
|
||
// ct.Top--;
|
||
//}
|
||
//else if (e.KeyCode == Keys.Down)
|
||
//{
|
||
// isDataChanged = true;
|
||
// myLabel ct = (myLabel)sender;
|
||
// ct.Top++;
|
||
//}
|
||
//else if (e.KeyCode == Keys.Left)
|
||
//{
|
||
// isDataChanged = true;
|
||
// myLabel ct = (myLabel)sender;
|
||
// ct.Left--;
|
||
//}
|
||
//else if (e.KeyCode == Keys.Right)
|
||
//{
|
||
// isDataChanged = true;
|
||
// myLabel ct = (myLabel)sender;
|
||
// ct.Left++;
|
||
//}
|
||
}
|
||
|
||
void ct_SizeChanged(object sender, EventArgs e)
|
||
{
|
||
isDataChanged = true;
|
||
myLabel ct = (myLabel)sender;
|
||
LoadProperty(ct);
|
||
}
|
||
|
||
void ct_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Delete)
|
||
{
|
||
isDataChanged = true;
|
||
myLabel ct = (myLabel)sender;
|
||
picExpress.Controls.Remove(ct);
|
||
propertyGrid1.SelectedObject = null;
|
||
}
|
||
}
|
||
private void AddControl(string name, ClsProperty.En_Type _type)
|
||
{
|
||
if (GetControl(name) != null)
|
||
{
|
||
MessageBox.Show("该项已经存在", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
else
|
||
{
|
||
AddControl(name, Enum.GetName(typeof(ClsProperty.En_Type), _type), _type, "", "");
|
||
}
|
||
}
|
||
private myLabel GetControl(string name)
|
||
{
|
||
foreach (Control ct in picExpress.Controls)
|
||
{
|
||
if (ct.Name == name)
|
||
{
|
||
if (ct is myLabel)
|
||
{
|
||
return (myLabel)ct;
|
||
}
|
||
else
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
#endregion
|
||
private void LoadProperty(myLabel ct)
|
||
{
|
||
propertyGrid1.SelectedObject = ct.Property;
|
||
}
|
||
void ct_Click(object sender, EventArgs e)
|
||
{
|
||
myLabel ct = (myLabel)sender;
|
||
LoadProperty(ct);
|
||
}
|
||
#region 控件拖放
|
||
private Point position;
|
||
private bool capture = false;
|
||
private void ct_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
|
||
{
|
||
//左键的话,标志位为true(表示拖拽开始)
|
||
if ((e.Button == System.Windows.Forms.MouseButtons.Left))
|
||
{
|
||
position = new Point(e.X, e.Y);
|
||
capture = true;
|
||
}
|
||
}
|
||
private void ct_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e)
|
||
{
|
||
if (capture)
|
||
{
|
||
if (sender is TextBox)
|
||
{
|
||
TextBox ct = (TextBox)sender;
|
||
ct.Location = new Point(e.X + ct.Left - position.X, e.Y + ct.Top - position.Y);
|
||
// this.Label1.Location = new Point(this.Label1.Left, this.label1.Top);
|
||
}
|
||
else if (sender is myLabel)
|
||
{
|
||
myLabel ct = (myLabel)sender;
|
||
ct.Location = new Point(e.X + ct.Left - position.X, e.Y + ct.Top - position.Y);
|
||
// this.label1.Location = new Point(this.label1.Left, this.label1.Top);
|
||
}
|
||
}
|
||
}
|
||
private void ct_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)
|
||
{
|
||
capture = false;
|
||
}
|
||
|
||
private void picEXpress_DragEnter(object sender, DragEventArgs e)
|
||
{
|
||
//当Button被拖拽到WinForm上时候,鼠标效果出现
|
||
if ((e.Data.GetDataPresent(typeof(TextBox))) || (e.Data.GetDataPresent(typeof(myLabel))))
|
||
{
|
||
e.Effect = DragDropEffects.Move;
|
||
}
|
||
}
|
||
#endregion
|
||
private string ResetLocationControl()
|
||
{
|
||
ryCommon.clsStorage tStor = new ryCommon.clsStorage();
|
||
foreach (Control ct1 in picExpress.Controls)
|
||
{
|
||
if (ct1 is myLabel)
|
||
{
|
||
myLabel ct = (myLabel)ct1;
|
||
ct.Size = new Size(rySet.mmtopixel(ct.Property.Size.Width), rySet.mmtopixel(ct.Property.Size.Height));
|
||
ct.Location = new Point(rySet.mmtopixel(ct.Property.Postion.X), rySet.mmtopixel(ct.Property.Postion.Y));
|
||
}
|
||
}
|
||
return tStor.GetXMLText();
|
||
}
|
||
private decimal pixelTomm_Width(int pixel)
|
||
{
|
||
return pixel * numWidth.Value / picExpress.Width;
|
||
}
|
||
private decimal pixelTomm_Height(int pixel)
|
||
{
|
||
return pixel * numHeight.Value / picExpress.Height;
|
||
}
|
||
private string SaveControl()
|
||
{
|
||
ryCommon.clsStorage tStor = new ryCommon.clsStorage();
|
||
foreach (Control ct1 in picExpress.Controls)
|
||
{
|
||
if (ct1 is myLabel)
|
||
{
|
||
myLabel ct =(myLabel)ct1;
|
||
tStor.AddNode2("Name",ct.Name);
|
||
tStor.SetAttrValue("Title", ct.Property.Title);
|
||
tStor.SetAttrValue("Width", rySet.pixeltomm(ct.Size.Width));
|
||
tStor.SetAttrValue("Height", rySet.pixeltomm(ct.Size.Height));
|
||
tStor.SetAttrValue("FontSize", ct.Font.Size);
|
||
tStor.SetAttrValue("Left", rySet.pixeltomm(ct.Location.X));
|
||
tStor.SetAttrValue("Top", rySet.pixeltomm(ct.Location.Y));
|
||
//tStor.SetAttrValue("Left", ct.Location.X>picExpress.Image.Width?0:ct.Location.X);
|
||
//tStor.SetAttrValue("Top", ct.Location.Y>picExpress.Image.Height?0:ct.Location.Y);
|
||
tStor.SetAttrValue("Multiline", ct.Property.Multiline);
|
||
tStor.SetAttrValue("align", ct.AlignStr);
|
||
tStor.SetAttrValue("format", ct.Property.CustomFormat);
|
||
tStor.SetAttrValue("value", ct.Property.Value);
|
||
tStor.SetAttrValue("sType", (int)ct.Property.Type);
|
||
tStor.SetAttrValue("LineSpace", ct.Property.LineSpace);
|
||
tStor.SetAttrValue("DataSource", ct.Property.DataSource);
|
||
tStor.SetAttrValue("NoPrint", ct.Property.NoPrint);
|
||
}
|
||
}
|
||
return tStor.GetXMLText();
|
||
}
|
||
private void LoadControl(string xml)
|
||
{
|
||
ryCommon.clsStorage tStor = new ryCommon.clsStorage(xml);
|
||
System.Xml.XmlNodeList list = tStor.GetList();
|
||
for (int i = 0; i < list.Count; i++)
|
||
{
|
||
tStor.SelectNode3(list[i]);
|
||
myLabel ct = new myLabel();
|
||
ct.Font = new Font("黑体", tStor.GetAttrValueByInt("FontSize", 10), FontStyle.Regular);
|
||
ct.Property.Multiline = tStor.GetAttrValueByBool("Multiline", false);
|
||
ct.Size = new Size(rySet.mmtopixel(tStor.GetAttrValue("Width", 50f)), rySet.mmtopixel(tStor.GetAttrValue("Height", 10f)));
|
||
if (ct.Size.Height == 0) { ct.Height = 21; }
|
||
if (ct.Size.Width == 0) { ct.Width = 100; }
|
||
ct.Property.Size= new SizeF((float)tStor.GetAttrValue("Width", 50f), (float)tStor.GetAttrValue("Height", 10f));
|
||
ct.Location = new Point(rySet.mmtopixel(tStor.GetAttrValue("Left", 0f)), rySet.mmtopixel(tStor.GetAttrValue("Top", 0f)));
|
||
ct.Property.Postion = new PointF((float)tStor.GetAttrValue("Left", 0f),(float)tStor.GetAttrValue("Top", 0f));
|
||
if (ct.Location.Y < 0) { ct.Top = 0; }
|
||
if (ct.Location.X < 0) { ct.Left = 0; }
|
||
//ct.Size = new Size(tStor.GetAttrValue("Width", 50), tStor.GetAttrValue("Height", 10));
|
||
//if (ct.Size.Height == 0) { ct.Height = 21; }
|
||
//if (ct.Size.Width == 0) { ct.Width = 100; }
|
||
//ct.Property.Size = new SizeF((float)pixelTomm_Width(tStor.GetAttrValue("Width", 50)), (float)pixelTomm_Height(tStor.GetAttrValue("Height", 10)));
|
||
////ct.Location = new Point((int)pixelTomm_Width(tStor.GetAttrValue("Left", 0)), (int)pixelTomm_Height(tStor.GetAttrValue("Top", 0)));
|
||
//ct.Property.Postion = new PointF((float)pixelTomm_Width(tStor.GetAttrValue("Left", 0)), (float)pixelTomm_Height(tStor.GetAttrValue("Top", 0)));
|
||
//ct.Size = new Size(tStor.GetAttrValue("Width", 50),tStor.GetAttrValue("Height", 10));
|
||
//ct.Location = new Point(tStor.GetAttrValue("Left", 0),tStor.GetAttrValue("Top", 0));
|
||
//
|
||
Mod.ClsProperty.en_Type _type = Mod.ClsProperty.en_Type.自定义;
|
||
try
|
||
{
|
||
_type = (Mod.ClsProperty.en_Type)tStor.GetAttrValueByInt("sType", 0);
|
||
}
|
||
catch { }
|
||
ct.Property.Type = _type;
|
||
ct.Property.Title = tStor.GetAttrValue("Title");
|
||
ct.Property.LineSpace = tStor.GetAttrValue("LineSpace",0);
|
||
ct.Name = tStor.GetAttrValue("Name");
|
||
ct.Parent = picExpress;
|
||
//ct.ReadOnly = true;
|
||
ct.BackColor = Color.Transparent;
|
||
ct.Cursor = Cursors.Arrow;
|
||
ct.SetAlign(tStor.GetAttrValue("align"));
|
||
ct.Property.Value = tStor.GetAttrValue("value");
|
||
ct.Property.CustomFormat = tStor.GetAttrValue("format");
|
||
ct.Property.DataSource = tStor.GetAttrValue("DataSource");
|
||
ct.Property.NoPrint = tStor.GetAttrValue("NoPrint",false);
|
||
ct.Property.Type = _type;
|
||
ct.Refresh();
|
||
//ct.MouseDown += new MouseEventHandler(ct_MouseDown);
|
||
//ct.MouseMove += new MouseEventHandler(ct_MouseMove);
|
||
//ct.MouseUp += new MouseEventHandler(ct_MouseUp);
|
||
new DragControl.MoveControl(ct);
|
||
ct.Click += new EventHandler(ct_Click);
|
||
ct.KeyUp += Ct_KeyUp;
|
||
ct.KeyDown += new KeyEventHandler(ct_KeyDown);
|
||
ct.SizeChanged+=new EventHandler(ct_SizeChanged);
|
||
picExpress.Controls.Add(ct);
|
||
}
|
||
}
|
||
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||
{
|
||
isDataChanged = true;
|
||
ClsProperty item = (ClsProperty)propertyGrid1.SelectedObject;
|
||
myLabel ct = GetControl(item.Name);
|
||
if (ct != null)
|
||
{
|
||
ct.Property = item;
|
||
ct.Refresh();
|
||
}
|
||
}
|
||
private void btnCancel_Click(object sender, EventArgs e)
|
||
{
|
||
this.DialogResult = DialogResult.Cancel;
|
||
}
|
||
public int isAdd = 1;
|
||
public string selectId = "-1";
|
||
private void btnOK_Click(object sender, EventArgs e)
|
||
{
|
||
if (txtName.Text == "")
|
||
{
|
||
MessageBox.Show("请输入名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
isDataChanged = false;
|
||
ryQuickSQL mySQL = new ryQuickSQL(Table.s_Express.TableName);
|
||
mySQL.AddField(Table.s_Express.Name, txtName.Text);
|
||
mySQL.AddField(Table.s_Express.PicPath, txtPicPath.Text);
|
||
mySQL.AddField(Table.s_Express.Width, numWidth.Value);
|
||
mySQL.AddField(Table.s_Express.Height,numHeight.Value);
|
||
mySQL.AddField(Table.s_Express.SysId,0);
|
||
mySQL.AddField(Table.s_Express.billType, cbbType.SelectedIndex);
|
||
mySQL.AddField(Table.s_Express.ModXML, SaveControl());
|
||
mySQL.AddField(Table.s_Express.Des, txtDes.Text);
|
||
if (isAdd >= 1)
|
||
{
|
||
mySQL.AddField(Table.s_Express.AddTime, DateTime.Now);
|
||
}
|
||
#if isSysEidt
|
||
ryCommon.clsDb myDb = new ryCommon.clsDb(clsPram.SysDbPath, clsPram.DbPwd);
|
||
#else
|
||
ryCommon.clsDb myDb = new ryCommon.clsDb(clsPram.UserExpressDbPath, clsPram.DbPwd);
|
||
#endif
|
||
myDb.ConnOrCreateDb();
|
||
if (isAdd >= 1)
|
||
{
|
||
myDb.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL.GetSQLiteParameter());
|
||
}
|
||
else
|
||
{
|
||
myDb.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + selectId, mySQL.GetSQLiteParameter());
|
||
}
|
||
this.DialogResult = DialogResult.OK;
|
||
}
|
||
private void frmAddMod_Load(object sender, EventArgs e)
|
||
{
|
||
#if isSysEidt
|
||
Text += "(调试模式)";
|
||
#endif
|
||
}
|
||
public void GetDataInfoById(string id)
|
||
{
|
||
#region 数据库
|
||
try
|
||
{
|
||
#if isSysEidt
|
||
ryCommon.clsDb myDb = new ryCommon.clsDb(clsPram.SysDbPath, clsPram.DbPwd);
|
||
#else
|
||
ryCommon.clsDb myDb = new ryCommon.clsDb(clsPram.UserExpressDbPath, clsPram.DbPwd);
|
||
#endif
|
||
myDb.ConnOrCreateDb();
|
||
SQLiteCommand cmd = myDb.SQLite_cn.CreateCommand();
|
||
cmd.CommandText = "select * from " +Table.s_Express.TableName + " where id=@id";
|
||
cmd.Parameters.Add("@id", DbType.Int32); //id
|
||
cmd.Parameters["@id"].Value = id;
|
||
SQLiteDataReader reader = cmd.ExecuteReader();
|
||
while (reader.Read())
|
||
{
|
||
try
|
||
{
|
||
txtName.Text = reader[Table.s_Express.Name].ToString();
|
||
txtDes.Text = reader[Table.s_Express.Des].ToString();
|
||
txtPicPath.Text = reader[Table.s_Express.PicPath].ToString();
|
||
numWidth.Value=Convert.ToDecimal(reader[Table.s_Express.Width]);
|
||
numHeight.Value = Convert.ToDecimal(reader[Table.s_Express.Height]);
|
||
try
|
||
{
|
||
cbbType.SelectedIndex = Convert.ToInt32(reader[Table.s_Express.billType]);
|
||
}
|
||
catch { cbbType.SelectedIndex = 0; }
|
||
#if isSysEidt
|
||
string picPath = clsPram.GetTruePath(reader[Table.s_Express.PicPath].ToString(), 1);
|
||
#else
|
||
string picPath = clsPram.GetTruePath(reader[Table.s_Express.PicPath].ToString(), Convert.ToInt32(reader[Table.s_Express.SysId]));
|
||
#endif
|
||
if (System.IO.File.Exists(picPath))
|
||
{
|
||
Image image = Image.FromFile(picPath);
|
||
picExpress.Width =rySet.mmtopixel(Convert.ToDouble(reader[Table.s_Express.Width]));
|
||
picExpress.Height = rySet.mmtopixel(Convert.ToDouble(reader[Table.s_Express.Height]));
|
||
picExpress.Image = image;
|
||
//numWidth.Value = Convert.ToDecimal(rySet.InchesTomm(picExpress.Width / Convert.ToDecimal(picExpress.Image.HorizontalResolution)));
|
||
// numHeight.Value = Convert.ToDecimal(rySet.InchesTomm(picExpress.Height / Convert.ToDecimal(picExpress.Image.VerticalResolution)));
|
||
}
|
||
LoadControl(reader[Table.s_Express.ModXML].ToString());
|
||
}
|
||
catch { }
|
||
break;
|
||
}
|
||
reader.Close();
|
||
cmd.Dispose();
|
||
}
|
||
catch { }
|
||
#endregion
|
||
isDataChanged = false;
|
||
}
|
||
#region 添加控件菜单
|
||
private void 寄件人姓名ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人姓名);
|
||
}
|
||
|
||
private void 寄件人电话ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人电话);
|
||
}
|
||
|
||
private void 寄件人地址ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人地址);
|
||
}
|
||
|
||
private void 收件人姓名ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人姓名);
|
||
}
|
||
|
||
private void 收件人电话ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人电话);
|
||
}
|
||
|
||
private void 收件人地址ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人地址);
|
||
}
|
||
private void 寄件人邮编ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人邮编);
|
||
}
|
||
|
||
private void 收件人邮编ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人邮编);
|
||
}
|
||
|
||
private void 寄件人单位ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人公司);
|
||
}
|
||
|
||
private void 收件人单位ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人公司);
|
||
}
|
||
/// <summary>
|
||
/// 获取新的控件名
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private string GetNewName()
|
||
{
|
||
int i = 1;
|
||
while (true)
|
||
{
|
||
if (GetControl("custom" + i.ToString()) == null)
|
||
{
|
||
return "custom" + i.ToString();
|
||
}
|
||
i++;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 获取新的控件名
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private string GetNewName2()
|
||
{
|
||
int i = 1;
|
||
while (true)
|
||
{
|
||
if (GetControl("lbl" + i.ToString()) == null)
|
||
{
|
||
return "lbl" + i.ToString();
|
||
}
|
||
i++;
|
||
}
|
||
}
|
||
private void 自定义ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
string name = GetNewName();
|
||
AddControl(name, "自定义" + name.Replace("custom", ""), ClsProperty.En_Type.自定义, "", "");
|
||
}
|
||
|
||
private void btnAddControl_Click(object sender, EventArgs e)
|
||
{
|
||
Button ct = (Button)sender;
|
||
Point p = new Point(0, ct.Height);
|
||
contextMenuStrip1.Show(ct, p);
|
||
}
|
||
#endregion
|
||
|
||
private void btnUpdate_Click(object sender, EventArgs e)
|
||
{
|
||
#if isSysEidt
|
||
string picPath = clsPram.GetTruePath(txtPicPath.Text,1);
|
||
#else
|
||
string picPath = clsPram.GetTruePath(txtPicPath.Text,0);
|
||
#endif
|
||
if (System.IO.File.Exists(picPath))
|
||
{
|
||
Image image = Image.FromFile(picPath);
|
||
picExpress.Image = image;
|
||
numWidth.Value=Convert.ToDecimal(rySet.InchesTomm(image.Width/ Convert.ToDecimal(image.HorizontalResolution)));
|
||
numHeight.Value = Convert.ToDecimal(rySet.InchesTomm(image.Height / Convert.ToDecimal(image.VerticalResolution)));
|
||
picExpress.Width =rySet.mmtopixel((float)numWidth.Value);
|
||
picExpress.Height = rySet.mmtopixel((float)numHeight.Value);
|
||
ResetLocationControl();
|
||
//picExpress.
|
||
}
|
||
else { picExpress.Image = null; }
|
||
}
|
||
|
||
private void txtName_TextChanged(object sender, EventArgs e)
|
||
{
|
||
isDataChanged = true;
|
||
}
|
||
|
||
private void txtPicPath_TextChanged(object sender, EventArgs e)
|
||
{
|
||
isDataChanged = true;
|
||
#if isSysEidt
|
||
string picPath = clsPram.GetTruePath(txtPicPath.Text, 1);
|
||
#else
|
||
string picPath = clsPram.GetTruePath(txtPicPath.Text,0);
|
||
#endif
|
||
if (System.IO.File.Exists(picPath))
|
||
{
|
||
Image image = Image.FromFile(picPath);
|
||
picExpress.Image = image;
|
||
}
|
||
else { picExpress.Image = null; }
|
||
}
|
||
|
||
private void txtDes_TextChanged(object sender, EventArgs e)
|
||
{
|
||
isDataChanged = true;
|
||
}
|
||
|
||
private void frmAddMod_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
if (isDataChanged && DialogResult != DialogResult.OK)
|
||
{
|
||
if (MessageBox.Show("数据已经被修改,确定要不保存退出吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||
{
|
||
e.Cancel = true;
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void picExpress_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void 省份ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人省份);
|
||
}
|
||
|
||
private void 寄件人市地址ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人所在市);
|
||
}
|
||
|
||
private void 寄件人所在县区ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人县区);
|
||
}
|
||
|
||
private void 寄件人详细地址ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.寄件人详细地址);
|
||
}
|
||
|
||
private void 收件人省份ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人省份);
|
||
}
|
||
|
||
private void 收件人所在市ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人所在市);
|
||
}
|
||
|
||
private void 收件人所在县区ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人县区);
|
||
}
|
||
|
||
private void 收件人详细地址ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddControl(GetNewName2(), ClsProperty.En_Type.收件人详细地址);
|
||
}
|
||
|
||
private void propertyGrid1_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btnCalcDpi_Click(object sender, EventArgs e)
|
||
{
|
||
frmCalcDpi frm = new frmCalcDpi();
|
||
frm.Icon = Icon;
|
||
frm.kd_Width = picExpress.Image.Width;
|
||
if(frm.ShowDialog()==DialogResult.OK)
|
||
{
|
||
numWidth.Value = frm.dpiValue;
|
||
}
|
||
}
|
||
|
||
private void btnAddShop_Click(object sender, EventArgs e)
|
||
{
|
||
Button ct = (Button)sender;
|
||
Point p = new Point(0, ct.Height);
|
||
contextMenuStrip2.Show(ct, p);
|
||
}
|
||
|
||
private void 货品名称ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl("货品名称");
|
||
}
|
||
|
||
private void 货品单位ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl("货品单位");
|
||
}
|
||
|
||
private void 货品规格ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl("货品规格");
|
||
}
|
||
|
||
private void 货品数量ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl("货品数量");
|
||
}
|
||
private void AddDataControl(string name)
|
||
{
|
||
AddControl(GetNewName2(), name, ClsProperty.En_Type.数据字段, "", name);
|
||
}
|
||
private void AddDataControl2(string name)
|
||
{
|
||
AddControl(GetNewName2(), name, ClsProperty.En_Type.数据字段, "", name,"info");
|
||
}
|
||
private void 货品价格ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl("货品单价");
|
||
}
|
||
|
||
private void btnBrowser_Click(object sender, EventArgs e)
|
||
{
|
||
if(openFileDialog1.ShowDialog()==DialogResult.OK)
|
||
{
|
||
txtPicPath.Text = openFileDialog1.FileName.Replace(Application.StartupPath + "\\Db\\Pics","<pic>").Replace(Application.StartupPath, "<app>");
|
||
}
|
||
}
|
||
|
||
private void 货品总价格ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl("货品总价");
|
||
}
|
||
|
||
private void 订单单号ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("单号");
|
||
}
|
||
|
||
private void 发货备注ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("发货备注");
|
||
}
|
||
|
||
private void 订单优惠前价格ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("订单优惠前价格");
|
||
}
|
||
|
||
private void 优惠减免ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("优惠减免");
|
||
}
|
||
|
||
private void 订单优惠后价格ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("订单优惠后价格");
|
||
}
|
||
|
||
private void 客户姓名ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("客户姓名");
|
||
}
|
||
|
||
private void 客户电话ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("客户电话");
|
||
}
|
||
|
||
private void 客户公司ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("客户公司");
|
||
}
|
||
|
||
private void 客户地址ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
AddDataControl2("客户地址");
|
||
}
|
||
}
|
||
}
|