SqlCommand cmd; SqlDataReader dr; private string s; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlComplaint.Items.Insert(0, new ListItem("---Select---", "---Select---")); FillDropDownList(); ddlAllow.Items.Insert(0, new ListItem("---Select---", "---Select---")); FillTechnicianDropDownList(); } } // Fill Dropdownlist public void FillDropDownList() { s = WebConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString; con = new SqlConnection(s); con.Open(); cmd = new SqlCommand("Select Complaint_no from Call_Reg where Status='Open'" , con); dr = cmd.ExecuteReader(); while (dr.Read()) { ddlComplaint.Items.Add(dr[0].ToString()); } dr.Close(); con.Close(); } // Show data in GridView protected void btnSearch_Click(object sender, EventArgs e) { s = WebConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString; con = new SqlConnection(s); con.Open(); cmd = new SqlCommand("Select * from Call_Reg where Complaint_no='" + ddlComplaint.SelectedItem.ToString() + "'", con); dr = cmd.ExecuteReader(); GridView2.DataSource = dr; GridView2.DataBind(); dr.Close(); con.Close(); } // Fill Technician public void FillTechnicianDropDownList() { s = WebConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString; con = new SqlConnection(s); con.Open(); cmd = new SqlCommand("Select Fname from New_Tech", con); dr = cmd.ExecuteReader(); while (dr.Read()) { ddlAllow.Items.Add(dr[0].ToString()); } dr.Close(); con.Close(); } protected void btnAllo_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("SERVER=KSHITIJA-PC; Initial Catalog=CRM;Integrated Security=True"); //SqlCommand cmd = new SqlCommand("Update Call_reg set status='Assigned' Where Complaint_no= '" + ddlComplaint.SelectedItem.ToString() + "'", con); SqlCommand cmd = new SqlCommand(" insert into Call_Allocation values( "", con); try { con.Open(); int i = cmd.ExecuteNonQuery(); //int a = cmd1.ExecuteNonQuery(); if (i == 1) { ddlComplaint.SelectedItem.Text = ""; EO.Web.MsgBoxButton mb = new EO.Web.MsgBoxButton("OK"); MsgBox1.Show("Message: ", "Call Assigned to Technician", null, mb); } } catch (Exception ex) { EO.Web.MsgBoxButton mb = new EO.Web.MsgBoxButton("OK"); MsgBox1.Show("Error: ", ex.Message, null, mb); } con.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)