protected void Button1_Click(object sender, EventArgs e) { getError(); if (isAdd) { Project.Data.UserInfoDAO.AddUsers(FullName.Text, Convert.ToDateTime(DateOfBirth.Text), Email.Text, Phone.Text, lblFile.Text); string id = Project.Data.AccountDAO.GetUserID().Rows[0][0].ToString(); Project.Entity.Account account = new Project.Entity.Account(Account.Text, Password.Text, 2, Convert.ToInt32(id)); account.InsertAccount(); String csname1 = "PopupScript"; Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript; if (!cs.IsStartupScriptRegistered(cstype, csname1)) { String cstext1 = "alert('Register succesful.You can login now');"; cs.RegisterStartupScript(cstype, csname1, cstext1, true); Response.Redirect("Home.aspx"); } } }
protected void Change_Click(object sender, EventArgs e) { int accID = Convert.ToInt32(Session["accountID"].ToString()); Project.Entity.Account acc = Project.Entity.AccountList.GetAccountByID(accID); if (btnSave.Text.Equals("Save") && lblFile.Text.Trim().Length != 0) { if (Session["Pass"].ToString() != null) { if (OldPass.Text.Equals(acc.Pass) && NewPass.Text.Equals(confirmPass.Text)) { getError(); if (Save) { Project.Data.AccountDAO.updateAccount(accID, NewPass.Text); int UserID = Convert.ToInt32(Session["UserID"].ToString()); Project.Entity.UserInfo.UpdateUserIntoDB(FullName.Text, Convert.ToDateTime(DateOfBirth.Text), Email.Text, Phone.Text, lblFile.Text, UserID); btnSave.Text = "Edit"; Label1.Text = "Update successful."; FullName.Enabled = false; DateOfBirth.Enabled = false; Email.Enabled = false; Phone.Enabled = false; } } else { alert("Update Fail."); } } } else { if (OldPass.Text.Equals(acc.Pass) && NewPass.Text.Equals(confirmPass.Text)) { accID = Convert.ToInt32(Session["accountID"].ToString()); Project.Data.AccountDAO.updateAccount(accID, NewPass.Text); Label1.Text = "Update successful."; FullName.Enabled = false; DateOfBirth.Enabled = false; Email.Enabled = false; Phone.Enabled = false; } else if (!OldPass.Text.Equals(acc.Pass)) { //txtError.Text = "Old Pass incorect or Confirm Pass must be same new pass."; alert("Old password was wrong."); } else { alert("New password and Confirm password not same."); } } }