protected void RepeaterAddressDetails_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "DelContact") { DataTable TempDT = ViewState["DTTable"] as DataTable; int ContactID = Convert.ToInt32(e.CommandArgument); DeletDTTable(ContactID); RepeaterAddressDetails.DataSource = ViewState["DTTable"] as DataTable; RepeaterAddressDetails.DataBind(); } }
protected void GVCustomer_RowCommand(object sender, GridViewCommandEventArgs e) { int MRecordID = Convert.ToInt32(e.CommandArgument); Session["MRecordID"] = MRecordID; #region For Command EditRecord if (e.CommandName == "EditRecord") { MVCustomers.ActiveViewIndex = 1; SqlParameter[] arrParam = new SqlParameter[2]; arrParam[0] = new SqlParameter("@Action", "SELECT_ByID"); arrParam[1] = new SqlParameter("@ID", MRecordID); DataSet DSRecords1 = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_Customer_CRUD", arrParam); if (DSRecords1.Tables[0].Rows.Count > 0) { ImgLogo.ImageUrl = DSRecords1.Tables[0].Rows[0]["Image"].ToString(); TBCustomerCode.Text = DSRecords1.Tables[0].Rows[0]["CustomerCode"].ToString(); TBCustomerCode.Enabled = false; if (DSRecords1.Tables[0].Rows[0]["CustomerType"].ToString() == "Individual") { RBIndividual.Checked = true; } if (DSRecords1.Tables[0].Rows[0]["CustomerType"].ToString() == "Company") { RBCompany.Checked = true; } TBFirstName.Text = DSRecords1.Tables[0].Rows[0]["FirstName"].ToString(); TBLastName.Text = DSRecords1.Tables[0].Rows[0]["LastName"].ToString(); TBCompanyName.Text = DSRecords1.Tables[0].Rows[0]["CompanyName"].ToString(); TBAddressLine1.Text = DSRecords1.Tables[0].Rows[0]["AddressLine1"].ToString(); TBAddressLine2.Text = DSRecords1.Tables[0].Rows[0]["AddressLine2"].ToString(); TBCity.Text = DSRecords1.Tables[0].Rows[0]["City"].ToString(); TBState.Text = DSRecords1.Tables[0].Rows[0]["State"].ToString(); TBCountry.Text = DSRecords1.Tables[0].Rows[0]["Country"].ToString(); TBPinCode.Text = DSRecords1.Tables[0].Rows[0]["PinCode"].ToString(); TBPhoneNumber.Text = DSRecords1.Tables[0].Rows[0]["PhoneNumber"].ToString(); TBMobileNumber.Text = DSRecords1.Tables[0].Rows[0]["MobileNumber"].ToString(); TBFaxNumber.Text = DSRecords1.Tables[0].Rows[0]["FaxNumber"].ToString(); TBEmailID.Text = DSRecords1.Tables[0].Rows[0]["EmailID"].ToString(); TBWebsite.Text = DSRecords1.Tables[0].Rows[0]["Website"].ToString(); TBVATNumber.Text = DSRecords1.Tables[0].Rows[0]["VATNumber"].ToString(); TBCSTNumber.Text = DSRecords1.Tables[0].Rows[0]["CSTNumber"].ToString(); TBTINNumber.Text = DSRecords1.Tables[0].Rows[0]["TINNumber"].ToString(); TBPANNumber.Text = DSRecords1.Tables[0].Rows[0]["PANNumber"].ToString(); TBSearchCode.Text = DSRecords1.Tables[0].Rows[0]["SearchCode"].ToString(); BindBusinessLocation(); DDLBusinessLocation.ClearSelection(); DDLBusinessLocation.Items.FindByValue(DSRecords1.Tables[0].Rows[0]["BusinessLocation"].ToString()).Selected = true; TBDOB.Text = DSRecords1.Tables[0].Rows[0]["BirthDate"].ToString(); TBAnniversaryDate.Text = DSRecords1.Tables[0].Rows[0]["AnniversaryDate"].ToString(); CBIsActive.Checked = Convert.ToBoolean(DSRecords1.Tables[0].Rows[0]["IsActive"].ToString()); } SqlParameter[] arrParam2 = new SqlParameter[2]; arrParam2[0] = new SqlParameter("@Action", "SELECT_ByMasterID"); arrParam2[1] = new SqlParameter("@CustomerID", MRecordID); DataSet DSRecords2 = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_CustomerContacts_CRUD", arrParam2); // Bind Table CreateDTTable(); TempDT = ViewState["DTTable"] as DataTable; for (int i = 0; i < DSRecords2.Tables[0].Rows.Count; i++) { TempDT.Rows.Add(null, DSRecords2.Tables[0].Rows[i]["Title"].ToString(), DSRecords2.Tables[0].Rows[i]["ContactName"].ToString(), DSRecords2.Tables[0].Rows[i]["Position"].ToString(), DSRecords2.Tables[0].Rows[i]["EmailID"].ToString(), DSRecords2.Tables[0].Rows[i]["PhoneNumber"].ToString(), DSRecords2.Tables[0].Rows[i]["MobileNumber"].ToString(), DSRecords2.Tables[0].Rows[i]["Note"].ToString(), DSRecords2.Tables[0].Rows[i]["AddressType"].ToString(), DSRecords2.Tables[0].Rows[i]["AddressLine1"].ToString(), DSRecords2.Tables[0].Rows[i]["AddressLine2"].ToString(), DSRecords2.Tables[0].Rows[i]["City"].ToString(), DSRecords2.Tables[0].Rows[i]["State"].ToString(), DSRecords2.Tables[0].Rows[i]["Country"].ToString(), DSRecords2.Tables[0].Rows[i]["PinCode"].ToString()); } RepeaterAddressDetails.DataSource = TempDT; RepeaterAddressDetails.DataBind(); ViewState["DTTable"] = TempDT; btnSubmit.Text = "Update"; } #endregion #region For Command DeleteRecord if (e.CommandName == "DeleteRecord") { SqlParameter[] arrParam = new SqlParameter[2]; arrParam[0] = new SqlParameter("@Action", "DELETE_ByMasterID"); arrParam[1] = new SqlParameter("@POID", MRecordID); int result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_CustomerContacts_CRUD", arrParam); SqlParameter[] arrParam1 = new SqlParameter[2]; arrParam1[0] = new SqlParameter("@Action", "DELETE"); arrParam1[1] = new SqlParameter("@ID", MRecordID); int result1 = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_Customer_CRUD", arrParam1); BindGVCustomer(); } #endregion #region For Command ChangeStatus if (e.CommandName == "ChangeStatus") { SqlParameter[] arrParam = new SqlParameter[2]; arrParam[0] = new SqlParameter("@Action", "SELECT_ByID"); arrParam[1] = new SqlParameter("@ID", MRecordID); DataSet DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_Customer_CRUD", arrParam); DataTable DTRecords = DSRecords.Tables[0]; if (DTRecords.Rows.Count > 0) { #region Change Status True To False if (DTRecords.Rows[0]["Status"].ToString() == "True") { SqlParameter[] arrParam2 = new SqlParameter[3]; arrParam2[0] = new SqlParameter("@Action", "UPDATE_Status"); arrParam2[1] = new SqlParameter("@Status", false); arrParam2[2] = new SqlParameter("@ID", MRecordID); int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_Customer_CRUD", arrParam2); } #endregion #region Change Status False TO True if (DTRecords.Rows[0]["Status"].ToString() == "False") { SqlParameter[] arrParam2 = new SqlParameter[3]; arrParam2[0] = new SqlParameter("@Action", "UPDATE_Status"); arrParam2[1] = new SqlParameter("@Status", true); arrParam2[2] = new SqlParameter("@ID", MRecordID); int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_Customer_CRUD", arrParam2); } #endregion } BindGVCustomer(); } #endregion }
// Method For Bind Inner GridView private void BindInnerGV() { RepeaterAddressDetails.DataSource = ViewState["DTTable"] as DataTable; RepeaterAddressDetails.DataBind(); }