partial void DeleteWebAccount(WebAccount instance);
partial void InsertWebAccount(WebAccount instance);
partial void UpdateWebAccount(WebAccount instance);
protected void btnSave_Click(object sender, EventArgs e) { if (btnNew.Visible == false) { if (txtNewPass1.Text == "" || txtNewPass2.Text == "") { lblStatus.Text = "Please enter a new password for this user"; return; } //if (ddAccountType.SelectedItem.Value != "B" || ddAccountType.SelectedItem.Value != "C") //{ // lblStatus.Text = "Please select a valid account type. Admin account is B and standard is C"; // return; //} Linq_1DataContext db = new Linq_1DataContext(); WebAccount t = new WebAccount(); t.AccountType = Convert.ToChar(ddAccountType.SelectedValue); if (chkActive.Checked) { t.Active = true; } t.DateOpen = DateTime.Today; t.Email = txtEmail.Text; t.FName = txtFirst.Text; t.LName = txtLast.Text; t.Password = txtNewPass1.Text; t.UserName = txtUserName.Text; db.WebAccounts.InsertOnSubmit(t); //insert new record //Show success message + refresh try { db.SubmitChanges(); lblStatus.Text = "New web user Successfully added."; chkActive.Checked = true; txtEmail.Text = txtNewPass2.Text = txtNewPass1.Text = txtId.Text = txtFirst.Text = txtLast.Text = txtLast.Text = txtUserName.Text = ""; } catch (Exception ex) { Shared.WriteError(ex, HttpContext.Current, "btnSave_Click"); } } else { try { Linq_1DataContext db = new Linq_1DataContext(); var usr = (from a in db.WebAccounts where a.id == Convert.ToInt32(txtId.Text) select a).FirstOrDefault(); if (usr != null) { usr.Active = chkActive.Checked; usr.FName = txtFirst.Text; usr.LName = txtLast.Text; usr.Email = txtEmail.Text; usr.AccountType = Convert.ToChar(ddAccountType.SelectedValue); usr.UserName = txtUserName.Text; db.SubmitChanges(); lblStatus.Text = "User's profile updated."; } } catch (Exception ex) { Shared.WriteError(ex, HttpContext.Current); lblStatus.Text = "Error updating user's profile."; } } }