protected void ImageButton5_Click(object sender, ImageClickEventArgs e) { connection(); amicassaCon.Open(); SqlCommand cmd = new SqlCommand("SELECT MAX(CAST(order_no as INT)) FROM checklists WHERE checklist_name='"+DropDownList2.SelectedValue+"'", amicassaCon); SqlDataReader dr = cmd.ExecuteReader(); string a = ""; //Order Number Generation for Checklist while (dr.Read()) { if (dr[0].ToString() == "" || dr[0].ToString() == null) { a = "1"; } else { if (dr[0].ToString() == "1") { a = Convert.ToString(Convert.ToInt32(dr[0].ToString()) + 9); } else { a = Convert.ToString(Convert.ToInt32(dr[0].ToString()) + 10); } } } dr.Close(); // Generating Checklist Code string dr_cmdcode_get = ""; SqlCommand cmdcode = new SqlCommand("SELECT milestone_code FROM milestones WHERE milestone_name='" + dd1.SelectedValue + "'", amicassaCon); SqlDataReader dr_cmdcode = cmdcode.ExecuteReader(); while (dr_cmdcode.Read()) { dr_cmdcode_get = dr_cmdcode[0].ToString(); //dr_cmdord_no = dr_cmdcode[1].ToString(); } dr_cmdcode.Close(); checklistCode = dr_cmdcode_get + '-' + a; SqlCommand apdate = new SqlCommand("UPDATE checklists SET milestone_name='" + dd1.SelectedValue + "', checklist_code='" + checklistCode + "' WHERE checklist_name='" + DropDownList2.SelectedValue + "'", amicassaCon); SqlDataReader aps = apdate.ExecuteReader(); aps.Close(); SqlCommand cmd2 = new SqlCommand("SELECT MAX(CAST(order_no as INT)) FROM activities WHERE checklist_name = '" + dpdchecklist_activity_add.SelectedValue + "'", amicassaCon); SqlDataReader dr2 = cmd2.ExecuteReader(); string b = ""; //Order Number for Activity while (dr2.Read()) { if (dr2[0].ToString() == "" || dr2[0].ToString() == null) { b = "1"; } else { if (dr2[0].ToString() == "1") { b = Convert.ToString(Convert.ToInt32(dr2[0].ToString()) + 9); } else { b = Convert.ToString(Convert.ToInt32(dr2[0].ToString()) + 10); } } } dr2.Close(); //Generating Activity Code string cget = ""; SqlCommand cmdd = new SqlCommand("SELECT checklist_code FROM checklists WHERE checklist_name='" + DropDownList2.SelectedValue + "'", amicassaCon); SqlDataReader drcode = cmdd.ExecuteReader(); while (drcode.Read()) { cget = drcode[0].ToString(); //dr_cmdord_no = dr_cmdcode[1].ToString(); } drcode.Close(); actCode = cget + '-' + b; SqlCommand actC = new SqlCommand("UPDATE activities SET milestone_name='" + dd1.SelectedValue + "', activity_code='" + actCode + "' WHERE checklist_name='" + DropDownList2.SelectedValue + "'", amicassaCon); SqlDataReader apss = actC.ExecuteReader(); drcode.Close(); amicassaCon.Close(); }
SqlDataReader apss = actC.ExecuteReader();
ExecuteNonQuery()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)