public ActionResult InsertAppointeesFormData(AppointeesModel AM) { ViewBag.collapse = "true"; // check type string typ = ""; con.Open(); string qq1 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa = new SqlDataAdapter(qq1, con); DataTable dtt = new DataTable(); daa.Fill(dtt); con.Close(); if (dtt.Rows.Count > 0) { typ = dtt.Rows[0]["Type"].ToString(); } //end if (typ == "Testator") { // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.showtitle = "true"; ViewBag.documentlink = "true"; } // roleassignment List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); //end AM.documentId = 0; int appid = 0; // latest appointees int apid = 0; if (Session["doctype"].ToString() == "Will") { con.Open(); SqlCommand cmd = new SqlCommand("SP_CRUDAppointees", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@condition", "insert"); cmd.Parameters.AddWithValue("@documentId", AM.documentId); cmd.Parameters.AddWithValue("@Type", AM.Typetxt); cmd.Parameters.AddWithValue("@subType", AM.subTypetxt); cmd.Parameters.AddWithValue("@Name", AM.Name); cmd.Parameters.AddWithValue("@middleName", AM.middleName); cmd.Parameters.AddWithValue("@Surname", AM.Surname); cmd.Parameters.AddWithValue("@Identity_proof", AM.Identity_Proof); cmd.Parameters.AddWithValue("@Identity_proof_value", AM.Identity_Proof_Value); cmd.Parameters.AddWithValue("@Alt_Identity_proof", AM.Alt_Identity_Proof); cmd.Parameters.AddWithValue("@Alt_Identity_proof_value", AM.Alt_Identity_Proof_Value); DateTime dat = DateTime.ParseExact(AM.Dob, "dd-MM-yyyy", CultureInfo.InvariantCulture); cmd.Parameters.AddWithValue("@DOB", dat); cmd.Parameters.AddWithValue("@Gender", AM.Gender); cmd.Parameters.AddWithValue("@Occupation", AM.Occupation); cmd.Parameters.AddWithValue("@Relationship", AM.RelationshipTxt); cmd.Parameters.AddWithValue("@Address1", AM.Address1); if (AM.Address2 != null || AM.Address2 == "") { cmd.Parameters.AddWithValue("@Address2", AM.Address2); } else { AM.Address2 = "None"; cmd.Parameters.AddWithValue("@Address2", AM.Address2); } if (AM.Address3 != null || AM.Address3 == "") { cmd.Parameters.AddWithValue("@Address3", AM.Address3); } else { AM.Address3 = "None"; cmd.Parameters.AddWithValue("@Address3", AM.Address3); } cmd.Parameters.AddWithValue("@City", AM.citytext); cmd.Parameters.AddWithValue("@State", AM.statetext); cmd.Parameters.AddWithValue("@Pin", AM.Pin); cmd.Parameters.AddWithValue("@tid", AM.ddltid); cmd.ExecuteNonQuery(); con.Close(); con.Open(); string query = "select top 1 * from Appointees order by apId desc"; SqlDataAdapter da2 = new SqlDataAdapter(query, con); DataTable dt2 = new DataTable(); da2.Fill(dt2); if (dt2.Rows.Count > 0) { appid = Convert.ToInt32(dt2.Rows[0]["apId"]); apid = 1; // for yes } else { apid = 2; //for no } con.Close(); //end con.Open(); string qt = "update Appointees set doctype = 'Will' where apId = " + Convert.ToInt32(dt2.Rows[0]["apId"]) + ""; SqlCommand cmdt = new SqlCommand(qt, con); cmdt.ExecuteNonQuery(); con.Close(); } if (Session["doctype"].ToString() == "POA") { con.Open(); SqlCommand cmd = new SqlCommand("SP_CRUDAppointees", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@condition", "insert"); cmd.Parameters.AddWithValue("@documentId", AM.documentId); cmd.Parameters.AddWithValue("@Type", AM.Typetxt); cmd.Parameters.AddWithValue("@subType", AM.subTypetxt); cmd.Parameters.AddWithValue("@Name", AM.Name); cmd.Parameters.AddWithValue("@middleName", AM.middleName); cmd.Parameters.AddWithValue("@Surname", AM.Surname); cmd.Parameters.AddWithValue("@Identity_proof", AM.Identity_Proof); cmd.Parameters.AddWithValue("@Identity_proof_value", AM.Identity_Proof_Value); cmd.Parameters.AddWithValue("@Alt_Identity_proof", AM.Alt_Identity_Proof); cmd.Parameters.AddWithValue("@Alt_Identity_proof_value", AM.Alt_Identity_Proof_Value); DateTime dat = DateTime.ParseExact(AM.Dob, "dd-MM-yyyy", CultureInfo.InvariantCulture); cmd.Parameters.AddWithValue("@DOB", dat); cmd.Parameters.AddWithValue("@Gender", AM.Gender); cmd.Parameters.AddWithValue("@Occupation", AM.Occupation); cmd.Parameters.AddWithValue("@Relationship", AM.RelationshipTxt); cmd.Parameters.AddWithValue("@Address1", AM.Address1); if (AM.Address2 != null || AM.Address2 == "") { cmd.Parameters.AddWithValue("@Address2", AM.Address2); } else { AM.Address2 = "None"; cmd.Parameters.AddWithValue("@Address2", AM.Address2); } if (AM.Address3 != null || AM.Address3 == "") { cmd.Parameters.AddWithValue("@Address3", AM.Address3); } else { AM.Address3 = "None"; cmd.Parameters.AddWithValue("@Address3", AM.Address3); } cmd.Parameters.AddWithValue("@City", AM.citytext); cmd.Parameters.AddWithValue("@State", AM.statetext); cmd.Parameters.AddWithValue("@Pin", AM.Pin); cmd.Parameters.AddWithValue("@tid", AM.ddltid); cmd.ExecuteNonQuery(); con.Close(); con.Open(); string query = "select top 1 * from Appointees order by apId desc"; SqlDataAdapter da2 = new SqlDataAdapter(query, con); DataTable dt2 = new DataTable(); da2.Fill(dt2); if (dt2.Rows.Count > 0) { appid = Convert.ToInt32(dt2.Rows[0]["apId"]); apid = 1; // for yes } else { apid = 2; //for no } con.Close(); //end con.Open(); string qt = "update Appointees set doctype = 'POA' where apId = " + apid + ""; SqlCommand cmdt = new SqlCommand(qt, con); cmdt.ExecuteNonQuery(); con.Close(); } if (Session["doctype"].ToString() == "Giftdeeds") { con.Open(); SqlCommand cmd = new SqlCommand("SP_CRUDAppointees", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@condition", "insert"); cmd.Parameters.AddWithValue("@documentId", AM.documentId); cmd.Parameters.AddWithValue("@Type", AM.Typetxt); cmd.Parameters.AddWithValue("@subType", AM.subTypetxt); cmd.Parameters.AddWithValue("@Name", AM.Name); cmd.Parameters.AddWithValue("@middleName", AM.middleName); cmd.Parameters.AddWithValue("@Surname", AM.Surname); cmd.Parameters.AddWithValue("@Identity_proof", AM.Identity_Proof); cmd.Parameters.AddWithValue("@Identity_proof_value", AM.Identity_Proof_Value); cmd.Parameters.AddWithValue("@Alt_Identity_proof", AM.Alt_Identity_Proof); cmd.Parameters.AddWithValue("@Alt_Identity_proof_value", AM.Alt_Identity_Proof_Value); DateTime dat = DateTime.ParseExact(AM.Dob, "dd-MM-yyyy", CultureInfo.InvariantCulture); cmd.Parameters.AddWithValue("@DOB", dat); cmd.Parameters.AddWithValue("@Gender", AM.Gender); cmd.Parameters.AddWithValue("@Occupation", AM.Occupation); cmd.Parameters.AddWithValue("@Relationship", AM.RelationshipTxt); cmd.Parameters.AddWithValue("@Address1", AM.Address1); if (AM.Address2 != null || AM.Address2 == "") { cmd.Parameters.AddWithValue("@Address2", AM.Address2); } else { AM.Address2 = "None"; cmd.Parameters.AddWithValue("@Address2", AM.Address2); } if (AM.Address3 != null || AM.Address3 == "") { cmd.Parameters.AddWithValue("@Address3", AM.Address3); } else { AM.Address3 = "None"; cmd.Parameters.AddWithValue("@Address3", AM.Address3); } cmd.Parameters.AddWithValue("@City", AM.citytext); cmd.Parameters.AddWithValue("@State", AM.statetext); cmd.Parameters.AddWithValue("@Pin", AM.Pin); cmd.Parameters.AddWithValue("@tid", AM.ddltid); cmd.ExecuteNonQuery(); con.Close(); con.Open(); string query = "select top 1 * from Appointees order by apId desc"; SqlDataAdapter da2 = new SqlDataAdapter(query, con); DataTable dt2 = new DataTable(); da2.Fill(dt2); if (dt2.Rows.Count > 0) { appid = Convert.ToInt32(dt2.Rows[0]["apId"]); apid = 1; // for yes } else { apid = 2; //for no } con.Close(); //end con.Open(); string qt = "update Appointees set doctype = 'Giftdeeds' where apId = " + apid + ""; SqlCommand cmdt = new SqlCommand(qt, con); cmdt.ExecuteNonQuery(); con.Close(); } // dropdown selection int AppointmentofGuardian = 0; if (AM.Typetxt == "Guardian") { AppointmentofGuardian = 1; //yes } else { AppointmentofGuardian = 2; // no } int Numberofexecutors = 0; if (AM.subTypetxt == "Single") { Numberofexecutors = 1; } if (AM.subTypetxt == "Many Joint") { Numberofexecutors = 2; } if (AM.subTypetxt == "Many Independent") { Numberofexecutors = 3; } //end // Document Rules //get latest id first con.Open(); string getquery = "select top 1 * from documentRules order by wdId desc"; SqlDataAdapter da = new SqlDataAdapter(getquery, con); DataTable dt = new DataTable(); da.Fill(dt); int getruleid = 0; if (dt.Rows.Count > 0) { getruleid = Convert.ToInt32(dt.Rows[0]["wdId"]); } con.Close(); //end con.Open(); string rulequery = "update documentRules set guardian = " + AppointmentofGuardian + " ,executors_category = " + Numberofexecutors + " where tid = " + AM.ddltid + " "; SqlCommand cmd2 = new SqlCommand(rulequery, con); cmd2.ExecuteNonQuery(); con.Close(); //end if (AM.check == "true") { // alternate appointees con.Open(); SqlCommand cmdd = new SqlCommand("SP_CRUDAlternateAppointees", con); cmdd.CommandType = CommandType.StoredProcedure; cmdd.Parameters.AddWithValue("@condition", "insert"); if (appid != 0) { cmdd.Parameters.AddWithValue("@apId", appid); } else { appid = 0; cmdd.Parameters.AddWithValue("@apId", appid); } cmdd.Parameters.AddWithValue("@Name", AM.altName); cmdd.Parameters.AddWithValue("@middleName", AM.altmiddleName); cmdd.Parameters.AddWithValue("@Surname", AM.altSurname); cmdd.Parameters.AddWithValue("@Identity_proof", AM.altIdentity_Proof); cmdd.Parameters.AddWithValue("@Identity_proof_value", AM.altIdentity_Proof_Value); cmdd.Parameters.AddWithValue("@Alt_Identity_proof", AM.altAlt_Identity_Proof); cmdd.Parameters.AddWithValue("@Alt_Identity_proof_value", AM.altAlt_Identity_Proof_Value); DateTime dat2 = DateTime.ParseExact(AM.altDob, "dd-MM-yyyy", CultureInfo.InvariantCulture); cmdd.Parameters.AddWithValue("@DOB", dat2); cmdd.Parameters.AddWithValue("@Gender", AM.altGender); cmdd.Parameters.AddWithValue("@Occupation", AM.altOccupation); cmdd.Parameters.AddWithValue("@Relationship", AM.altRelationshipTxt); cmdd.Parameters.AddWithValue("@Address1", AM.altAddress1); if (AM.altAddress2 != null || AM.altAddress2 == "") { cmdd.Parameters.AddWithValue("@Address2", AM.altAddress2); } else { AM.altAddress2 = "None"; cmdd.Parameters.AddWithValue("@Address2", AM.altAddress2); } if (AM.altAddress3 != null || AM.altAddress3 == "") { cmdd.Parameters.AddWithValue("@Address3", AM.altAddress3); } else { AM.altAddress3 = "None"; cmdd.Parameters.AddWithValue("@Address3", AM.altAddress3); } cmdd.Parameters.AddWithValue("@City", AM.altcitytext); cmdd.Parameters.AddWithValue("@State", AM.altstatetext); cmdd.Parameters.AddWithValue("@Pin", AM.altPin); cmdd.Parameters.AddWithValue("@tid", AM.ddltid); cmdd.Parameters.AddWithValue("@altguardian", AM.altguardian); if (AM.altexecutor != null) { cmdd.Parameters.AddWithValue("@altexecutor", AM.altexecutor); } else { AM.altexecutor = "None"; cmdd.Parameters.AddWithValue("@altexecutor", AM.altexecutor); } cmdd.ExecuteNonQuery(); con.Close(); //end } ViewBag.Message = "Verified"; // latest appointees int altapid = 0; con.Open(); string query4 = "select top 1 * from alternate_Appointees order by apId desc"; SqlDataAdapter da4 = new SqlDataAdapter(query4, con); DataTable dt4 = new DataTable(); da4.Fill(dt4); if (dt4.Rows.Count > 0) { altapid = 1; // for yes } else { altapid = 2; //for no } con.Close(); //end // dropdown selection int AppointmentofaltGuardian = 0; if (AM.altguardian == "Guardian") { AppointmentofaltGuardian = 1; //yes } else { AppointmentofaltGuardian = 2; // no } int altNumberofexecutors = 2; if (AM.altexecutor == "Single") { altNumberofexecutors = 1; } if (AM.altexecutor == "Many Joint") { altNumberofexecutors = 1; } if (AM.altexecutor == "Many Independent") { altNumberofexecutors = 1; } //end // Document Rules //get latest id first con.Open(); string getquery4 = "select top 1 * from documentRules order by wdId desc"; SqlDataAdapter da5 = new SqlDataAdapter(getquery4, con); DataTable dt5 = new DataTable(); da5.Fill(dt5); int getruleid2 = 0; if (dt.Rows.Count > 0) { getruleid2 = Convert.ToInt32(dt5.Rows[0]["wdId"]); } con.Close(); //end con.Open(); string rulequery2 = "update documentRules set AlternateGaurdian = " + AppointmentofaltGuardian + " , AlternateExecutors = " + altNumberofexecutors + " where tid = " + AM.ddltid + " "; SqlCommand cmd6 = new SqlCommand(rulequery2, con); cmd6.ExecuteNonQuery(); con.Close(); //end // update document master with latest rule id con.Open(); string rquery2 = "update documentMaster set wdId = " + getruleid2 + " where tId = " + AM.ddltid + " "; SqlCommand rcmd2 = new SqlCommand(rquery2, con); rcmd2.ExecuteNonQuery(); con.Close(); //end ModelState.Clear(); return(View("/Views/AddAppointees/AddAppointeesPageContent.cshtml")); }
public ActionResult UpdatingAppointeesFormData(AppointeesModel AM) { // check type string typ5 = ""; con.Open(); string qq15 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa5 = new SqlDataAdapter(qq15, con); DataTable dtt5 = new DataTable(); daa5.Fill(dtt5); con.Close(); if (dtt5.Rows.Count > 0) { typ5 = dtt5.Rows[0]["Type"].ToString(); } //end if (typ5 == "Testator") { // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.documentlink = "true"; } // roleassignment List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); //end AM.documentId = 0; con.Open(); SqlCommand cmd = new SqlCommand("SP_CRUDAppointees", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@condition", "update"); cmd.Parameters.AddWithValue("@apId", AM.apId); cmd.Parameters.AddWithValue("@documentId", AM.documentId); cmd.Parameters.AddWithValue("@Type", AM.Typetxt); cmd.Parameters.AddWithValue("@subType", AM.subTypetxt); cmd.Parameters.AddWithValue("@Name", AM.Name); cmd.Parameters.AddWithValue("@middleName", AM.middleName); cmd.Parameters.AddWithValue("@Surname", AM.Surname); cmd.Parameters.AddWithValue("@Identity_proof", AM.Identity_Proof); cmd.Parameters.AddWithValue("@Identity_proof_value", AM.Identity_Proof_Value); cmd.Parameters.AddWithValue("@Alt_Identity_proof", AM.Alt_Identity_Proof); cmd.Parameters.AddWithValue("@Alt_Identity_proof_value", AM.Alt_Identity_Proof_Value); //DateTime dat = DateTime.ParseExact(AM.Dob, "dd-MM-yyyy", CultureInfo.InvariantCulture); cmd.Parameters.AddWithValue("@DOB", Convert.ToDateTime(AM.Dob)); cmd.Parameters.AddWithValue("@Gender", AM.Gender); cmd.Parameters.AddWithValue("@Occupation", AM.Occupation); cmd.Parameters.AddWithValue("@Relationship", AM.RelationshipTxt); cmd.Parameters.AddWithValue("@Address1", AM.Address1); cmd.Parameters.AddWithValue("@Address2", AM.Address2); cmd.Parameters.AddWithValue("@Address3", AM.Address3); cmd.Parameters.AddWithValue("@City", AM.citytext); cmd.Parameters.AddWithValue("@State", AM.statetext); cmd.Parameters.AddWithValue("@Pin", AM.Pin); cmd.Parameters.AddWithValue("@tid", AM.ddltid); cmd.ExecuteNonQuery(); con.Close(); if (Convert.ToInt32(Session["upappointeesid"]) != 0) { AM.check = "true"; } if (AM.check == "true") { con.Open(); SqlCommand cmdd = new SqlCommand("SP_CRUDAlternateAppointees", con); cmdd.CommandType = CommandType.StoredProcedure; cmdd.Parameters.AddWithValue("@condition", "update"); cmdd.Parameters.AddWithValue("@id", Convert.ToInt32(Session["upappointeesid"])); cmdd.Parameters.AddWithValue("@apId", AM.altapId); cmdd.Parameters.AddWithValue("@Name", AM.altName); cmdd.Parameters.AddWithValue("@middleName", AM.altmiddleName); cmdd.Parameters.AddWithValue("@Surname", AM.altSurname); cmdd.Parameters.AddWithValue("@Identity_proof", AM.altIdentity_Proof); cmdd.Parameters.AddWithValue("@Identity_proof_value", AM.altIdentity_Proof_Value); cmdd.Parameters.AddWithValue("@Alt_Identity_proof", AM.altAlt_Identity_Proof); cmdd.Parameters.AddWithValue("@Alt_Identity_proof_value", AM.altAlt_Identity_Proof_Value); //DateTime dat2 = DateTime.ParseExact(AM.altDob, "dd-MM-yyyy", CultureInfo.InvariantCulture); cmdd.Parameters.AddWithValue("@DOB", Convert.ToDateTime(AM.altDob).ToString("dd-MM-yyyy")); cmdd.Parameters.AddWithValue("@Gender", AM.altGender); cmdd.Parameters.AddWithValue("@Occupation", AM.altOccupation); cmdd.Parameters.AddWithValue("@Relationship", AM.altRelationshipTxt); cmdd.Parameters.AddWithValue("@Address1", AM.altAddress1); cmdd.Parameters.AddWithValue("@Address2", AM.altAddress2); cmdd.Parameters.AddWithValue("@Address3", AM.altAddress3); cmdd.Parameters.AddWithValue("@City", AM.altcitytext); cmdd.Parameters.AddWithValue("@State", AM.altstatetext); cmdd.Parameters.AddWithValue("@Pin", AM.altPin); cmdd.Parameters.AddWithValue("@tid", AM.ddltid); cmdd.ExecuteNonQuery(); con.Close(); } ViewBag.Message = "Verified"; return(View("~/Views/UpdateAppointees/UpdateAppointeesPageContent.cshtml")); }
// GET: AddAppointees public ActionResult AddAppointeesIndex() { ViewBag.collapse = "true"; if (Session["rId"] == null || Session["uuid"] == null) { RedirectToAction("LoginPageIndex", "LoginPage"); } // check type string typ = ""; con.Open(); string qq1 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa = new SqlDataAdapter(qq1, con); DataTable dtt = new DataTable(); daa.Fill(dtt); con.Close(); if (dtt.Rows.Count > 0) { typ = dtt.Rows[0]["Type"].ToString(); } //end if (typ == "Testator") { con.Open(); string qq12 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " and designation = 1 "; SqlDataAdapter da42 = new SqlDataAdapter(qq12, con); DataTable d4t2 = new DataTable(); da42.Fill(d4t2); con.Close(); if (d4t2.Rows.Count > 0) { ViewBag.documentlink = "true"; } // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.showtitle = "true"; ViewBag.documentlink = "true"; } // total count Dashboard string q1 = "select count(*) as TotalDistributorAdmin from users where Linked_user = "******"uuid"]) + " and Type = 'DistributorAdmin'"; SqlDataAdapter da1 = new SqlDataAdapter(q1, con); DataTable dt1 = new DataTable(); da1.Fill(dt1); ViewBag.TotalDistributorAdmin = Convert.ToInt32(dt1.Rows[0]["TotalDistributorAdmin"]); string q2 = "select count(*) as TotalWillEmployee from users where Linked_user = "******"uuid"]) + " and Type = 'WillEmployee'"; SqlDataAdapter da22 = new SqlDataAdapter(q2, con); DataTable dt22 = new DataTable(); da22.Fill(dt22); ViewBag.TotalWillEmployee = Convert.ToInt32(dt22.Rows[0]["TotalWillEmployee"]); string q4 = "select count(*) as TotalDistributorEmployee from users where Linked_user = "******"uuid"]) + " and Type = 'DistributorEmployee'"; SqlDataAdapter da4 = new SqlDataAdapter(q4, con); DataTable dt4 = new DataTable(); da4.Fill(dt4); ViewBag.TotalDistributorEmployee = Convert.ToInt32(dt4.Rows[0]["TotalDistributorEmployee"]); string q5 = "select count(*) as TotalTestator from TestatorDetails a inner join users b on a.uId=b.uId where b.Linked_user = "******"uuid"]) + ""; SqlDataAdapter da5 = new SqlDataAdapter(q5, con); DataTable dt5 = new DataTable(); da5.Fill(dt5); ViewBag.TotalTestator = Convert.ToInt32(dt5.Rows[0]["TotalTestator"]); string q6 = "select count(*) as TotalWillEmployee from users where Linked_user = "******"uuid"]) + " and Type = 'WillEmployee'"; SqlDataAdapter da6 = new SqlDataAdapter(q6, con); DataTable dt6 = new DataTable(); da6.Fill(dt6); ViewBag.TotalWillEmployee = Convert.ToInt32(dt6.Rows[0]["TotalWillEmployee"]); string q7 = "select count(*) as TotalFamily from testatorFamily a inner join TestatorDetails b on a.tId=b.tId inner join users c on b.uId = c.uId where c.Linked_user = "******"uuid"]) + ""; SqlDataAdapter da7 = new SqlDataAdapter(q7, con); DataTable dt7 = new DataTable(); da7.Fill(dt7); ViewBag.TotalFamily = Convert.ToInt32(dt7.Rows[0]["TotalFamily"]); string q8 = "select count(*) as TotalAssetInformation from AssetInformation a inner join TestatorDetails b on a.tid=b.tId inner join AssetsType c on a.atId = c.atId inner join AssetsCategory d on a.amId=d.amId inner join users e on e.uId=b.uId where e.Linked_user = "******"uuid"]) + ""; SqlDataAdapter da8 = new SqlDataAdapter(q8, con); DataTable dt8 = new DataTable(); da8.Fill(dt8); ViewBag.TotalAssetInformation = Convert.ToInt32(dt8.Rows[0]["TotalAssetInformation"]); string q9 = "select count(*) as TotalBeneficiary from BeneficiaryDetails a inner join TestatorDetails b on a.tId=b.tId inner join users c on b.uId = c.uId where c.Linked_user = "******"uuid"]) + ""; SqlDataAdapter da9 = new SqlDataAdapter(q9, con); DataTable dt9 = new DataTable(); da9.Fill(dt9); ViewBag.TotalBeneficiary = Convert.ToInt32(dt9.Rows[0]["TotalBeneficiary"]); string q10 = "select count(*) as TotalNominee from Nominee a inner join TestatorDetails b on a.tId=b.tId inner join users c on b.uId=c.uId where c.Linked_user = "******"uuid"]) + ""; SqlDataAdapter da10 = new SqlDataAdapter(q10, con); DataTable dt10 = new DataTable(); da10.Fill(dt10); ViewBag.TotalNominee = Convert.ToInt32(dt10.Rows[0]["TotalNominee"]); string q11 = "select count(*) as TotalAppointees from Appointees a inner join TestatorDetails b on a.tid=b.tid inner join users c on b.uId=c.uId where c.Linked_user = "******"uuid"]) + ""; SqlDataAdapter da11 = new SqlDataAdapter(q11, con); DataTable dt11 = new DataTable(); da11.Fill(dt11); ViewBag.TotalAppointees = Convert.ToInt32(dt11.Rows[0]["TotalAppointees"]); con.Close(); //end List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); ViewBag.view = "Will"; ViewBag.view = "POA"; ViewBag.view = "GiftDeeds"; AppointeesModel Am = new AppointeesModel(); con.Open(); string query = "select * from Appointees where apId = " + Session["distid"].ToString() + ""; SqlDataAdapter da = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); string data = ""; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Am.Typetxt = dt.Rows[i]["Type"].ToString(); Am.subTypetxt = dt.Rows[i]["subType"].ToString(); Am.Name = dt.Rows[i]["Name"].ToString(); Am.middleName = dt.Rows[i]["middleName"].ToString(); Am.Surname = dt.Rows[i]["Surname"].ToString(); Am.Identity_Proof = dt.Rows[i]["Identity_Proof"].ToString(); Am.Identity_Proof_Value = dt.Rows[i]["Identity_Proof_Value"].ToString(); Am.Alt_Identity_Proof = dt.Rows[i]["Alt_Identity_Proof"].ToString(); Am.Alt_Identity_Proof_Value = dt.Rows[i]["Alt_Identity_Proof_Value"].ToString(); Am.Dob = Convert.ToDateTime(dt.Rows[0]["DOB"]).ToString("dd-MM-yyyy"); Am.Gender = dt.Rows[i]["Gender"].ToString(); Am.Occupation = dt.Rows[i]["Occupation"].ToString(); Am.RelationshipTxt = dt.Rows[i]["Relationship"].ToString(); Am.Address1 = dt.Rows[i]["Address1"].ToString(); Am.Address2 = dt.Rows[i]["Address2"].ToString(); Am.Address3 = dt.Rows[i]["Address3"].ToString(); Am.citytext = dt.Rows[i]["City"].ToString(); Am.statetext = dt.Rows[i]["State"].ToString(); Am.Pin = dt.Rows[i]["Pin"].ToString(); } } return(View("/Views/AddAppointees/AddAppointeesPageContent.cshtml", Am)); }
// GET: UpdateAppointees public ActionResult UpdateAppointeesIndex(int NestId) { // check type string typ = ""; con.Open(); string qq1 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " "; SqlDataAdapter daa = new SqlDataAdapter(qq1, con); DataTable dtt = new DataTable(); daa.Fill(dtt); con.Close(); if (dtt.Rows.Count > 0) { typ = dtt.Rows[0]["Type"].ToString(); } //end if (typ == "Testator") { con.Open(); string qq12 = "select Type from users where uId = " + Convert.ToInt32(Session["uuid"]) + " and designation = 1 "; SqlDataAdapter da42 = new SqlDataAdapter(qq12, con); DataTable d4t2 = new DataTable(); da42.Fill(d4t2); con.Close(); if (d4t2.Rows.Count > 0) { ViewBag.documentlink = "true"; } // check will status con.Open(); string qry1 = "select Will from users where Will = 1 "; SqlDataAdapter daa1 = new SqlDataAdapter(qry1, con); DataTable dtt1 = new DataTable(); daa1.Fill(dtt1); if (dtt1.Rows.Count > 0) { ViewBag.documentbtn1 = "true"; } con.Close(); //end // check codocil status con.Open(); string qry2 = "select Codocil from users where Codocil = 1 "; SqlDataAdapter daa2 = new SqlDataAdapter(qry2, con); DataTable dtt2 = new DataTable(); daa2.Fill(dtt2); if (dtt2.Rows.Count > 0) { ViewBag.documentbtn2 = "true"; } con.Close(); //end // check Poa status con.Open(); string qry4 = "select POA from users where POA = 1 "; SqlDataAdapter daa4 = new SqlDataAdapter(qry4, con); DataTable dtt4 = new DataTable(); daa4.Fill(dtt4); if (dtt4.Rows.Count > 0) { ViewBag.documentbtn3 = "true"; } con.Close(); //end // check gift deeds status con.Open(); string qry3 = "select Giftdeeds from users where Giftdeeds = 1 "; SqlDataAdapter daa3 = new SqlDataAdapter(qry3, con); DataTable dtt3 = new DataTable(); daa3.Fill(dtt3); if (dtt3.Rows.Count > 0) { ViewBag.documentbtn4 = "true"; } con.Close(); //end } else { ViewBag.showtitle = "true"; ViewBag.documentlink = "true"; } if (Session["rId"] == null || Session["uuid"] == null) { RedirectToAction("LoginPageIndex", "LoginPage"); } //if (Session["tid"]== null) //{ // ViewBag.message = "link"; //} List <LoginModel> Lmlist = new List <LoginModel>(); con.Open(); string q = "select * from Assignment_Roles where RoleId = " + Convert.ToInt32(Session["rId"]) + ""; SqlDataAdapter da3 = new SqlDataAdapter(q, con); DataTable dt3 = new DataTable(); da3.Fill(dt3); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { LoginModel lm = new LoginModel(); lm.PageName = dt3.Rows[i]["PageName"].ToString(); lm.PageStatus = dt3.Rows[i]["PageStatus"].ToString(); lm.Action = dt3.Rows[i]["Action"].ToString(); lm.Nav1 = dt3.Rows[i]["Nav1"].ToString(); lm.Nav2 = dt3.Rows[i]["Nav2"].ToString(); Lmlist.Add(lm); } ViewBag.PageName = Lmlist; } con.Close(); AppointeesModel Am = new AppointeesModel(); Am.apId = NestId; con.Open(); string query = "select * from Appointees where apId = " + NestId + ""; SqlDataAdapter da = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); string data = ""; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Am.Typetxt = dt.Rows[i]["Type"].ToString(); Am.subTypetxt = dt.Rows[i]["subType"].ToString(); Am.Name = dt.Rows[i]["Name"].ToString(); Am.middleName = dt.Rows[i]["middleName"].ToString(); Am.Surname = dt.Rows[i]["Surname"].ToString(); Am.Identity_Proof = dt.Rows[i]["Identity_Proof"].ToString(); Am.Identity_Proof_Value = dt.Rows[i]["Identity_Proof_Value"].ToString(); Am.Alt_Identity_Proof = dt.Rows[i]["Alt_Identity_Proof"].ToString(); Am.Alt_Identity_Proof_Value = dt.Rows[i]["Alt_Identity_Proof_Value"].ToString(); Am.Dob = dt.Rows[0]["DOB"].ToString(); Am.Gender = dt.Rows[i]["Gender"].ToString(); Am.Occupation = dt.Rows[i]["Occupation"].ToString(); Am.RelationshipTxt = dt.Rows[i]["Relationship"].ToString(); Am.Address1 = dt.Rows[i]["Address1"].ToString(); Am.Address2 = dt.Rows[i]["Address2"].ToString(); Am.Address3 = dt.Rows[i]["Address3"].ToString(); Am.citytext = dt.Rows[i]["City"].ToString(); Am.statetext = dt.Rows[i]["State"].ToString(); Am.Pin = dt.Rows[i]["Pin"].ToString(); } } // for alternate appointees con.Open(); string query2 = "select * from alternate_Appointees where id = " + Convert.ToInt32(Session["upappointeesid"]) + ""; SqlDataAdapter da2 = new SqlDataAdapter(query2, con); DataTable dt2 = new DataTable(); da2.Fill(dt2); con.Close(); if (dt2.Rows.Count > 0) { for (int i = 0; i < dt2.Rows.Count; i++) { Am.altName = dt2.Rows[i]["Name"].ToString(); Am.altmiddleName = dt2.Rows[i]["middleName"].ToString(); Am.altSurname = dt2.Rows[i]["Surname"].ToString(); Am.altIdentity_Proof = dt2.Rows[i]["Identity_Proof"].ToString(); Am.altIdentity_Proof_Value = dt2.Rows[i]["Identity_Proof_Value"].ToString(); Am.altAlt_Identity_Proof = dt2.Rows[i]["Alt_Identity_Proof"].ToString(); Am.altAlt_Identity_Proof_Value = dt2.Rows[i]["Alt_Identity_Proof_Value"].ToString(); Am.altDob = dt2.Rows[i]["DOB"].ToString(); Am.altGender = dt2.Rows[i]["Gender"].ToString(); Am.altOccupation = dt2.Rows[i]["Occupation"].ToString(); Am.altRelationshipTxt = dt2.Rows[i]["Relationship"].ToString(); Am.altAddress1 = dt2.Rows[i]["Address1"].ToString(); Am.altAddress2 = dt2.Rows[i]["Address2"].ToString(); Am.altAddress3 = dt2.Rows[i]["Address3"].ToString(); Am.altcitytext = dt2.Rows[i]["City"].ToString(); Am.altstatetext = dt2.Rows[i]["State"].ToString(); Am.altPin = dt2.Rows[i]["Pin"].ToString(); } } //end return(View("~/Views/UpdateAppointees/UpdateAppointeesPageContent.cshtml", Am)); }