當前位置:首頁 » 操作系統 » winform源碼下載

winform源碼下載

發布時間: 2024-11-26 10:11:57

⑴ 求winform套打源碼 小弟窮就56財富 只能給50了 求高手幫忙

PrintDocument pd = new PrintDocument();
//設置邊距
Margins margin = new Margins(20, 20, 20, 20);
pd.DefaultPageSettings.Margins = margin;
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
try
{
pd.Print();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "列印出錯", MessageBoxButtons.OK, MessageBoxIcon.Error);
pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
}
//列印事件處理
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
string date = DateTime.Now.ToString(); //當前日期
string flowId = "A0000-00001"; //流水號
string payDate = DateTime.Now.ToString("yyyy年MM月"); //應收年月
string adminId = "A-01"; //操作員編號
string baseExpense = "50.00"; //應交基本費用
string fine = "30.00"; //罰款數目
string upExpense = "-20.00"; //上月上余
string actualExpense = "50.00"; //實際應交費用
string chineseExpense = "伍十圓整"; //實際應交費用的中文大寫

//讀取圖片模板
Image temp = Image.FromFile(@"Receipts.jpg");
GetResultIntoImage(ref temp, "1", flowId, date, baseExpense, fine, upExpense, actualExpense, chineseExpense, payDate, adminId);
int x = e.MarginBounds.X;
int y = e.MarginBounds.Y;
int width = temp.Width;
int height = temp.Height;
Rectangle destRect = new Rectangle(x, y, width, height);
e.Graphics.DrawImage(temp, destRect, 0, 0, temp.Width, temp.Height, System.Drawing.GraphicsUnit.Pixel);
}

/// <summary>
/// 將收費結果填充到圖片模板
/// </summary>
private void GetResultIntoImage(
ref Image temp,
string userId,
string flowId,
string currentDate,
string baseExpense,
string fine,
string upExpense,
string actualExpense,
string chineseExpense,
string payDate,
string adminName)
{
//讀取圖片模板
Graphics g = Graphics.FromImage(temp);

Font f = new Font("宋體", 12);
Brush b = new SolidBrush(Color.Black);

//填充數據到圖片模板(位置要在製作圖片模板的時候度量好)
g.DrawImage(temp, 0, 0, temp.Width, temp.Height);
g.DrawString(userId, f, b, 168, 105);
g.DrawString("Admin", f, b, 166, 134);
g.DrawString(flowId, f, b, 535, 105);
g.DrawString(currentDate, f, b, 535, 134);
g.DrawString(baseExpense, f, b, 219, 202);
g.DrawString(fine, f, b, 372, 202);
g.DrawString(upExpense, f, b, 486, 202);
g.DrawString(actualExpense, f, b, 596, 202);
g.DrawString(chineseExpense, f, b, 196, 238);
g.DrawString(payDate, f, b, 176, 269);
g.DrawString(adminName, f, b, 497, 298);

g.Dispose();}
自己把需要列印紙的大小 做一張同樣大小 空白的圖片 這里我使用的是圖片進行列印 列印的數據乃是使用在圖片上面進行坐標控制 等第一張打出來了 其餘的慢慢調下就好了

熱點內容
python27formac 發布:2025-03-11 00:04:03 瀏覽:307
蘋果8p為什麼一直要輸id密碼 發布:2025-03-10 23:55:31 瀏覽:11
java文件上傳實例 發布:2025-03-10 23:51:29 瀏覽:193
ftp對象控制 發布:2025-03-10 23:48:06 瀏覽:329
手機配置哪些不能給別人看 發布:2025-03-10 23:47:28 瀏覽:469
通常在哪個目錄存放配置文件信息 發布:2025-03-10 23:42:25 瀏覽:198
ftp伺服器什麼意思 發布:2025-03-10 23:42:17 瀏覽:863
黑魂2腳本 發布:2025-03-10 23:30:45 瀏覽:52
安卓導航手剎設置在哪裡 發布:2025-03-10 23:29:07 瀏覽:34
如何配置一套網站系統 發布:2025-03-10 23:28:53 瀏覽:93