using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Add_New_PO : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection scon = new SqlConnection("Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True");
SqlCommand scmd = new SqlCommand("select PO from PO_Table" , scon);
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataSet ds = new DataSet();
//DataTable dt = new DataTable();
sda.Fill(ds);
if (TextBox1.Text == ds.Tables[0].Rows[0][0].ToString())
{
Response.Write("PO already Enter");
}
else
{
SqlConnection use = new SqlConnection(" Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True ");
SqlDataAdapter da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand("insert into PO_Table values (@PO, @Style_Ref, @Price, @Season, @Order_Qty, @PO_Ship_Date, @PO_Shipping_Month, @PO_Shipping_Mode, @PO_Value, @PO_Destination)", use);
da.InsertCommand.Parameters.Add("@PO", SqlDbType.Int).Value = TextBox1.Text;
da.InsertCommand.Parameters.Add("@Style_Ref", SqlDbType.NVarChar).Value = TextBox2.Text;
da.InsertCommand.Parameters.Add("@PO_Destination", SqlDbType.NVarChar).Value = DropDownList3.Text;
da.InsertCommand.Parameters.Add("@Price", SqlDbType.Money).Value = TextBox3.Text;
da.InsertCommand.Parameters.Add("@Season", SqlDbType.NVarChar).Value = DropDownList2.Text;
da.InsertCommand.Parameters.Add("@Order_Qty", SqlDbType.Int).Value = TextBox4.Text;
da.InsertCommand.Parameters.Add("@PO_Ship_Date", SqlDbType.DateTime).Value = TextBox5.Text;
da.InsertCommand.Parameters.Add("@PO_Shipping_Month", SqlDbType.Char).Value = TextBox6.Text;
da.InsertCommand.Parameters.Add("@PO_Shipping_Mode", SqlDbType.Char).Value = TextBox7.Text;
da.InsertCommand.Parameters.Add("@PO_Value", SqlDbType.Int).Value = TextBox8.Text;
use.Open();
da.InsertCommand.ExecuteNonQuery();
use.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
scon.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection scon = new SqlConnection("Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True");
SqlCommand scmd = new SqlCommand("select * from PO_Table", scon);
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (TextBox1.Text == dt.Rows[0][0].ToString())
{
TextBox1.Text = dt.Rows[0][0].ToString();
TextBox2.Text = dt.Rows[0][1].ToString();
TextBox3.Text = dt.Rows[0][2].ToString();
TextBox4.Text = dt.Rows[0][4].ToString();
TextBox5.Text = dt.Rows[0][5].ToString();
TextBox6.Text = dt.Rows[0][6].ToString();
TextBox7.Text = dt.Rows[0][7].ToString();
TextBox8.Text = dt.Rows[0][8].ToString();
DropDownList2.Text = dt.Rows[0][3].ToString();
DropDownList3.Text = dt.Rows[0][9].ToString();
}
else
{
Response.Write("PO Not Found");
}
scon.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
SqlConnection use = new SqlConnection(" Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True ");
SqlDataAdapter da = new SqlDataAdapter();
da.UpdateCommand = new SqlCommand("update PO_Table set PO=@PO, Style_Ref=@Style_Ref, Price=@Price, Season=@Season, Order_Qty=@Order_Qty, PO_Ship_Date=@PO_Ship_Date, PO_Shipping_Month=@PO_Shipping_Month, PO_Shipping_Mode=@PO_Shipping_Mode, PO_Value=@PO_Value, PO_Destination=@PO_Destination where PO=@PO", use);
da.UpdateCommand.Parameters.Add("@PO", SqlDbType.Int).Value = TextBox1.Text;
da.UpdateCommand.Parameters.Add("@Style_Ref", SqlDbType.NVarChar).Value = TextBox2.Text;
da.UpdateCommand.Parameters.Add("@PO_Destination", SqlDbType.NVarChar).Value = DropDownList3.Text;
da.UpdateCommand.Parameters.Add("@Price", SqlDbType.Money).Value = TextBox3.Text;
da.UpdateCommand.Parameters.Add("@Season", SqlDbType.NVarChar).Value = DropDownList2.Text;
da.UpdateCommand.Parameters.Add("@Order_Qty", SqlDbType.Int).Value = TextBox4.Text;
da.UpdateCommand.Parameters.Add("@PO_Ship_Date", SqlDbType.DateTime).Value = TextBox5.Text;
da.UpdateCommand.Parameters.Add("@PO_Shipping_Month", SqlDbType.Char).Value = TextBox6.Text;
da.UpdateCommand.Parameters.Add("@PO_Shipping_Mode", SqlDbType.Char).Value = TextBox7.Text;
da.UpdateCommand.Parameters.Add("@PO_Value", SqlDbType.Int).Value = TextBox8.Text;
use.Open();
da.UpdateCommand.ExecuteNonQuery();
use.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
protected void Button5_Click(object sender, EventArgs e)
{
SqlConnection use = new SqlConnection(" Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True ");
SqlDataAdapter da = new SqlDataAdapter();
da.DeleteCommand = new SqlCommand("delete from PO_Table where PO=@PO", use);
da.DeleteCommand.Parameters.Add("@PO", SqlDbType.Int).Value = TextBox1.Text;
da.DeleteCommand.Parameters.Add("@Style_Ref", SqlDbType.NVarChar).Value = TextBox2.Text;
da.DeleteCommand.Parameters.Add("@PO_Destination", SqlDbType.NVarChar).Value = DropDownList3.Text;
da.DeleteCommand.Parameters.Add("@Price", SqlDbType.Money).Value = TextBox3.Text;
da.DeleteCommand.Parameters.Add("@Season", SqlDbType.NVarChar).Value = DropDownList2.Text;
da.DeleteCommand.Parameters.Add("@Order_Qty", SqlDbType.Int).Value = TextBox4.Text;
da.DeleteCommand.Parameters.Add("@PO_Ship_Date", SqlDbType.DateTime).Value = TextBox5.Text;
da.DeleteCommand.Parameters.Add("@PO_Shipping_Month", SqlDbType.Char).Value = TextBox6.Text;
da.DeleteCommand.Parameters.Add("@PO_Shipping_Mode", SqlDbType.Char).Value = TextBox7.Text;
da.DeleteCommand.Parameters.Add("@PO_Value", SqlDbType.Int).Value = TextBox8.Text;
use.Open();
da.DeleteCommand.ExecuteNonQuery();
use.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Add_New_PO : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection scon = new SqlConnection("Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True");
SqlCommand scmd = new SqlCommand("select PO from PO_Table" , scon);
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataSet ds = new DataSet();
//DataTable dt = new DataTable();
sda.Fill(ds);
if (TextBox1.Text == ds.Tables[0].Rows[0][0].ToString())
{
Response.Write("PO already Enter");
}
else
{
SqlConnection use = new SqlConnection(" Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True ");
SqlDataAdapter da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand("insert into PO_Table values (@PO, @Style_Ref, @Price, @Season, @Order_Qty, @PO_Ship_Date, @PO_Shipping_Month, @PO_Shipping_Mode, @PO_Value, @PO_Destination)", use);
da.InsertCommand.Parameters.Add("@PO", SqlDbType.Int).Value = TextBox1.Text;
da.InsertCommand.Parameters.Add("@Style_Ref", SqlDbType.NVarChar).Value = TextBox2.Text;
da.InsertCommand.Parameters.Add("@PO_Destination", SqlDbType.NVarChar).Value = DropDownList3.Text;
da.InsertCommand.Parameters.Add("@Price", SqlDbType.Money).Value = TextBox3.Text;
da.InsertCommand.Parameters.Add("@Season", SqlDbType.NVarChar).Value = DropDownList2.Text;
da.InsertCommand.Parameters.Add("@Order_Qty", SqlDbType.Int).Value = TextBox4.Text;
da.InsertCommand.Parameters.Add("@PO_Ship_Date", SqlDbType.DateTime).Value = TextBox5.Text;
da.InsertCommand.Parameters.Add("@PO_Shipping_Month", SqlDbType.Char).Value = TextBox6.Text;
da.InsertCommand.Parameters.Add("@PO_Shipping_Mode", SqlDbType.Char).Value = TextBox7.Text;
da.InsertCommand.Parameters.Add("@PO_Value", SqlDbType.Int).Value = TextBox8.Text;
use.Open();
da.InsertCommand.ExecuteNonQuery();
use.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
scon.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection scon = new SqlConnection("Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True");
SqlCommand scmd = new SqlCommand("select * from PO_Table", scon);
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (TextBox1.Text == dt.Rows[0][0].ToString())
{
TextBox1.Text = dt.Rows[0][0].ToString();
TextBox2.Text = dt.Rows[0][1].ToString();
TextBox3.Text = dt.Rows[0][2].ToString();
TextBox4.Text = dt.Rows[0][4].ToString();
TextBox5.Text = dt.Rows[0][5].ToString();
TextBox6.Text = dt.Rows[0][6].ToString();
TextBox7.Text = dt.Rows[0][7].ToString();
TextBox8.Text = dt.Rows[0][8].ToString();
DropDownList2.Text = dt.Rows[0][3].ToString();
DropDownList3.Text = dt.Rows[0][9].ToString();
}
else
{
Response.Write("PO Not Found");
}
scon.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
SqlConnection use = new SqlConnection(" Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True ");
SqlDataAdapter da = new SqlDataAdapter();
da.UpdateCommand = new SqlCommand("update PO_Table set PO=@PO, Style_Ref=@Style_Ref, Price=@Price, Season=@Season, Order_Qty=@Order_Qty, PO_Ship_Date=@PO_Ship_Date, PO_Shipping_Month=@PO_Shipping_Month, PO_Shipping_Mode=@PO_Shipping_Mode, PO_Value=@PO_Value, PO_Destination=@PO_Destination where PO=@PO", use);
da.UpdateCommand.Parameters.Add("@PO", SqlDbType.Int).Value = TextBox1.Text;
da.UpdateCommand.Parameters.Add("@Style_Ref", SqlDbType.NVarChar).Value = TextBox2.Text;
da.UpdateCommand.Parameters.Add("@PO_Destination", SqlDbType.NVarChar).Value = DropDownList3.Text;
da.UpdateCommand.Parameters.Add("@Price", SqlDbType.Money).Value = TextBox3.Text;
da.UpdateCommand.Parameters.Add("@Season", SqlDbType.NVarChar).Value = DropDownList2.Text;
da.UpdateCommand.Parameters.Add("@Order_Qty", SqlDbType.Int).Value = TextBox4.Text;
da.UpdateCommand.Parameters.Add("@PO_Ship_Date", SqlDbType.DateTime).Value = TextBox5.Text;
da.UpdateCommand.Parameters.Add("@PO_Shipping_Month", SqlDbType.Char).Value = TextBox6.Text;
da.UpdateCommand.Parameters.Add("@PO_Shipping_Mode", SqlDbType.Char).Value = TextBox7.Text;
da.UpdateCommand.Parameters.Add("@PO_Value", SqlDbType.Int).Value = TextBox8.Text;
use.Open();
da.UpdateCommand.ExecuteNonQuery();
use.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
protected void Button5_Click(object sender, EventArgs e)
{
SqlConnection use = new SqlConnection(" Data Source=Tahir-PC;Initial Catalog=Shipping;Integrated Security=True ");
SqlDataAdapter da = new SqlDataAdapter();
da.DeleteCommand = new SqlCommand("delete from PO_Table where PO=@PO", use);
da.DeleteCommand.Parameters.Add("@PO", SqlDbType.Int).Value = TextBox1.Text;
da.DeleteCommand.Parameters.Add("@Style_Ref", SqlDbType.NVarChar).Value = TextBox2.Text;
da.DeleteCommand.Parameters.Add("@PO_Destination", SqlDbType.NVarChar).Value = DropDownList3.Text;
da.DeleteCommand.Parameters.Add("@Price", SqlDbType.Money).Value = TextBox3.Text;
da.DeleteCommand.Parameters.Add("@Season", SqlDbType.NVarChar).Value = DropDownList2.Text;
da.DeleteCommand.Parameters.Add("@Order_Qty", SqlDbType.Int).Value = TextBox4.Text;
da.DeleteCommand.Parameters.Add("@PO_Ship_Date", SqlDbType.DateTime).Value = TextBox5.Text;
da.DeleteCommand.Parameters.Add("@PO_Shipping_Month", SqlDbType.Char).Value = TextBox6.Text;
da.DeleteCommand.Parameters.Add("@PO_Shipping_Mode", SqlDbType.Char).Value = TextBox7.Text;
da.DeleteCommand.Parameters.Add("@PO_Value", SqlDbType.Int).Value = TextBox8.Text;
use.Open();
da.DeleteCommand.ExecuteNonQuery();
use.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
}
No comments:
Post a Comment