protected void btnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { string strAlertScript = string.Empty; dsUsers.dtUsersDataTable dtUsers = new dsUsers.dtUsersDataTable(); dsUsersTableAdapters.taUsers taUsers = new dsUsersTableAdapters.taUsers(); List <string> lstMessage = ChackValidationForUserNameAndMail(dtUsers, taUsers, txtUserName.Text, txtEmail.Text); if (lstMessage.Count > 0) { strAlertScript = clsHelper.MultiAlert(3, lstMessage); Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", strAlertScript, true); return; } dsUsers.dtUsersRow UserRow = dtUsers.NewdtUsersRow(); UserRow.IsUserActive = true; UserRow.UserName = txtUserName.Text; UserRow.Password = txtPassword.Text; UserRow.Email = txtEmail.Text; dtUsers.AdddtUsersRow(UserRow); taUsers.Update(dtUsers); strAlertScript = clsHelper.Alert(1, "ثبت نام شما انجام شد."); Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", strAlertScript, true); txtUserName.Text = txtPassword.Text = txtPasswordConfirm.Text = txtEmail.Text = txtEmailConfirm.Text = string.Empty; } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (Page.IsValid == true) { Helper clsHelper = new Helper(); dsUsers.dtUsersDataTable dtUsers = new dsUsers.dtUsersDataTable(); dsUsersTableAdapters.taUsers taUsers = new dsUsersTableAdapters.taUsers(); taUsers.FillUserByUserID(dtUsers, 5); dsUsers.dtUsersRow UsersRow = dtUsers[0]; if (txtNam.Text == string.Empty) { UsersRow.SetNamNull(); } else { UsersRow.Nam = txtNam.Text; } if (txtFamily.Text == string.Empty) { UsersRow.SetFamilyNull(); } else { UsersRow.Family = txtFamily.Text; } if (txtPassword.Text != string.Empty) { UsersRow.Password = txtPassword.Text; } if (txtEmail.Text != string.Empty) { UsersRow.Email = txtEmail.Text; } if (txtMobile.Text != string.Empty) { UsersRow.Mobile = txtMobile.Text; } taUsers.Update(dtUsers); string strMessage = "اطلاعات بروز رسانی شد."; string strAlertScript = clsHelper.Alert(1, strMessage); Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", strAlertScript, true); } }