Professional Documents
Culture Documents
}
protected voidButton1_Click(objectsender, EventArgs e)
{
SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
intflag=0;
if(TextBox1.Text=="admin")
{
if (flag == 1)
{
Label6.Text = "Your password succussfuly changed";
}
else
{Label6.Text = "plz Check the id and password ";
}
28
Online Sales and Services of Hardware Management System
//amount
Int a1, b1, c1;
Int tot,tm,dm;
tm=int.Parse (TextBox8.Text);
dm=int.Parse(rd[5].ToString ());
tot=dm-tm;
//parts
31
Online Sales and Services of Hardware Management System
a1 =int.Parse(TextBox6.Text.ToString());
b1 =int.Parse(rd[3].ToString());
c1 = b1 - a1;
rd.Close();
SqlCommand com2 =new SqlCommand("update spinfo set noofparts='" +
c1.ToString() +"',tamount='" + tot.ToString() + "' where partid='" +
TextBox5.Text +"'", con);
com2.ExecuteNonQuery();
SqlCommand com3 =new SqlCommand("delete orderinfo where orname='" +
TextBox3.Text +"'", con);
com3.ExecuteNonQuery();
com.ExecuteNonQuery();
Label10.Text = "One record is added";
Response.Redirect("salesinfo.aspx");
}
rd.Close();
}
con.Close();
cler();
}
public voidcler()
{
TextBox1.Text ="";
TextBox2.Text ="";
TextBox3.Text ="";
//TextBox4.Text = "";
TextBox5.Text =""; TextBox6.Text =""; TextBox7.Text =""; TextBox8.Text ="";
}
protected voidButton1_Click(objectsender,EventArgs e)
{
cler();
string cou ="";
int num;
string str;
Label10.Text ="";
SqlConnection con =new SqlConnection("initial catalog=phani;integrated
security=yes");
SqlCommand com =new SqlCommand("select max(salid) from salseinfo",
con);
SqlCommand com1 =new SqlCommand("Select max(salid) from salseinfo",
con);
con.Open();
SqlDataAdapter ad =new SqlDataAdapter(com1);
cou = com1.ExecuteScalar().ToString();
SqlDataReader rd = com.ExecuteReader();
if (cou =="")
{
TextBox1.Text ="SA000" +"1";
}
else
{
32
Online Sales and Services of Hardware Management System
If (rd.Read())
{
str = rd[0].ToString();
str = str.Substring(2, 4);
num =Int32.Parse(str.ToString());
if (num < 9)
{
num = num + 1;
TextBox1.Text ="SA000" + num.ToString().Trim();
}
else
{
str = str.Substring(2, 2);
num =Int32.Parse(str.ToString());
num = num + 1;
TextBox1.Text ="SA00" + num.ToString();
}
}
}
con.Close();
}
protected voidTextBox2_TextChanged(objectsender,EventArgs e)
{
int flag = 0;
SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
con.Open();
SqlCommand com =new SqlCommand("select *from orderinfo where custid='"
+ TextBox2.Text +"'", con);
SqlDataReader rd = com.ExecuteReader();
while(rd.Read())
{
if (TextBox2.Text == rd[1].ToString())
{
rd.Close();
SqlCommand com1 =new SqlCommand("select partid,orderid,noofcom from
orderinfo where custid='" + TextBox2.Text + "'", con);
SqlDataAdapter ad =new SqlDataAdapter(com);
DataSet ds =new DataSet();
ad.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
flag = 1;
break;
}
else
{
flag = 0;
}
}
if (flag == 0)
{
Label10.Text = "The custmuer id does not exist in orderinformation";
}
else
{
Label10.Text = "select the any one productid and enter the specified
textfield";
} 33
Online Sales and Services of Hardware Management System
con.Close();
}
protected voidTextBox3_TextChanged(objectsender,EventArgs e)
{
SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
con.Open();
SqlCommand com =new SqlCommand("select * from orderinfo where orname='"
+ TextBox3.Text +"'", con);
SqlDataReader rd = com.ExecuteReader();
//TextBox6.Text = rd[4].ToString();
if(rd.Read())
{
TextBox5.Text = rd[2].ToString();
TextBox6.Text = rd[4].ToString();
}
con.Close();
}
protected voidButton3_Click(objectsender,EventArgs e)
{
SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
con.Open();
SqlCommand com =new SqlCommand("select * from spinfo where partid='" +
TextBox5.Text +"'", con);
SqlDataReader rd = com.ExecuteReader();
//TextBox6.Text = rd[4].ToString();
if(rd.Read())
{
TextBox7.Text = rd[4].ToString();
int a, b, c;
a=int.Parse( TextBox6.Text.ToString());
b=int.Parse (TextBox7.Text.ToString ());
c=a*b;
TextBox8.Text =c.ToString ();
}
con.Close();
}
protected voidButton5_Click(objectsender,EventArgs e)
{SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
con.Close();
SqlCommand com =new SqlCommand("delete bill", con);
try
{
com.ExecuteNonQuery();
}
catch(Exception)
{
Label10.Text = "No record is found";
}
con.Close();
}
34