protected void btnLogin_Click(object sender, ImageClickEventArgs e) { Sec_Users user = getUser(txtUserName.Text, txtPassword.Text); if (user != null) { if (user.id != 0 && user.Sec_UserType.name.ToLower() == "patient") { Session["user"] = user; Response.Redirect("Patient/ViewPatientRecord.aspx"); } else if (user.id != 0 && user.Sec_UserType.name.ToLower() == "doctor") { Session["user"] = user; Response.Redirect("Doctor/ManagePatients.aspx"); } else if (user.id != 0 && user.Sec_UserType.name.ToLower() == "admin") { Session["user"] = user; Response.Redirect("Administration/ManageCenters.aspx"); } else { lblMsg.Text = "invalid user name or password"; lblMsg.Visible = true; } } else { lblMsg.Text = "invalid user name or password or the user is in-active"; lblMsg.Visible = true; } }
protected void btnChangePassword_Click(object sender, ImageClickEventArgs e) { Sec_Users user = null; if (Session["user"] != null) { user = Session["user"] as Sec_Users; if (user.Sec_UserType.name.ToLower() != "patient") { Response.Redirect("~/Login.aspx"); } } else if (Session["user"] == null) { Response.Redirect("~/Login.aspx"); } Sec_Users patient = getPatientById(user.id); if (patient.password.ToLower() == txtCurrentPassword.Text.ToLower()) { patient.password = txtNewPassword.Text; db.SaveChanges(); lblMsg.Text = "Password has been changed successfully"; lblMsg.Visible = true; } }
protected void RadGridDoctors_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem dataItem = e.Item as GridEditableItem; int DoctorId = Convert.ToInt32(dataItem.GetDataKeyValue("id")); TextBox txtUserName = e.Item.FindControl("txtUserName") as TextBox; TextBox txtPassword = e.Item.FindControl("txtPassword") as TextBox; CheckBox chkActive = e.Item.FindControl("chkActive") as CheckBox; Sec_Users doctor = getDoctorById(DoctorId); doctor.Username = txtUserName.Text; doctor.password = txtPassword.Text; doctor.IsActive = chkActive.Checked; db.SaveChanges(); RadAjaxManager.ResponseScripts.Add(@"radalert('you have updated a doctor Successfully !!', 400, 135,'update Succeeded !!');"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] != null) { Sec_Users user = Session["user"] as Sec_Users; if (user.Sec_UserType.name.ToLower() != "admin") { Response.Redirect("~/Login.aspx"); } } else if (Session["user"] == null) { Response.Redirect("~/Login.aspx"); } doctor.Attributes["class"] = "active"; }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] != null) { Sec_Users user = Session["user"] as Sec_Users; if (user.Sec_UserType.name.ToLower() != "doctor") { Response.Redirect("~/Login.aspx"); } } else if (Session["user"] == null) { Response.Redirect("~/Login.aspx"); } managePatients.Attributes.Add("class", "active managePatients"); }
protected void RadGridPatients_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { TextBox txtPatientName = e.Item.FindControl("txtPatientName") as TextBox; TextBox txtMotherName = e.Item.FindControl("txtMotherName") as TextBox; RadComboBox cmbCities = e.Item.FindControl("cmbCities") as RadComboBox; RadComboBox cmbNationalities = e.Item.FindControl("cmbNationalities") as RadComboBox; TextBox txtAddress = e.Item.FindControl("txtAddress") as TextBox; TextBox txtPhone = e.Item.FindControl("txtPhone") as TextBox; TextBox txtMobile = e.Item.FindControl("txtMobile") as TextBox; TextBox txtNationalityNumber = e.Item.FindControl("txtNationalityNumber") as TextBox; Sec_Users user = new Sec_Users(); if (cmbCities.SelectedIndex != -1 && cmbNationalities.SelectedIndex != -1) { user.Username = txtPatientName.Text; user.IsActive = true; user.UserTypeId = 1; user.password = Membership.GeneratePassword(6, 0); if (userExisted(txtPatientName.Text)) { RadAjaxManager.ResponseScripts.Add(@"radalert('Patient Name is Taken !!', 400, 135,'Adding Failed !!');"); return; } db.AddToSec_Users(user); db.SaveChanges(); Patient patient = new Patient(); patient.name = txtPatientName.Text; patient.mothername = txtMotherName.Text; patient.address = txtAddress.Text; patient.phone = txtPhone.Text; patient.mobile = txtMobile.Text; patient.cityid = Convert.ToInt32(cmbCities.SelectedValue); patient.natid = Convert.ToInt32(cmbNationalities.SelectedValue); patient.UserId = user.id; patient.nationalityno = txtNationalityNumber.Text; db.AddToPatients(patient); db.SaveChanges(); RadAjaxManager.ResponseScripts.Add(@"radalert('Adding Succeeded !!', 400, 135,'Adding Succeeded !!');"); } else { RadAjaxManager.ResponseScripts.Add(@"radalert('please check your entries !!', 400, 135,'update failed !!');"); } }
protected void RadListViewPatient_NeedDataSource(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e) { Sec_Users user = null; if (Session["user"] != null) { user = Session["user"] as Sec_Users; if (user.Sec_UserType.name.ToLower() != "patient") { Response.Redirect("~/Login.aspx"); } } else if (Session["user"] == null) { Response.Redirect("~/Login.aspx"); } RadListViewPatient.DataSource = getPatientInfo(getPatientIdByUserId(user.id)); }
protected void RadGridPatients_UpdateCommand(object sender, GridCommandEventArgs e) { GridEditableItem dataitem = e.Item as GridEditableItem; if (dataitem != null) { int patientId = Convert.ToInt32(dataitem.GetDataKeyValue("patientId")); Patient patient = getPatientById(patientId); TextBox txtPatientName = e.Item.FindControl("txtPatientName") as TextBox; TextBox txtMotherName = e.Item.FindControl("txtMotherName") as TextBox; RadComboBox cmbCities = e.Item.FindControl("cmbCities") as RadComboBox; RadComboBox cmbNationalities = e.Item.FindControl("cmbNationalities") as RadComboBox; TextBox txtAddress = e.Item.FindControl("txtAddress") as TextBox; TextBox txtPhone = e.Item.FindControl("txtPhone") as TextBox; TextBox txtMobile = e.Item.FindControl("txtMobile") as TextBox; TextBox txtPatientPassword = e.Item.FindControl("txtPatientPassword") as TextBox; TextBox txtNationalityNumber = e.Item.FindControl("txtNationalityNumber") as TextBox; CheckBox chkActive = e.Item.FindControl("chkActive") as CheckBox; if (cmbCities.SelectedIndex != -1 && cmbNationalities.SelectedIndex != -1) { patient.name = txtPatientName.Text; patient.mothername = txtMotherName.Text; patient.address = txtAddress.Text; patient.phone = txtPhone.Text; patient.mobile = txtMobile.Text; patient.cityid = Convert.ToInt32(cmbCities.SelectedValue); patient.natid = Convert.ToInt32(cmbNationalities.SelectedValue); patient.nationalityno = txtNationalityNumber.Text; int? UserId = patient.UserId; Sec_Users user = getUser(UserId); user.Username = txtPatientName.Text; user.password = txtPatientPassword.Text; user.IsActive = chkActive.Checked; db.SaveChanges(); RadAjaxManager.ResponseScripts.Add(@"radalert('you have updated an existing patient successfuly !!', 400, 135,'update succeeded !!');"); } else { RadAjaxManager.ResponseScripts.Add(@"radalert('please check your entries !!', 400, 135,'update failed !!');"); } } }
protected void RadGridDoctors_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { TextBox txtUserName = e.Item.FindControl("txtUserName") as TextBox; TextBox txtPassword = e.Item.FindControl("txtPassword") as TextBox; CheckBox chkActive = e.Item.FindControl("chkActive") as CheckBox; if (userExisted(txtUserName.Text)) { RadAjaxManager.ResponseScripts.Add(@"radalert('Doctor Name is Taken !!', 400, 135,'Adding Failed !!');"); return; } Sec_Users doctor = new Sec_Users(); doctor.Username = txtUserName.Text; doctor.password = txtPassword.Text; doctor.IsActive = chkActive.Checked; doctor.UserTypeId = 2; db.AddToSec_Users(doctor); db.SaveChanges(); RadAjaxManager.ResponseScripts.Add(@"radalert('you have added a new doctor Successfully !!', 400, 135,'Adding Succeeded !!');"); }
/// <summary> /// Function for add the user /// </summary> /// <param name="user_VM"></param> /// <returns></returns> public int Add(User_VM user_VM, int loginUserId, bool isSuperAdminLogin) { var ret = 1; using (var dbcxtransaction = _context.Database.BeginTransaction()) { try { var user = new Sec_Users(); user.Username = user_VM.UserName; user.Password = Helper.Encrypt(user_VM.Password); user.Email = user_VM.Email; user.FullName = user_VM.FullName; user.Phone = user_VM.Phone; user.Lock = true; user.DefaultModule = 0; user.DefaultPage = 0; user.LockProfile = true; user.UnlockProfile = true; user.CreatedOn = DateTime.Now; user.CreatedBy = loginUserId; user.Active = user_VM.Active; user.CanExportProfiles = true; user.IsAdmin = isSuperAdminLogin; user.ClientId = user_VM.ClientId; user.IsAllowVoucherApprovalPermission = user_VM.IsAllowVoucherApprovalPermission; user.IsAllowVoucherIssuancePermission = user_VM.IsAllowVoucherIssuancePermission; _context.Sec_Users.Add(user); _context.SaveChanges(); // Add Stores Persmission // Add Stores Persmission for Admin if (isSuperAdminLogin) { var storesList = _context.Set_Stores.Where(x => x.IsDeleted != true && x.ClientId == user.ClientId && x.CreatedBy == loginUserId).ToList(); if (storesList.Any()) { var userStores = new List <Sec_UserStores>(); foreach (var store in storesList) { var userStore = new Sec_UserStores(); userStore.UserId = user.Id; userStore.Status = store.Status; userStore.StoreId = store.Id; userStore.CreatedBy = loginUserId; userStore.CreatedOn = DateTime.Now; userStore.ClientId = user.ClientId; userStores.Add(userStore); } _context.Sec_UserStores.AddRange(userStores); _context.SaveChanges(); } } // Add Stores Persmission for User if (!isSuperAdminLogin) { var userStores = new List <Sec_UserStores>(); foreach (var store in user_VM.StoreIds) { var userStore = new Sec_UserStores(); userStore.UserId = user.Id; userStore.Status = true; userStore.StoreId = store; userStore.CreatedBy = loginUserId; userStore.CreatedOn = DateTime.Now; userStore.ClientId = user.ClientId; userStores.Add(userStore); } _context.Sec_UserStores.AddRange(userStores); _context.SaveChanges(); } dbcxtransaction.Commit(); } catch (Exception ex) { dbcxtransaction.Rollback(); ret = 0; } } return(ret); }