-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.aspx.cs
More file actions
59 lines (48 loc) · 1.64 KB
/
print.aspx.cs
File metadata and controls
59 lines (48 loc) · 1.64 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using GenCode128;
namespace CoverSheetBarCode
{
public partial class print : System.Web.UI.Page
{
protected string SHEET_ID = System.Configuration.ConfigurationManager.AppSettings["SheetIdViewStateName"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
// get the sheet id
int iId = Convert.ToInt32( Session[SHEET_ID] );
// if Id is zero, do nothing
if (iId == 0)
return;
// reset the session variable
//Session[SHEET_ID] = 0;
string strId = iId.ToString("0");
// generate the bar code image
System.Drawing.Image objImage =
Code128Rendering.MakeBarcodeImage( strId, 10, true );
// create filename to save the barcode image
string strImgFile = string.Format("{0}barcodes\\{1}_{2}.png"
, HttpContext.Current.Request.PhysicalApplicationPath
, Page.User.Identity.Name.Replace( "\\", "" )
, strId);
// remove old barcode images
string[] strFiles = Directory.GetFiles(
string.Format( "{0}barcodes\\"
, HttpContext.Current.Request.PhysicalApplicationPath )
, string.Format("{0}_*.png"
, Page.User.Identity.Name.Replace( "\\", "" ) ) );
foreach( string strFile in strFiles )
File.Delete( strFile );
// save the new barcode
objImage.Save( strImgFile );
// plug the new barcode URL
imgBarCode.ImageUrl = string.Format("~\\barcodes\\{0}_{1}.png"
, Page.User.Identity.Name.Replace("\\", "")
, strId);
}
}
}