[学习公共库] 条码打印
麦林 发表于 2008/11/20 9:12:14
[DllImport("Winppla.dll")] private static extern int A_CreatePrn(int selection, string filename); [DllImport("Winppla.dll")] private static extern void A_Clear_Memory(); [DllImport("Winppla.dll")] private static extern int A_Set_Darkness(int heat); [DllImport("Winppla.dll")] private static extern int A_Prn_Barcode(int x, int y, int ori, char type, int narrow, int width, int height, char mode, int numeric, string data); [DllImport("Winppla.dll")] private static extern int A_Prn_Text_TrueType(int x, int y, int FSize, string FType, int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut, string id_name, string data, int mem_mode); [DllImport("Winppla.dll")] private static extern int A_Print_Out(int width, int height, int copies, int amount); [DllImport("Winppla.dll")] private static extern void A_ClosePrn();
void Confim_Click(object sender, EventArgs e) { int x = 30; int y = 1; A_CreatePrn(1, "NULL"); A_Clear_Memory(); A_Set_Darkness(8); A_Prn_Barcode(x, y + 30, 1,'e',1,1, 30, 'N', 1, Barcodeno); A_Prn_Text_TrueType(x, y + 20, 18, "宋体", 1, 700, 0, 0, 0, "AB", "123456789", 1); A_Print_Out(1, 1, LabelCount, 1); A_ClosePrn(); this.Close(); }
回复:条码打印
dml(游客)发表评论于2009/8/11 17:14:03
class PrintTxm : Jeez.Runtime.Base.General.GeneralUI { public static string Num; public static string Unit;
public Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox IfName; public Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox IfContact; public Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox IfMufact; public Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox IfPrice; public Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox IfBarde; public Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox IfUnit; public Jeez.Control.UltraButton.JeezUltraButton Confim; public Jeez.Control.UltraButton.JeezUltraButton Cancle; public Jeez.Control.JeezNumberTextBox.JeezNumberTextBox count;
public override bool LoadUI() { bool b = base.LoadUI(); IfName = base.GetControlByName("JeezCheckBox4") as Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox; IfContact = base.GetControlByName("JeezCheckBox1") as Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox; IfMufact = base.GetControlByName("JeezCheckBox5") as Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox; IfPrice = base.GetControlByName("JeezCheckBox2") as Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox; IfBarde = base.GetControlByName("JeezCheckBox6") as Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox; IfUnit = base.GetControlByName("JeezCheckBox3") as Jeez.Control.JeezUltraCheckBox.JeezUltraCheckBox; Confim = base.GetControlByName("JeezButton1") as Jeez.Control.UltraButton.JeezUltraButton; Cancle = base.GetControlByName("JeezButton2") as Jeez.Control.UltraButton.JeezUltraButton; count = base.GetControlByName("JeezNumberTextBox1") as Jeez.Control.JeezNumberTextBox.JeezNumberTextBox; Confim.Click += new EventHandler(Confim_Click); Cancle.Click += new EventHandler(Cancle_Click); return b; }
protected override void GereralUI_Load(object sender, EventArgs e) { base.GereralUI_Load(sender, e); IfName.Checked = true; IfContact.Checked = true; IfMufact.Checked = true; IfBarde.Checked = true; }
[DllImport("Winppla.dll")] private static extern void A_Clear_Memory(); [DllImport("Winppla.dll")] private static extern void A_ClosePrn(); [DllImport("Winppla.dll")] private static extern int A_CreatePrn(int selection, string filename); [DllImport("Winppla.dll")] private static extern int A_Del_Graphic(int mem_mode, string graphic); [DllImport("Winppla.dll")] private static extern int A_Draw_Box(char mode, int x, int y, int width, int height, int top, int side); [DllImport("Winppla.dll")] private static extern int A_Draw_Line(char mode, int x, int y, int width, int height); [DllImport("Winppla.dll")] private static extern void A_Feed_Label(); [DllImport("Winppla.dll")] private static extern int A_Get_Graphic(int x, int y, int mem_mode, char format, string filename); [DllImport("Winppla.dll")] private static extern int A_Get_Graphic_ColorBMP(int x, int y, int mem_mode, char format, string filename); [DllImport("Winppla.dll")] private static extern int A_Initial_Setting(int Type, string Source); [DllImport("Winppla.dll")] private static extern int A_Load_Graphic(int x, int y, string graphic_name); [DllImport("Winppla.dll")] private static extern int A_Open_ChineseFont(string path); [DllImport("Winppla.dll")] private static extern int A_Print_Form(int width, int height, int copies, int amount, string form_name); [DllImport("Winppla.dll")] private static extern int A_Print_Out(int width, int height, int copies, int amount); [DllImport("Winppla.dll")] private static extern int A_Prn_Barcode(int x, int y, int ori, char type, int narrow, int width, int height, char mode, int numeric, string data); [DllImport("Winppla.dll")] private static extern int A_Prn_Text(int x, int y, int ori, int font, int type, int hor_factor, int ver_factor, char mode, int numeric, string data); [DllImport("Winppla.dll")] private static extern int A_Prn_Text_Chinese(int x, int y, int fonttype, string id_name, string data, int mem_mode); [DllImport("Winppla.dll")] private static extern int A_Prn_Text_TrueType(int x, int y, int FSize, string FType, int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut, string id_name, string data, int mem_mode); [DllImport("Winppla.dll")] private static extern int A_Prn_Text_TrueType_W(int x, int y, int FHeight, int FWidth, string FType, int Fspin, int FWeight, int FItalic, int FUnline, int FStrikeOut, string id_name, string data, int mem_mode); [DllImport("Winppla.dll")] private static extern int A_Set_Backfeed(int back); [DllImport("Winppla.dll")] private static extern int A_Set_BMPSave(int nSave, string pstrBMPFName); [DllImport("Winppla.dll")] private static extern int A_Set_Cutting(int cutting); [DllImport("Winppla.dll")] private static extern int A_Set_Darkness(int heat); [DllImport("Winppla.dll")] private static extern int A_Set_DebugDialog(int nEnable); [DllImport("Winppla.dll")] private static extern int A_Set_Feed(char rate); [DllImport("Winppla.dll")] private static extern int A_Set_Form(string formfile, string form_name, int mem_mode); [DllImport("Winppla.dll")] private static extern int A_Set_Margin(int position, int margin); [DllImport("Winppla.dll")] private static extern int A_Set_Prncomport(int baud, int parity, int data, int stop); [DllImport("Winppla.dll")] private static extern int A_Set_Prncomport_PC(int nBaudRate, int nByteSize, int nParity, int nStopBits, int nDsr, int nCts, int nXonXoff); [DllImport("Winppla.dll")] private static extern int A_Set_Sensor_Mode(char type, int continuous); [DllImport("Winppla.dll")] private static extern int A_Set_Speed(char speed); [DllImport("Winppla.dll")] private static extern int A_Set_Syssetting(int transfer, int cut_peel, int length, int zero, int pause); [DllImport("Winppla.dll")] private static extern int A_Set_Unit(char unit); [DllImport("Winppla.dll")] private static extern int A_Set_Logic(int logic); [DllImport("Winppla.dll")] private static extern int A_Set_ProcessDlg(int nShow); [DllImport("Winppla.dll")] private static extern int A_Set_LabelVer(int centiInch); [DllImport("Winppla.dll")] private static extern int A_GetUSBBufferLen(); [DllImport("Winppla.dll")] private static extern int A_EnumUSB(byte[] buf); [DllImport("Winppla.dll")] private static extern int A_CreateUSBPort(int nPort); [DllImport("Winppla.dll")] private static extern int A_CreatePort(int nPortType, int nPort, string filename);
void Cancle_Click(object sender, EventArgs e) { this.Close(); }
void Confim_Click(object sender, EventArgs e) { int x = 30; int y = 1;
A_CreatePrn(1, "NULL"); A_Clear_Memory(); A_Set_Darkness(8); string Barcode = "690000000000"; string MatName = ""; string Contact = ""; string Manufact = ""; string Price = "0.00";
EntityObject eo_Mat = EntityObjectFactory.GetInstance(this.objContext, EntityIDEnum.Material).FindFirst("Number = {0}", Num); if (eo_Mat != null) { Barcode = eo_Mat.GetProperty("Barcode").ToString(); MatName = eo_Mat.GetProperty("Name").ToString(); Contact = eo_Mat.GetProperty("Contact").ToString(); Manufact = eo_Mat.GetProperty("Manufacturers").ToString(); if (Manufact.Length > 6) { Manufact = Manufact.Substring(0, 6); } EntityObject eo_Price = EntityObjectFactory.GetInstance(this.objContext, EntityIDEnum.MaterialsPurchasePrice).FindFirst("materialID = {0}", eo_Mat.PrimaryKeyValue); if (eo_Price != null) { Price = eo_Price.GetProperty("RetailPrice").ToString(); } } int LabelCount = Convert.ToInt32(count.VALUE); int Ys = 0; System.Math.DivRem(LabelCount, 3, out Ys); int rowCount = LabelCount / 3;
if (MatName.Length > 11) { if (IfUnit.Checked == true) { MatName = MatName.Substring(0, 11); } else { MatName = MatName.Substring(0, 12); } } Price = decimal.Round(Convert.ToDecimal(Price), 3).ToString(); string row1 = (IfBarde.Checked == true) ? (Barcode) : (""); string row2 = ((IfName.Checked == true) ? (MatName) : ("")) + " " + ((IfUnit.Checked == true) ? (Unit) : ("")); string row3 = ((IfMufact.Checked == true) ? (Manufact) : ("")) + " " + ((IfContact.Checked == true) ? (Contact) : (""));
A_Prn_Barcode(x, y + 30, 1, 'e', 1, 1, 30, 'N', 1, Barcode); A_Prn_Text_TrueType(x, y + 20, 18, "宋体", 1, 700, 0, 0, 0, "AB", row1, 1); A_Prn_Text_TrueType(x - 10, y + 10, 18, "宋体", 1, 700, 0, 0, 0, "A", row2, 1); A_Prn_Text_TrueType(x - 10, y, 16, "宋体", 1, 700, 0, 0, 0, "B", row3, 1);
A_Prn_Barcode(x + 130, y + 30, 1, 'e', 1, 1, 30, 'N', 1, Barcode); A_Prn_Text_TrueType(x + 130, y + 20, 18, "宋体", 1, 700, 0, 0, 0, "AB", row1, 1); A_Prn_Text_TrueType(x + 120, y + 10, 18, "宋体", 1, 700, 0, 0, 0, "A", row2, 1); A_Prn_Text_TrueType(x + 120, y, 16, "宋体", 1, 700, 0, 0, 0, "B", row3, 1);
A_Prn_Barcode(x + 265, y + 30, 1, 'e', 1, 1, 30, 'N', 1, Barcode); A_Prn_Text_TrueType(x + 265, y + 20, 18, "宋体", 1, 700, 0, 0, 0, "AB", row1, 1); A_Prn_Text_TrueType(x + 255, y + 10, 18, "宋体", 1, 700, 0, 0, 0, "A", row2, 1); A_Prn_Text_TrueType(x + 255, y, 16, "宋体", 1, 700, 0, 0, 0, "B", row3, 1);
A_Print_Out(1, 1, LabelCount, 1);
A_ClosePrn(); this.Close(); } }
回复:条码打印
dml(游客)发表评论于2010/6/18 10:22:15
[DllImport("kernel32.dll", CharSet = CharSet.Auto)] private static extern IntPtr CreateFile(string lpFileName, int dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); public void PrintLine(string str) { try { IntPtr iHandle = CreateFile(PosMain.BoxConnection, 0x40000000, 0, 0, 3, 0, 0); System.Threading.Thread.CurrentThread.Join(100); if (iHandle.ToInt32() != -1) { FileStream fs = new FileStream(iHandle,FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("GB2312")); sw.WriteLine(str); sw.Close(); fs.Close(); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
回复:条码打印
I want to print barcode in c#,does anyone have any ideas about it? Or any good suggestion? I am totally a green hand on barcode printing field. Any suggestion will be appreciated. Thanks in advance.
» 1 »
.: 公告
« November 2025 » 日 一 二 三 四 五 六 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
.: 我的分类(专题)
.: 最新日志
.: 最新回复
blog名称:栗色?蓝色? 日志总数:449 评论数量:201 留言数量:37 访问次数:2271664 建立时间:2006年5月16日
.: 留言板
.: 链接