You are on page 1of 14

Online Sales and Services of Hardware Management System

}
protected voidButton1_Click(objectsender, EventArgs e)
{
SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
intflag=0;
if(TextBox1.Text=="admin")
{

SqlCommand com =new SqlCommand("select * from admin", con);


con.Open();
SqlDataReader rd = com.ExecuteReader();
if(rd.Read())
{
if ((TextBox1.Text.Trim() == rd[0].ToString()) && (TextBox2.Text.Trim()
== rd[1].ToString()))
{
rd.Close();
SqlCommand com1 =new SqlCommand("update admin set
password='"+TextBox3.Text+"' where id='"+TextBox1.Text+"'",con);
com1.ExecuteNonQuery();
Label6.Text = "Your password succussfuly changed";
}
else
{
Label6.Text = "plz Check the id and password ";
}
}
}
else
{
SqlCommand com2 =new SqlCommand("select userid,password1 from
userinfo", con);
con.Open();
SqlDataReader rd1 = com2.ExecuteReader();
while(rd1.Read())
{
if ((TextBox1.Text.ToString() == rd1[0].ToString()) &&
(TextBox2.Text.ToString() == rd1[1].ToString()))
{
rd1.Close();
SqlCommand com3=new SqlCommand ("update userinfo set
password1='"+TextBox3.Text+"',password2='"+TextBox4.Text+"' where
userid='"+TextBox1.Text+"'",con);
com3.ExecuteNonQuery();
flag=1;
break;
}
}

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

protected voidLinkButton1_Click(object sender, EventArgs e)


{
// Panel3.Visible = false;
}
protected voidButton3_Click(objectsender,EventArgs e)
{
GridView1.Visible=true;
}
Form3
Public partial class Salesinfo : System.Web.UI.Page
{
protected voidPage_Load(objectsender,EventArgs e)
{
TextBox4.Text =DateTime.Today.ToShortDateString();
TextBox8.Enabled =false;
//Label11.Text ="WELCOME:"+" "+Session["id"].ToString() ;
}
protected voidButton2_Click(objectsender,EventArgs e)
{
Label11.Text ="";
//int a, b, c;
//a = int.Parse(TextBox6.Text.ToString());
//b = int.Parse(TextBox7.Text.ToString());
//c = a * b;
//TextBox8.Text = c.ToString();
SqlConnection con =new SqlConnection("Initial Catalog=phani;integrated
security=yes");
con.Open();
SqlCommand com4 =new SqlCommand("select * from spinfo where partid='" +
TextBox5.Text +"'", con);
SqlDataReader rd = com4.ExecuteReader();
//string s=rd[3].ToString ();
if(rd.Read())
{
Int n = int .Parse(rd[3].ToString ());
Int n1=int .Parse (TextBox6.Text);
if(n<n1)
{
Label10.Text = "Sorry we have"+" " +rd[3].ToString()+" " +"Items plz
refill the spareparts";
}
else
{

SqlCommand com =new SqlCommand("insert into salseinfo values('" +


TextBox1.Text +"','" + TextBox2.Text +"','" + TextBox3.Text +"','" +
TextBox4.Text +"','" + TextBox5.Text +"','" + TextBox6.Text +"','" +
TextBox7.Text +"','" + TextBox8.Text +"')", con);

//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

You might also like