Professional Documents
Culture Documents
Code Project2 1
Code Project2 1
Code Project2 1
cs 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Net;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
BarcodeLib.Barcode b = new BarcodeLib.Barcode();
string barcodeImage;
string dt = "";
string imageSavePath = Application.StartupPath + "/bar/";
public Form2()
{
InitializeComponent();
}
void clear()
{
textBoxDesc.Text = textBox1.Text = textBox2.Text = textBoxPname.Text = "";
createBarCode();
byte[] mydata;
FileInfo finfo = new FileInfo(imageSavePath+barcodeImage);
long numbyte = finfo.Length;
FileStream fstream = new FileStream(imageSavePath+barcodeImage, FileMode.Open,
FileAccess.Read);
BinaryReader breader = new BinaryReader(fstream);
mydata = breader.ReadBytes(Convert.ToInt32(numbyte));
str="insert into product(name,price,manufacturer,description,img) values ('"+
textBoxPname.Text+"','"+textBox1.Text+"','"+textBox2.Text+"','"+textBoxDesc.Text+"',@img)
";
con.Open();
cmd.Connection = con;
cmd.CommandText = str;
cmd.Parameters.Add(new SqlParameter("@img", (object)mydata));
cmd.ExecuteNonQuery();
con.Close();
C:\Users\shiva\OneDrive\Documents\Visual ... Generator\WindowsFormsApplication1\Form2.cs 2
clear();
label2.Visible = true;
int w = Convert.ToInt32(300);
int h = Convert.ToInt32(50);
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
b.IncludeLabel = true;
pictureBox1.Image = b.Encode(type, dt.Trim(), this.b.ForeColor, this.b.
BackColor, w, h);
pictureBox1.Width = pictureBox1.Image.Width;
pictureBox1.Height = pictureBox1.Image.Height;
pictureBox1.Image.Save(imageSavePath + barcodeImage);
}
}