protected void accountdetails_ServerClick(object sender, EventArgs e) { try { if (ValidateAccountDetails() == true) { if (Session["UserName"] != null) { CustomerLoginViewModel customerLoginViewModel = new CustomerLoginViewModel(); CustomerModel custModel = new CustomerModel(); custModel.firstname = firstname.Value.Trim(); custModel.lastname = lastname.Value.Trim(); custModel.address1 = address1.Value.Trim(); custModel.address2 = address2.Value.Trim(); custModel.city = city.Value.Trim(); custModel.state = state.Value.Trim(); custModel.zip = zip.Value.Trim(); custModel.mobileno = mobileno.Value.Trim(); string uid = Session["UserName"].ToString(); customerLoginViewModel.UpdateCustomerDetails(custModel, uid); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Add Event Validation", "<script type='text/javascript'>CheckValidation('Account Details updated','Account Details');</script>", false); } } } catch (Exception ex) { ErrHandler.WriteError(ex.Message); } }
public bool UpdateCustomerDetails(CustomerModel customerModel, string emailid) { try { using (SqlConnection conn = new SqlConnection(ConnString)) { using (SqlCommand cmd = new SqlCommand("SL_PROC_UPDATE_CUSTOMER_DETAILS", conn)) { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = customerModel.firstname; cmd.Parameters.Add("@LastName", SqlDbType.VarChar, 50).Value = customerModel.lastname; cmd.Parameters.Add("@Address1", SqlDbType.VarChar, 200).Value = customerModel.address1; cmd.Parameters.Add("@Address2", SqlDbType.VarChar, 200).Value = customerModel.address2; cmd.Parameters.Add("@City", SqlDbType.VarChar, 200).Value = customerModel.city; cmd.Parameters.Add("@State", SqlDbType.VarChar, 200).Value = customerModel.state; cmd.Parameters.Add("@Zip", SqlDbType.VarChar, 50).Value = customerModel.zip; cmd.Parameters.Add("@Phone", SqlDbType.VarChar, 20).Value = customerModel.mobileno; cmd.Parameters.Add("@USERID", SqlDbType.VarChar, 200).Value = emailid; cmd.ExecuteNonQuery(); return true; } } } catch (Exception ex) { ErrHandler.WriteError(ex.Message); return false; } }