protected void BindListView(string selectOrder = "LPAD(ward_name,64)") { string query = DataProvider.Wards.fillListView(selectOrder); DataTable dt = HospitalClass.getDataTable(query); BindListView(dt); }
protected void EmailButton_Click(object sender, EventArgs e) { try { string emailInfo = DataProvider.ChangePassword.getEmailPassword(EmailBox.Text.Trim().ToUpper()); //get user's email DataTable dt = HospitalClass.getDataTable(emailInfo); if (dt.Rows.Count > 0) { string firstName = HospitalClass.PascalCasing(dt.Rows[0][0].ToString()); string userId = dt.Rows[0][1].ToString(); string password = HospitalClass.Decrypt(dt.Rows[0][2].ToString()); string message = string.Format("Good day user {0}.\r\n\r\nYour user Id is: {1}\r\nYour password is: {2}", firstName, userId, password); MailMessage myMessage = new MailMessage(); myMessage.Body = message; //myMessage.From = new MailAddress(EmailBox.Text, UsernameBox.Text); //Unneccesary, set at web.config myMessage.To.Add(new MailAddress(EmailBox.Text.Trim())); SmtpClient mySender = new SmtpClient(); mySender.Send(myMessage); //uses config file settings to send message string updaterId = "", updateCode = "PWD_SND"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else if (Session["Admin"] != null) { updaterId = (string)Session["Admin"]; } else { updaterId = (string)Session["User"]; } List <string> values = new List <string>(); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add((string)Session["User"]); int status = DataConsumer.executeProcedure("audit_trail_proc", values); EmailLabel.CssClass = "success normal"; EmailLabel.Text = "Successful.<br/>Check your E-mail box for details."; } else { EmailLabel.CssClass = "error paraNormal"; if (EmailBox.Text.Length == 0) { EmailLabel.Text = "Please enter an email"; } else { EmailLabel.Text = "Email does not exist"; } } } catch (Exception ex) { EmailLabel.CssClass = "error paraNormal"; EmailLabel.Text = "Error: " + ex.Message; } }
protected void DeletePicButton_Click(object sender, EventArgs e) { string chkQuery = DataProvider.LoggedInPage.getPicAddress((string)Session["User"]); DataTable dt = HospitalClass.getDataTable(chkQuery); if (dt.Rows.Count > 0 && dt.Rows[0][0].ToString() != "~\\Images\\UploadProfilePicture.PNG") { chkQuery = "delete"; string updaterId = UpdaterId(); //delete picture from server if (dt.Rows.Count == 1) { System.IO.File.Delete(Server.MapPath(dt.Rows[0][0].ToString())); } //update information at the database List <string> values = new List <string>(); values.Add((string)Session["User"]); values.Add("~\\Images\\UploadProfilePicture.PNG"); values.Add(HospitalClass.getTransactionId()); values.Add("IMG_DEL"); values.Add(updaterId); values.Add(chkQuery); int status = DataConsumer.executeProcedure("image_upload", values); ProfilePic.ImageUrl = "~\\Images\\UploadProfilePicture.PNG"; UploadPicLabel.CssClass = "success"; UploadPicLabel.Text = "Deleted"; } else { UploadPicLabel.CssClass = "error"; UploadPicLabel.Text = "No picture exists"; } }
protected void populateDeptList() { string getDeptsQuery = DataProvider.DiscDeptWard.getDepartments(); DataTable dt = HospitalClass.getDataTable(getDeptsQuery); DeptList.DataSource = dt; DeptList.DataTextField = "DEPT_NAME"; DeptList.DataBind(); DeptList.Items.Insert(0, new ListItem("Please select...")); }
protected void populateWardList() { string getWardsQuery = DataProvider.RelDeptWardPage.getWards(); DataTable dt = HospitalClass.getDataTable(getWardsQuery); WardList.DataSource = dt; WardList.DataTextField = "WARD_NAME"; WardList.DataBind(); WardList.Items.Insert(0, new ListItem("Please select...")); }
protected void ChangeButton_Click(object sender, EventArgs e) { try { string checkPassword = DataProvider.ChangePassword.getPassword(Session["User"].ToString()); //get the former password and check DataTable dt = HospitalClass.getDataTable(checkPassword); if (dt.Rows[0][0].ToString() == HospitalClass.Encrypt(OldPasswordBox.Text) && OldPasswordBox.Text != NewPasswordBox.Text) { string updaterId = "", updateCode = "PWD_CHG"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else if (Session["Admin"] != null) { updaterId = (string)Session["Admin"]; } else { updaterId = (string)Session["User"]; } List <string> values = new List <string>(); values.Add(HospitalClass.Encrypt(NewPasswordBox.Text)); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add((string)Session["User"]); int status = DataConsumer.executeProcedure("pwd_change", values); UserStatusLabel.CssClass = "success paraNormal"; UserStatusLabel.Text = "Password was successfully changed"; } else { UserStatusLabel.CssClass = "error normal"; if (OldPasswordBox.Text == NewPasswordBox.Text) { UserStatusLabel.Text = "Same password entered"; } else { UserStatusLabel.Text = "Wrong password entered.<br/>Meet the system administrator for assistance"; } } } catch (Exception ex) { UserStatusLabel.CssClass = "error paraNormal"; UserStatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void DeptAddButton_Click(object sender, EventArgs e) { try { DeptAddLabel.CssClass = "error"; string checkQuery = DataProvider.DeptWardPage.verifyDeptAdd(DeptAddNameBox.Text); DataTable dt = HospitalClass.getDataTable(checkQuery); if (DeptAddNameBox.Text.Trim().Length > 2 && DeptAddDescBox.Text.Trim().Length > 3 && dt.Rows.Count == 0) { string updateCode = "DEPT_ADD"; string updaterId = ""; if (Session["SuperUser"] != null) { updaterId = Session["SuperUser"].ToString(); } else { updaterId = Session["Admin"].ToString(); } List <string> values = new List <string>(); values.Add(DeptAddNameBox.Text.Trim()); values.Add(DeptAddDescBox.Text); values.Add(updateCode); values.Add(updaterId); values.Add("insert"); int status = DataConsumer.executeProcedure("add_del_dept", values); DeptAddLabel.CssClass = "success"; DeptAddLabel.Text = "Operation Successful.<br/>Department added: " + DeptAddNameBox.Text.Trim(); populateLists(); } else { if (dt.Rows.Count != 0) { DeptAddLabel.Text = "This department exists"; } else if (DeptAddNameBox.Text.Trim().Length <= 2) { DeptAddLabel.Text = "Enter a valid department name"; } else { DeptAddLabel.Text = "Enter a valid department description"; } } } catch (Exception ex) { DeptAddLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void getPasswordButton_Click(object sender, EventArgs e) { try { string getPassword = DataProvider.ChangePassword.getPassword(UserIdBox.Text.Trim().ToUpper()); //get the user's password DataTable dt = HospitalClass.getDataTable(getPassword); if (UserIdBox.Text.Trim().Length == 6 || UserIdBox.Text.Trim().Length == 11 && dt.Rows.Count > 0) //unnecessary due to access restrictions { string updaterId = "", updateCode = "PWD_GET"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } List <string> values = new List <string>(); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(UserIdBox.Text.Trim().ToUpper()); int status = DataConsumer.executeProcedure("audit_trail_proc", values); PasswordStatusLabel.CssClass = "success paraNormal"; PasswordStatusLabel.Text = "Your password is: " + HospitalClass.Decrypt(dt.Rows[0][0].ToString()); //display password } else { PasswordStatusLabel.CssClass = "error paraNormal"; if (dt.Rows.Count == 0) { PasswordStatusLabel.Text = UserIdBox.Text.Trim().ToUpper() + " is not a user on this system"; } else if (UserIdBox.Text.Length == 0) { PasswordStatusLabel.Text = "User Id cannot be empty"; } else { PasswordStatusLabel.Text = UserIdBox.Text.Trim().ToUpper() + " is not a valid id"; } } } catch (Exception ex) { UserStatusLabel.CssClass = "error paraNormal"; UserStatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
public void completeAction() { System.Data.DataTable nameDt = HospitalClass.getDataTable(DataProvider.Patients.getName(SearchBox.Text.Trim().ToUpper())); SearchNameLabel.Text = "Name: " + HospitalClass.PascalCasing(nameDt.Rows[0][0].ToString()) + ", " + HospitalClass.PascalCasing(nameDt.Rows[0][1].ToString()); if (!DBNull.Value.Equals(nameDt.Rows[0][2])) { SearchNameLabel.Text += " " + HospitalClass.PascalCasing(nameDt.Rows[0][2].ToString()); } SearchNameLabel.Text += "<br/>User Id: "; SearchUserIdLabel.Text = SearchBox.Text.Trim().ToUpper(); SearchStatusLabel.CssClass = "success"; SearchStatusLabel.Text = "Found"; }
/// <summary> /// Returns the last transaction Id + 1 from the audit trail /// </summary> /// <returns></returns> internal static string getTransactionId() { string lastId = DataProvider.GeneralClass.getLastTransactionId(); DataTable dt = HospitalClass.getDataTable(lastId); if (dt.Rows[0][0].ToString() == "") { return("1"); } else { int newId = int.Parse(dt.Rows[0][0].ToString()) + 1; return(newId.ToString()); } }
protected void SubmitButton_Click(object sender, EventArgs e) { string checkTopicExist = DataProvider.AddInformationPage.checkTopic(TopicBox.Text.Trim()); DataTable dt = HospitalClass.getDataTable(checkTopicExist); if ((UserIdBox.Text.Length >= 3 && UserIdBox.Text.Length <= 32) && (TopicBox.Text.Trim().Length >= 2 && TopicBox.Text.Length <= 32) && (InfoBox.Text.Length >= 4 && InfoBox.Text.Length <= 256) && RecipientList.SelectedIndex != 0 && dt.Rows.Count == 0) { List <string> values = new List <string>(); values.Add(InfoBox.Text); values.Add(RecipientList.SelectedItem.Value); values.Add(HospitalClass.PascalCasing(TopicBox.Text.Trim())); values.Add(HospitalClass.getTransactionId()); values.Add("INFO_ADD"); values.Add(UpdaterId()); values.Add(UserIdBox.Text); values.Add(""); values.Add("insert"); int status = DataConsumer.executeProcedure("info_proc", values); StatusLabel.CssClass = "success"; StatusLabel.Text = "Successful.<br/>Updater: " + UpdaterId() + "."; } else { StatusLabel.CssClass = "error"; if (dt.Rows.Count != 0) { StatusLabel.Text = "This topic already exists. Choose another topic name"; } else if (RecipientList.SelectedIndex == 0) { StatusLabel.Text = "Please select a recipient classification"; } else if (!(UserIdBox.Text.Length >= 3 && UserIdBox.Text.Length <= 32)) { StatusLabel.Text = "Please enter a valid user Id.<br/>Between 6 and 32 characters"; } else if ((TopicBox.Text.Length >= 2 && TopicBox.Text.Length <= 32)) { StatusLabel.Text = "Please enter a valid topic.<br/>Between 2 and 32 characters"; } else { StatusLabel.Text = "Please enter valid information.<br/>Between 4 and 256 characters"; } } }
protected void RoleList_SelectedIndexChanged(object sender, EventArgs e) { if (RoleList.SelectedIndex == 0) { StatusLabel.Text = "Please select a a role (or update user information)"; } else if (RoleList.SelectedIndex == 3) { UserIdBox.Text = Session["User"].ToString(); if (Session["User"].ToString().StartsWith("ADM") || Session["User"].ToString().StartsWith("SUP")) { Populate(); } else { ValidateButton.Visible = false; StatusLabel.Text = "This user's information cannot be updated here.<br/>Go to user profile page"; } } else { //redundant except if an administrator can register other administrators if (Session["SuperUser"] == null && RoleList.SelectedIndex == 1) { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "You cannot register this user"; ValidateButton.Visible = false; } string lastIdQuery = ""; if (RoleList.SelectedIndex == 1) { lastIdQuery = DataProvider.RegistrationPage.LastIdQuery("SUP"); //returns an empty string for no value } else { lastIdQuery = DataProvider.RegistrationPage.LastIdQuery("ADM"); } DataTable lastDt = HospitalClass.getDataTable(lastIdQuery); UserIdBox.Text = getNewSuperuserAdminId(lastDt); ClearAll(); } }
public void completeAction() { System.Data.DataTable nameDt; if (RoleList.SelectedIndex == 0) { nameDt = HospitalClass.getDataTable(DataProvider.DoctorStaffHistory.getNameDoc(SearchBox.Text.Trim().ToUpper())); } else { nameDt = HospitalClass.getDataTable(DataProvider.DoctorStaffHistory.getNameStf(SearchBox.Text.Trim().ToUpper())); } SearchNameLabel.Text = "Name: " + HospitalClass.PascalCasing(nameDt.Rows[0][0].ToString()) + ", " + HospitalClass.PascalCasing(nameDt.Rows[0][1].ToString()); if (!DBNull.Value.Equals(nameDt.Rows[0][2])) { SearchNameLabel.Text += " " + HospitalClass.PascalCasing(nameDt.Rows[0][2].ToString()); } SearchNameLabel.Text += "<br/>User Id: "; SearchUserIdLabel.Text = SearchBox.Text.Trim().ToUpper(); SearchStatusLabel.CssClass = "success"; SearchStatusLabel.Text = "Found"; }
protected void DeptSelectButton_Click(object sender, EventArgs e) { if (DeptList.SelectedIndex != 0) { deptSelected(); string getDeptTableInfoQuery = DataProvider.DiscDeptWard.getDeptInfo(DeptList.SelectedItem.Text); DataTable dt = HospitalClass.getDataTable(getDeptTableInfoQuery); DeptIdLabel.Text = dt.Rows[0]["DEPT_ID"].ToString(); DeptNameLabel.Text = dt.Rows[0]["DEPT_NAME"].ToString(); DeptDescLabel.Text = dt.Rows[0]["DESCRIPTION"].ToString(); CancelButton.Visible = true; BindListView(); StatusLabel.CssClass += " addColor"; StatusLabel.Text = "choose wards to be unrelated from table above"; } else { StatusLabel.CssClass = "error"; StatusLabel.Text = "Please select a department"; } ListView1.SelectedIndex = -1; }
protected void StaffRadioButton_CheckedChanged(object sender, EventArgs e) { try { InfoDiv.Visible = true; DocRoleTable.Visible = false; StfRoleTable.Visible = true; RegLabel.Text = "Staff's Registration Page"; string stfQuery = DataProvider.RegistrationPage.StfListQuery(); DataTable dt = HospitalClass.getDataTable(stfQuery); //populate drop down list for staffs StfRoleList.DataSource = dt; StfRoleList.DataTextField = "DESCRIPTION"; StfRoleList.DataValueField = "ROLE_ID"; StfRoleList.DataBind(); StfRoleList.Items.Insert(0, new ListItem("Please select...")); } catch (Exception ex) { StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void Page_Load(object sender, EventArgs e) { string docQuery = DataProvider.GeneralClass.getDoctorsInfo(); DataTable dt = HospitalClass.getDataTable(docQuery); //populate doctors table for (int i = 0; i < dt.Rows.Count; i++) { TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Text = i + 1 + ""; row.Cells.Add(cell); Image img = new Image(); img.Width = (System.Web.UI.WebControls.Unit) 150; img.Height = (System.Web.UI.WebControls.Unit) 150; img.ID = "docImage" + (i + 1); if (!DBNull.Value.Equals(dt.Rows[i]["IMG_ADR"])) { img.ImageUrl = dt.Rows[i]["IMG_ADR"].ToString(); } else { img.ImageUrl = "~//images//UploadProfilePicture.png"; } cell = new TableCell(); cell.Height = (System.Web.UI.WebControls.Unit) 200; cell.Controls.Add(img); row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Name: " + HospitalClass.PascalCasing(dt.Rows[i]["LAST_NAME"].ToString()) + " " + HospitalClass.PascalCasing(dt.Rows[i]["FIRST_NAME"].ToString()) + ".<br/>" + "Mobile: " + dt.Rows[i]["PHONE_NO"].ToString() + ".<br/>E-mail: " + dt.Rows[i]["EMAIL"].ToString() + "."; row.Cells.Add(cell); cell = new TableCell(); cell.Text = dt.Rows[i]["OTHER_INFO"].ToString(); row.Cells.Add(cell); DocTable.Rows.Add(row); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["SuperUser"] == null && Session["Admin"] == null && Session["User"] == null) { Response.Redirect("~/Login.aspx"); } if (Session["SuperUser"] != null || Session["Admin"] != null) { SuDiv.Visible = true; } UserIdBox.Text = Session["User"].ToString(); UserIdBox.ReadOnly = true; if (!IsPostBack) { DataTable dt = HospitalClass.getDataTable(DataProvider.ChangePassword.getEmail(Session["User"].ToString())); //get user email EmailBox.Text = HospitalClass.PascalCasing(dt.Rows[0][0].ToString()); } EmailBox.ReadOnly = true; if (Session["SuperUser"] != null || Session["Admin"] != null) { EmailBox.ReadOnly = false; } }
protected void populateLists() { try { string deptListQuery = DataProvider.DeptWardPage.fillDeptList(); DataTable deptDt = HospitalClass.getDataTable(deptListQuery); DeptDelList.DataSource = deptDt; DeptDelList.DataTextField = "DEPT_NAME"; DeptDelList.DataValueField = "DESCRIPTION"; DeptDelList.DataBind(); DeptDelList.Items.Insert(0, new ListItem("Please select...", "None Selected")); string wardListQuery = "select ward_name from tobehospital.wards where no_of_rooms='0' and parent_dept='None'"; DataTable wardDt = HospitalClass.getDataTable(wardListQuery); WardDelList.DataSource = wardDt; WardDelList.DataTextField = "WARD_NAME"; WardDelList.DataValueField = "WARD_NAME"; WardDelList.DataBind(); WardDelList.Items.Insert(0, new ListItem("Please select...", "None")); DeptDelDescLabel.Text = "Description: None Selected"; WardDelDescLabel.Text = "Name of ward to be deleted: none"; } catch { throw; } }
protected void WardAddButton_Click(object sender, EventArgs e) { if (WardList.SelectedIndex != 0) { string getWardInfo = DataProvider.RelDeptWardPage.getWardInfo(WardList.SelectedItem.Text); DataTable dt = HospitalClass.getDataTable(getWardInfo); List <string> values = new List <string>(); values.Add(dt.Rows[0]["WARD_ID"].ToString()); values.Add(dt.Rows[0]["WARD_NAME"].ToString()); values.Add(dt.Rows[0]["DESCRIPTION"].ToString()); values.Add("add"); DataConsumer.executeProcedure("ward_temp_proc", values); BindListView(); populateWardList(); StatusLabel.CssClass += "success"; StatusLabel.Text = "Added"; } else { StatusLabel.CssClass = "error"; StatusLabel.Text = "Please select a ward"; } ListView1.SelectedIndex = -1; }
protected void UploadPicButton_Click(object sender, EventArgs e) { try { if (FileUpload1.HasFile && (FileUpload1.FileName.ToLower().EndsWith(".gif") || FileUpload1.FileName.ToLower().EndsWith(".jpg") || FileUpload1.FileName.ToLower().EndsWith(".bmp") || FileUpload1.FileName.ToLower().EndsWith(".png")) && FileUpload1.PostedFile.ContentLength <= 1048576) { string path = @"~\Uploads\"; string savedPath = Server.MapPath(path) + FileUpload1.FileName; //better for saving into IIS FileUpload1.SaveAs(savedPath); ////To test image dimensions //System.Drawing.Image i = System.Drawing.Image.FromFile(savedPath); //if (i.PhysicalDimension.Height != 200 || i.PhysicalDimension.Width != 200) //{ // FileUpload1.Dispose(); // i.Dispose(); // File.Delete(savedPath); // throw new Exception("Incompatible dimensions. <br>Image must be 200px by 200px!"); //} string chkQuery = DataProvider.LoggedInPage.getPictureAvailability((string)Session["User"]); DataTable dt = HospitalClass.getDataTable(chkQuery); string updateCode = ""; if (dt.Rows.Count > 0) { chkQuery = "update"; updateCode = "IMG_UPD"; } else { chkQuery = "insert"; updateCode = "IMG_UPL"; } string updaterId = UpdaterId(); List <string> values = new List <string>(); values.Add((string)Session["User"]); values.Add(path + FileUpload1.FileName); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(chkQuery); int status = DataConsumer.executeProcedure("image_upload", values); string insertPicData = "update tobehospital.images set img=:image where user_id='" + (string)Session["User"] + "'"; status = DataConsumer.sendPictureToDatabase(insertPicData, FileUpload1.FileBytes); ProfilePic.ImageUrl = path + FileUpload1.FileName; UploadPicLabel.CssClass = "success"; UploadPicLabel.Text = "Done"; } else { UploadPicLabel.CssClass = "error"; if (!FileUpload1.HasFile) { UploadPicLabel.Text = "Choose a picture"; } else if (FileUpload1.PostedFile.ContentLength > 1048576) { UploadPicLabel.Text = "Too Large"; } else { UploadPicLabel.Text = "Wrong Format"; } } } catch (Exception ex) { UploadPicLabel.CssClass = "error"; UploadPicLabel.Text = "Error" + ex.Message; HospitalClass.Log(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null && Session["Admin"] == null && Session["SuperUser"] == null) { Response.Redirect("~/Login.aspx"); //not logged in } Session["Unsubscribe"] = "Unsubscribe"; //set session to display unsubscribe link only on profile page WelcomeLabel.Text = "Welcome " + HospitalClass.PascalCasing((string)Session["FirstName"]); string regStatus = ""; if (Session["RegStatus"] != null) { regStatus = (string)Session["RegStatus"]; //registration status of user } if (regStatus.ToUpper() != "VALIDATED") { HistLabel.CssClass = "error"; HistLabel.Text = "Incomplete Registration".ToUpper(); InfoLabel.Visible = false; HistoryDiv.Visible = false; ActivitiesDiv.Visible = false; } try { //get profile picture string getPicAdr = DataProvider.LoggedInPage.getPicAddress((string)Session["User"]); DataTable picDt = HospitalClass.getDataTable(getPicAdr); if (picDt.Rows.Count > 0) { ProfilePic.ImageUrl = picDt.Rows[0][0].ToString(); } else { ProfilePic.ImageUrl = @"~\Images\UploadProfilePicture.PNG"; } //get user history information string histInfoQuery = DataProvider.LoggedInPage.getHistoryInfo((string)Session["User"]); DataTable histDt = HospitalClass.getDataTable(histInfoQuery); //populate user history table if (histDt.Rows.Count > 0) { for (int i = 0; i < histDt.Rows.Count; i++) { TableRow row = new TableRow(); for (int j = 0; j <= histDt.Columns.Count; j++) { TableCell cell = new TableCell(); if (j == 0) { cell.Text = (i + 1).ToString(); } else { if (!DBNull.Value.Equals(histDt.Rows[i][j - 1])) { cell.Text = histDt.Rows[i][j - 1].ToString(); } else { cell.Text = ""; } } row.Cells.Add(cell); } HistoryTable.Rows.Add(row); } } //get general information pertaining to user string userSubstring = ""; if (Session["User"].ToString().StartsWith("SUP") || Session["User"].ToString().StartsWith("ADM")) { userSubstring = ""; //gets all information } else { userSubstring = ((string)Session["User"]).Substring(0, 2); //gets related information } string generalInfoQuery = DataProvider.LoggedInPage.getGeneralInfo(userSubstring); DataTable genInfoDt = HospitalClass.getDataTable(generalInfoQuery); //populate information table if (genInfoDt.Rows.Count > 0) { for (int i = 0; i < genInfoDt.Rows.Count; i++) { TableRow row = new TableRow(); for (int j = 0; j <= genInfoDt.Columns.Count; j++) { TableCell cell = new TableCell(); if (j == 0) { cell.Text = (i + 1).ToString(); } else { if (!DBNull.Value.Equals(genInfoDt.Rows[i][j - 1])) { cell.Text = genInfoDt.Rows[i][j - 1].ToString(); } else { cell.Text = ""; } } row.Cells.Add(cell); } InformationTable.Rows.Add(row); } } } catch (Exception ex) { WelcomeLabel.CssClass = "error"; WelcomeLabel.Text += " (An error has occured)"; HospitalClass.Log(ex); } }
protected void DivModifyButton_Click(object sender, EventArgs e) { try { addDelDiv.Visible = true; //check for changes bool check = DivNameBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DeptNameLabel")).Text.ToUpper(); check = check && DivIdBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DeptIdLabel")).Text.ToUpper(); check = check && DivDescBox.Text == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DeptDescLabel")).Text; //check for existence string checkDeptIdName = DataProvider.Departments.deptIdName(DivIdBox.Text.Trim().ToUpper(), HospitalClass.PascalCasing(DivNameBox.Text.Trim())); DataTable dt = HospitalClass.getDataTable(checkDeptIdName); //check fo acceptance of change bool check2 = DivNameBox.Text.ToUpper() != ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DeptNameLabel")).Text.ToUpper(); check2 = check2 && DivIdBox.Text.ToUpper() != ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DeptIdLabel")).Text.ToUpper(); if (DivNameBox.Text.Trim().Length >= 2 && DivDescBox.Text.Length >= 3 && DivIdBox.Text.Trim().Length >= 1 && !check && ((check2 && dt.Rows.Count == 0) || (!check2 && dt.Rows.Count == 1))) { string updaterId = "", updateCode = "DEPT_UPD"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } List <string> values = new List <string>(); values.Add(DivIdBox.Text.Trim().ToUpper()); values.Add(HospitalClass.PascalCasing(DivNameBox.Text.Trim())); values.Add(((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DeptNameLabel")).Text); values.Add(DivDescBox.Text); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add("update"); int status = DataConsumer.executeProcedure("dept_proc", values); StatusLabel.CssClass = "success normal"; StatusLabel.Text = "Successful ward modification.<br/>Department ID: " + DivIdBox.Text.Trim().ToUpper() + "<br/>Department Name:" + HospitalClass.PascalCasing(DivNameBox.Text.Trim()) + "."; addDelDiv.Visible = false; SortButton_Click(new object(), new EventArgs()); ListView1.SelectedIndex = -1; } else { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "User input error below"; DivStatusLabel.CssClass = "error normal"; if (DivNameBox.Text.Trim().Length < 2) { DivStatusLabel.Text = "Enter a valid department name"; } else if (DivDescBox.Text.Length < 3) { DivStatusLabel.Text = "Enter a valid department description"; } else if (DivIdBox.Text.Trim().Length < 1) { DivStatusLabel.Text = "Enter a department ID"; } else if (check) { DivStatusLabel.Text = "No change made"; } else { DivStatusLabel.Text = "Department ID/name already exists for another department"; } } } catch (Exception ex) { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void DivAddButton_Click(object sender, EventArgs e) { try { addDelDiv.Visible = true; if (DivNameBox.Text.Trim().Length >= 2 && DivDescBox.Text.Length >= 3 && DivIdBox.Text.Trim().Length >= 1) { //check for existence string checkDeptIdName = DataProvider.Departments.deptIdName(DivIdBox.Text.Trim().ToUpper(), HospitalClass.PascalCasing(DivNameBox.Text.Trim())); DataTable dt = HospitalClass.getDataTable(checkDeptIdName); if (dt.Rows.Count == 0) { string updaterId = "", updateCode = "DEPT_ADD"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } List <string> values = new List <string>(); values.Add(DivIdBox.Text.Trim().ToUpper()); values.Add(HospitalClass.PascalCasing(DivNameBox.Text.Trim())); values.Add(""); values.Add(DivDescBox.Text); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add("insert"); int status = DataConsumer.executeProcedure("dept_proc", values); DivStatusLabel.CssClass = "success normal"; DivStatusLabel.Text = "Successful ward addition. <br/>Department ID: " + DivIdBox.Text.Trim().ToUpper() + "<br/>Department Name:" + HospitalClass.PascalCasing(DivNameBox.Text.Trim()) + "."; StatusLabel.CssClass = "success paraNormal"; StatusLabel.Text = "Done"; SortButton_Click(new object(), new EventArgs()); } else { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "User input error below"; DivStatusLabel.CssClass = "error normal"; if (dt.Rows[0][0].ToString() == DivIdBox.Text.Trim().ToUpper()) { DivStatusLabel.Text = "Department ID already exists"; } else { DivStatusLabel.Text = "Department name already exists"; } } } else { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "User input error below"; DivStatusLabel.CssClass = "error normal"; if (DivIdBox.Text.Trim().Length < 1) { DivStatusLabel.Text = "Enter a valid department id"; } else if (DivNameBox.Text.Length < 2) { DivStatusLabel.Text = "Enter a valid department name"; } else { DivStatusLabel.Text = "Enter a valid department description"; } } ListView1.SelectedIndex = -1; } catch (Exception ex) { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void Populate() { string tableName = ""; if (UserIdBox.Text.StartsWith("SUP")) { tableName = "superusers"; } else { tableName = "administrators"; } string infoQuery = DataProvider.UpdateRegistration.getInfo(tableName, UserIdBox.Text.Trim().ToUpper()); DataTable dt = HospitalClass.getDataTable(infoQuery); if (dt.Rows.Count > 0) { if (!DBNull.Value.Equals(dt.Rows[0]["FIRST_NAME"])) { FirstNameBox.Text = (string)dt.Rows[0]["FIRST_NAME"]; } if (!DBNull.Value.Equals(dt.Rows[0]["LAST_NAME"])) { LastNameBox.Text = (string)dt.Rows[0]["LAST_NAME"]; } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_NAME"])) { OtherNameBox.Text = (string)dt.Rows[0]["OTHER_NAME"]; } if (!DBNull.Value.Equals(dt.Rows[0]["GENDER"])) { if ((string)dt.Rows[0]["GENDER"] == "Male") { GenderList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["GENDER"] == "Female") { GenderList.SelectedIndex = 2; } else { GenderList.SelectedIndex = 3; } } if (!DBNull.Value.Equals(dt.Rows[0]["DOB"])) //6 { DateTime dob = (DateTime)dt.Rows[0]["DOB"]; DobBox.Text = dob.ToString("dd/MM/yyyy"); } if (!DBNull.Value.Equals(dt.Rows[0]["MARITAL_STAT"])) { if ((string)dt.Rows[0]["MARITAL_STAT"] == "Single") { MaritalList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["MARITAL_STAT"] == "Married") { MaritalList.SelectedIndex = 2; } else { MaritalList.SelectedIndex = 3; } } if (!DBNull.Value.Equals(dt.Rows[0]["COUNTRY_ORI"])) { CountryOriBox.Text = (string)dt.Rows[0]["COUNTRY_ORI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["STATE_ORI"])) { StateOriBox.Text = (string)dt.Rows[0]["STATE_ORI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["LGA_ORI"])) { LocalOriBox.Text = (string)dt.Rows[0]["LGA_ORI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["PHONE_NO"])) { PhoneBox.Text = (string)dt.Rows[0]["PHONE_NO"]; //11 } if (!DBNull.Value.Equals(dt.Rows[0]["EMAIL"])) { EmailBox.Text = (string)dt.Rows[0]["EMAIL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["COUNTRY_RES"])) { CountryResBox.Text = (string)dt.Rows[0]["COUNTRY_RES"]; } if (!DBNull.Value.Equals(dt.Rows[0]["STATE_RES"])) { StateResBox.Text = (string)dt.Rows[0]["STATE_RES"]; } if (!DBNull.Value.Equals(dt.Rows[0]["LGA_RES"])) { LocalResBox.Text = (string)dt.Rows[0]["LGA_RES"]; } if (!DBNull.Value.Equals(dt.Rows[0]["HOME_ADR"])) { HomeAdrBox.Text = (string)dt.Rows[0]["HOME_ADR"]; //16 } if (!DBNull.Value.Equals(dt.Rows[0]["ID_TYPE"])) { if ((string)dt.Rows[0]["ID_TYPE"] == "National Id") { IdTypeList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["ID_TYPE"] == "School Id") { IdTypeList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["ID_TYPE"] == "Voters Card") { IdTypeList.SelectedIndex = 3; } else { IdTypeList.SelectedIndex = 4; } } if (!DBNull.Value.Equals(dt.Rows[0]["ID_NO"])) { IdNoBox.Text = (string)dt.Rows[0]["ID_NO"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NEXT_OF_KIN"])) { NextNameBox.Text = (string)dt.Rows[0]["NEXT_OF_KIN"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_OF_KIN_REL"])) { NextRelBox.Text = (string)dt.Rows[0]["NXT_OF_KIN_REL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_PHONE_NO"])) { NextPhoneBox.Text = (string)dt.Rows[0]["NXT_PHONE_NO"]; //21 } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_EMAIL"])) { NextEmailBox.Text = (string)dt.Rows[0]["NXT_EMAIL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_ADR"])) { NextAdrBox.Text = (string)dt.Rows[0]["NXT_ADR"]; } if (!DBNull.Value.Equals(dt.Rows[0]["GENOTYPE"])) { if ((string)dt.Rows[0]["GENOTYPE"] == "AA") { TypeList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["GENOTYPE"] == "AS") { TypeList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["GENOTYPE"] == "SS") { TypeList.SelectedIndex = 3; } else { TypeList.SelectedIndex = 4; } } if (!DBNull.Value.Equals(dt.Rows[0]["BLOOD_GRP"])) { if ((string)dt.Rows[0]["BLOOD_GRP"] == "A") { GroupList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["BLOOD_GRP"] == "B") { GroupList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["BLOOD_GRP"] == "AB") { GroupList.SelectedIndex = 3; } else if ((string)dt.Rows[0]["BLOOD_GRP"] == "O") { GroupList.SelectedIndex = 4; } else { TypeList.SelectedIndex = 5; } } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_INFO"])) { OtherInfoBox.Text = (string)dt.Rows[0]["OTHER_INFO"]; //26 } if (!DBNull.Value.Equals(dt.Rows[0]["SCHL_ID_NO"])) { SchoolIdBox.Text = (string)dt.Rows[0]["SCHL_ID_NO"]; } if (!DBNull.Value.Equals(dt.Rows[0]["PRI_SCHL"])) { PriBox.Text = (string)dt.Rows[0]["PRI_SCHL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["PRI_CERT"])) { if ((string)dt.Rows[0]["PRI_CERT"] == "First School Leaving Certificate (FSLT)") { PriList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["PRI_CERT"] == "None") { PriList.SelectedIndex = 2; } else { PriList.SelectedIndex = 3; } } if (!DBNull.Value.Equals(dt.Rows[0]["SEC_SCHL"])) { SecBox.Text = (string)dt.Rows[0]["SEC_SCHL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["SEC_CERT"])) //31 { if ((string)dt.Rows[0]["SEC_CERT"] == "WASSCE/WAEC") { SecList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["SEC_CERT"] == "GCE") { SecList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["SEC_CERT"] == "NECO") { SecList.SelectedIndex = 3; } else if ((string)dt.Rows[0]["SEC_CERT"] == "None") { SecList.SelectedIndex = 4; } else { SecList.SelectedIndex = 5; } } if (!DBNull.Value.Equals(dt.Rows[0]["UNI"])) { UniBox.Text = (string)dt.Rows[0]["UNI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["UNI_CERT"])) { if ((string)dt.Rows[0]["UNI_CERT"] == "Pass (Doctor)") { UniList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["UNI_CERT"] == "First Class") { UniList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Second class, Upper Division") { UniList.SelectedIndex = 3; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Second class, Lower division") { UniList.SelectedIndex = 4; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Third Class") { UniList.SelectedIndex = 5; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Pass (Staff)") { UniList.SelectedIndex = 6; } else if ((string)dt.Rows[0]["UNI_CERT"] == "None") { UniList.SelectedIndex = 7; } else { UniList.SelectedIndex = 8; } } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_INST1"])) { OtherBox1.Text = (string)dt.Rows[0]["OTHER_INST1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_CERT1"])) { OtherCert1.Text = (string)dt.Rows[0]["OTHER_CERT1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_INST2"])) { OtherBox2.Text = (string)dt.Rows[0]["OTHER_INST2"]; //36 } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_CERT2"])) { OtherCert2.Text = (string)dt.Rows[0]["OTHER_CERT2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_NAME1"])) { RefNameBox1.Text = (string)dt.Rows[0]["REF_NAME1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_OF_KIN_REL1"])) { RefRelBox1.Text = (string)dt.Rows[0]["REF_OF_KIN_REL1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_PHONE_NO1"])) { RefPhoneBox1.Text = (string)dt.Rows[0]["REF_PHONE_NO1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_EMAIL1"])) { RefEmailBox1.Text = (string)dt.Rows[0]["REF_EMAIL1"]; //41 } if (!DBNull.Value.Equals(dt.Rows[0]["REF_ADR1"])) { RefAdrBox1.Text = (string)dt.Rows[0]["REF_ADR1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_NAME2"])) { RefNameBox2.Text = (string)dt.Rows[0]["REF_NAME2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_OF_KIN_REL2"])) { RefRelBox2.Text = (string)dt.Rows[0]["REF_OF_KIN_REL2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_PHONE_NO2"])) { RefPhoneBox2.Text = (string)dt.Rows[0]["REF_PHONE_NO2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_EMAIL2"])) { RefEmailBox2.Text = (string)dt.Rows[0]["REF_EMAIL2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_ADR2"])) { RefAdrBox2.Text = (string)dt.Rows[0]["REF_ADR2"]; } } else //not going to happen due to access restrictions { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "User does not exist"; } }
protected void ValidateButton_Click(object sender, EventArgs e) { try { //check if the user id is within the necessary bounds string lastIdQuery = DataProvider.RegAdminSup.LastIdQuery(UserIdBox.Text.Trim().Substring(0, 3)); DataTable lastDt = HospitalClass.getDataTable(lastIdQuery); string lastPossibleId = getNewSuperuserAdminId(lastDt); if (GenderList.SelectedIndex != 0 && MaritalList.SelectedIndex != 0 && IdTypeList.SelectedIndex != 0 && TypeList.SelectedIndex != 0 && GroupList.SelectedIndex != 0 && PriList.SelectedIndex != 0 && SecList.SelectedIndex != 0 && UniList.SelectedIndex != 0 && int.Parse(lastPossibleId.Substring(3, 3)) >= int.Parse(UserIdBox.Text.Trim().Substring(3, 3))) { string userId = UserIdBox.Text; string updaterId = (string)Session["SuperUser"]; string updateCode = ""; string operation = ""; bool execute = true; if (int.Parse(lastPossibleId.Substring(3, 3)) == int.Parse(UserIdBox.Text.Trim().Substring(3, 3))) { operation = "insert"; if (UserIdBox.Text.ToUpper().Trim().StartsWith("SUP")) { updateCode = "SUP_REG"; } else { updateCode = "ADM_REG"; } string existQuery = DataProvider.RegAdminSup.ExistQuery(EmailBox.Text.ToUpper().Trim()); DataTable emailDt = HospitalClass.getDataTable(existQuery); if (emailDt.Rows.Count > 0) { execute = false; StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "This email address is already registered"; } } else { operation = "update"; if (UserIdBox.Text.ToUpper().Trim().StartsWith("SUP")) { updateCode = "SUP_UPD"; } else { updateCode = "ADM_UPD"; } if (UserIdBox.Text.StartsWith("SUP") && UserIdBox.Text != Session["SuperUser"].ToString()) { execute = false; StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "You cannot update this user's information"; } } if (execute) { List <string> values = new List <string>(); values.Add(GroupList.SelectedItem.Text); //1 values.Add(TypeList.SelectedItem.Text); values.Add(CountryOriBox.Text); values.Add(CountryResBox.Text); values.Add(DobBox.Text); values.Add(EmailBox.Text.Trim()); //6 values.Add(FirstNameBox.Text.Trim()); values.Add(GenderList.SelectedItem.Text); values.Add(HomeAdrBox.Text); values.Add(IdNoBox.Text); values.Add(IdTypeList.SelectedItem.Text); //11 values.Add(LastNameBox.Text); values.Add(LocalOriBox.Text); values.Add(LocalResBox.Text); values.Add(MaritalList.SelectedItem.Text); values.Add(NextAdrBox.Text); //16 values.Add(NextEmailBox.Text); values.Add(NextNameBox.Text); values.Add(NextRelBox.Text); values.Add(NextPhoneBox.Text); values.Add(OtherNameBox.Text); //21 values.Add(PhoneBox.Text); values.Add(SchoolIdBox.Text); values.Add(StateOriBox.Text); values.Add(StateResBox.Text); values.Add(OtherInfoBox.Text); //26 values.Add(PriBox.Text); values.Add(PriList.SelectedItem.Text); values.Add(SecBox.Text); values.Add(SecList.SelectedItem.Text); values.Add(UniBox.Text); //31 values.Add(UniList.SelectedItem.Text); values.Add(OtherBox1.Text); values.Add(OtherCert1.Text); values.Add(OtherBox2.Text); values.Add(OtherCert2.Text); //36 values.Add(RefNameBox1.Text); values.Add(RefRelBox1.Text); values.Add(RefPhoneBox1.Text); values.Add(RefEmailBox1.Text); values.Add(RefAdrBox1.Text); //41 values.Add(RefNameBox2.Text); values.Add(RefRelBox2.Text); values.Add(RefPhoneBox2.Text); values.Add(RefEmailBox2.Text); values.Add(RefAdrBox2.Text); //46 values.Add(updateCode); values.Add(updaterId); values.Add(userId.ToUpper().Trim()); values.Add(HospitalClass.Encrypt(PasswordBox.Text)); values.Add(HospitalClass.getTransactionId()); values.Add(operation); //52 int status = DataConsumer.executeProcedure("superuser_admin_val", values); Session["FirstName"] = FirstNameBox.Text; StatusLabel.Text = "Operation Successful.<br/>Performer: " + updaterId + ".<br/>Operation: " + operation; StatusLabel.CssClass = "success paraNormal"; } } else { StatusLabel.CssClass = "error paraNormal"; if (int.Parse(lastPossibleId.Substring(3, 3)) < int.Parse(UserIdBox.Text.Trim().Substring(3, 3))) { StatusLabel.Text = "Invalid User Id. Perform a new registration"; } else if (GenderList.SelectedIndex == 0) { StatusLabel.Text = "Please select your gender"; } else if (MaritalList.SelectedIndex == 0) { StatusLabel.Text = "Please select your marital status"; } else if (IdTypeList.SelectedIndex == 0) { StatusLabel.Text = "Please select your Identificaton type"; } else if (TypeList.SelectedIndex == 0) { StatusLabel.Text = "Please select your blood type"; } else if (GroupList.SelectedIndex == 0) { StatusLabel.Text = "Please select your blood group"; } else if (PriList.SelectedIndex == 0) { StatusLabel.Text = "Please select your primary school certificate. (Select none if unavailable)"; } else if (SecList.SelectedIndex == 0) { StatusLabel.Text = "Please select your secondary school certificate. (Select none if unavailable)"; } else { StatusLabel.Text = "Please select your university certificate grade. (Select none if unavailable)"; } } } catch (Exception ex) { StatusLabel.CssClass = "error normal"; StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void ExecuteButton_Click(object sender, EventArgs e) { try { TableDiv.Visible = false; //visisbility depends on operation if (QueryBox.Text.Trim().Length > 6) { StatusLabel.CssClass = "success"; string query = QueryBox.Text.Trim().Substring(0, 6).ToUpper(); string updatecode = query; if (query == "SELECT") { DataTable dt = HospitalClass.getDataTable(QueryBox.Text.Trim()); TableLabel.Text = HospitalClass.drawDataTableInHtml(dt, 1036); //draw the data table on a label control as html TableDiv.Visible = true; StatusLabel.CssClass = "success paraNormal"; StatusLabel.Text = "Successful."; } else { int status = DataConsumer.executeQuery(QueryBox.Text.Trim()); StatusLabel.Text = "Successful.<br/>Rows affected: " + status + "Rows."; if (System.Text.RegularExpressions.Regex.IsMatch(query, "(^(DROP)|(TRUNC)|(DELETE))")) { updatecode = "DELETE"; } if (!(query == "CREATE" || query == "INSERT" || query == "UPDATE" || System.Text.RegularExpressions.Regex.IsMatch(query, "(^(DROP)|(TRUNC)|(DELETE))"))) { updatecode = "OTHER"; } } TransBox.Text = HospitalClass.getTransactionId(); if (UpdCodeOverrideBox.Text.Trim().Length == 0) { UpdateCodeBox.Text = "A_" + updatecode; } else { UpdateCodeBox.Text = UpdCodeOverrideBox.Text; } UpdaterBox.Text = Session["SuperUser"].ToString(); UserIdBox.Text = Session["User"].ToString(); DateUpdBox.Text = DateTime.Now.ToShortDateString() + ", " + DateTime.Now.ToLongTimeString(); if (AuditCheckBox.Checked) { List <string> values = new List <string>(); values.Add(TransBox.Text); values.Add(UpdateCodeBox.Text); values.Add(UpdaterBox.Text); values.Add(UserIdBox.Text); int status = DataConsumer.executeProcedure("audit_trail_proc", values); AuditLabel.CssClass = "success"; AuditLabel.Text = "ADDED"; } else { AuditLabel.ForeColor = System.Drawing.Color.Brown; AuditLabel.Text = "NOT ADDED"; } } else { StatusLabel.CssClass = "error"; StatusLabel.Text = "Invalid query"; } } catch (Exception ex) { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "Error: " + ex.Message; if (ex.GetType().ToString() != "System.Data.OracleClient.OracleException") { HospitalClass.Log(ex); } } }
protected void Page_Load(object sender, EventArgs e) { try { //redirect if not logged in if (Session["Admin"] == null && Session["SuperUser"] == null && Session["User"] == null) { Response.Redirect("~/Login.aspx"); } //Only SuperUser and admin has access to validate if ((Session["SuperUser"] == null && Session["Admin"] == null) || (Session["User"].ToString().StartsWith("SUP") || Session["User"].ToString().StartsWith("ADM"))) { ValidateButton.Visible = false; ReadOnly(); StatusLabel.CssClass = "error paraNormal"; StatusLabel.ForeColor = System.Drawing.Color.Black; if (Session["SuperUser"] == null && Session["Admin"] == null) { StatusLabel.Text = "Note: Meet the system administrator to make modifications"; } else { StatusLabel.Text = "Note: This user cannot be validated here.<br/>Meet the super user for modification."; } } else { ValidateButton.Visible = true; } if (Session["User"].ToString().StartsWith("PAT")) { EduRefTable.Visible = false; //remove eduucation and referee table for patients } if (Session["User"].ToString().StartsWith("DC") || Session["User"].ToString().StartsWith("ST")) { OtherInfoLabel.Text = "About yourself"; } //populate form controls if (!IsPostBack) { string infoQuery = DataProvider.UpdateRegistration.getInfo //get user information from the database (HospitalClass.getTableName(Session["User"].ToString().Substring(0, 2)), Session["User"].ToString()); DataTable dt = HospitalClass.getDataTable(infoQuery); UserIdBox.Text = Session["User"].ToString(); //1 FirstNameBox.Text = DBNull.Value.Equals(dt.Rows[0]["FIRST_NAME"]) ? "" : (string)dt.Rows[0]["FIRST_NAME"]; if (!DBNull.Value.Equals(dt.Rows[0]["LAST_NAME"])) { LastNameBox.Text = (string)dt.Rows[0]["LAST_NAME"]; } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_NAME"])) { OtherNameBox.Text = (string)dt.Rows[0]["OTHER_NAME"]; } if (!DBNull.Value.Equals(dt.Rows[0]["GENDER"])) { if ((string)dt.Rows[0]["GENDER"] == "Male") { GenderList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["GENDER"] == "Female") { GenderList.SelectedIndex = 2; } else { GenderList.SelectedIndex = 3; } } if (!DBNull.Value.Equals(dt.Rows[0]["DOB"])) //6 { DateTime dob = (DateTime)dt.Rows[0]["DOB"]; DobBox.Text = dob.ToString("dd/MM/yyyy"); } if (!DBNull.Value.Equals(dt.Rows[0]["MARITAL_STAT"])) { if ((string)dt.Rows[0]["MARITAL_STAT"] == "Single") { MaritalList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["MARITAL_STAT"] == "Married") { MaritalList.SelectedIndex = 2; } else { MaritalList.SelectedIndex = 3; } } if (!DBNull.Value.Equals(dt.Rows[0]["COUNTRY_ORI"])) { CountryOriBox.Text = (string)dt.Rows[0]["COUNTRY_ORI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["STATE_ORI"])) { StateOriBox.Text = (string)dt.Rows[0]["STATE_ORI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["LGA_ORI"])) { LocalOriBox.Text = (string)dt.Rows[0]["LGA_ORI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["PHONE_NO"])) { PhoneBox.Text = (string)dt.Rows[0]["PHONE_NO"]; //11 } if (!DBNull.Value.Equals(dt.Rows[0]["EMAIL"])) { EmailBox.Text = (string)dt.Rows[0]["EMAIL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["COUNTRY_RES"])) { CountryResBox.Text = (string)dt.Rows[0]["COUNTRY_RES"]; } if (!DBNull.Value.Equals(dt.Rows[0]["STATE_RES"])) { StateResBox.Text = (string)dt.Rows[0]["STATE_RES"]; } if (!DBNull.Value.Equals(dt.Rows[0]["LGA_RES"])) { LocalResBox.Text = (string)dt.Rows[0]["LGA_RES"]; } if (!DBNull.Value.Equals(dt.Rows[0]["HOME_ADR"])) { HomeAdrBox.Text = (string)dt.Rows[0]["HOME_ADR"]; //16 } if (!DBNull.Value.Equals(dt.Rows[0]["ID_TYPE"])) { if ((string)dt.Rows[0]["ID_TYPE"] == "National Id") { IdTypeList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["ID_TYPE"] == "School Id") { IdTypeList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["ID_TYPE"] == "Voters Card") { IdTypeList.SelectedIndex = 3; } else { IdTypeList.SelectedIndex = 4; } } if (!DBNull.Value.Equals(dt.Rows[0]["ID_NO"])) { IdNoBox.Text = (string)dt.Rows[0]["ID_NO"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NEXT_OF_KIN"])) { NextNameBox.Text = (string)dt.Rows[0]["NEXT_OF_KIN"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_OF_KIN_REL"])) { NextRelBox.Text = (string)dt.Rows[0]["NXT_OF_KIN_REL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_PHONE_NO"])) { NextPhoneBox.Text = (string)dt.Rows[0]["NXT_PHONE_NO"]; //21 } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_EMAIL"])) { NextEmailBox.Text = (string)dt.Rows[0]["NXT_EMAIL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["NXT_ADR"])) { NextAdrBox.Text = (string)dt.Rows[0]["NXT_ADR"]; } if (!DBNull.Value.Equals(dt.Rows[0]["GENOTYPE"])) { if ((string)dt.Rows[0]["GENOTYPE"] == "AA") { TypeList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["GENOTYPE"] == "AS") { TypeList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["GENOTYPE"] == "SS") { TypeList.SelectedIndex = 3; } else { TypeList.SelectedIndex = 4; } } if (!DBNull.Value.Equals(dt.Rows[0]["BLOOD_GRP"])) { if ((string)dt.Rows[0]["BLOOD_GRP"] == "A") { GroupList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["BLOOD_GRP"] == "B") { GroupList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["BLOOD_GRP"] == "AB") { GroupList.SelectedIndex = 3; } else if ((string)dt.Rows[0]["BLOOD_GRP"] == "O") { GroupList.SelectedIndex = 4; } else { TypeList.SelectedIndex = 5; } } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_INFO"])) { OtherInfoBox.Text = (string)dt.Rows[0]["OTHER_INFO"]; //26 } if (Session["User"].ToString().StartsWith("PAT")) //for patients { if (!DBNull.Value.Equals(dt.Rows[0]["MATRIC_NO"])) { SchoolIdBox.Text = (string)dt.Rows[0]["MATRIC_NO"]; //27 } } else //for other users { if (!DBNull.Value.Equals(dt.Rows[0]["SCHL_ID_NO"])) { SchoolIdBox.Text = (string)dt.Rows[0]["SCHL_ID_NO"]; //27 } if (!DBNull.Value.Equals(dt.Rows[0]["PRI_SCHL"])) { PriBox.Text = (string)dt.Rows[0]["PRI_SCHL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["PRI_CERT"])) { if ((string)dt.Rows[0]["PRI_CERT"] == "First School Leaving Certificate (FSLT)") { PriList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["PRI_CERT"] == "None") { PriList.SelectedIndex = 2; } else { PriList.SelectedIndex = 3; } } if (!DBNull.Value.Equals(dt.Rows[0]["SEC_SCHL"])) { SecBox.Text = (string)dt.Rows[0]["SEC_SCHL"]; } if (!DBNull.Value.Equals(dt.Rows[0]["SEC_CERT"])) //31 { if ((string)dt.Rows[0]["SEC_CERT"] == "WASSCE/WAEC") { SecList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["SEC_CERT"] == "GCE") { SecList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["SEC_CERT"] == "NECO") { SecList.SelectedIndex = 3; } else if ((string)dt.Rows[0]["SEC_CERT"] == "None") { SecList.SelectedIndex = 4; } else { SecList.SelectedIndex = 5; } } if (!DBNull.Value.Equals(dt.Rows[0]["UNI"])) { UniBox.Text = (string)dt.Rows[0]["UNI"]; } if (!DBNull.Value.Equals(dt.Rows[0]["UNI_CERT"])) { if ((string)dt.Rows[0]["UNI_CERT"] == "Pass (Doctor)") { UniList.SelectedIndex = 1; } else if ((string)dt.Rows[0]["UNI_CERT"] == "First Class") { UniList.SelectedIndex = 2; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Second class, Upper Division") { UniList.SelectedIndex = 3; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Second class, Lower division") { UniList.SelectedIndex = 4; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Third Class") { UniList.SelectedIndex = 5; } else if ((string)dt.Rows[0]["UNI_CERT"] == "Pass (Staff)") { UniList.SelectedIndex = 6; } else if ((string)dt.Rows[0]["UNI_CERT"] == "None") { UniList.SelectedIndex = 7; } else { UniList.SelectedIndex = 8; } } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_INST1"])) { OtherBox1.Text = (string)dt.Rows[0]["OTHER_INST1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_CERT1"])) { OtherCert1.Text = (string)dt.Rows[0]["OTHER_CERT1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_INST2"])) { OtherBox2.Text = (string)dt.Rows[0]["OTHER_INST2"]; //36 } if (!DBNull.Value.Equals(dt.Rows[0]["OTHER_CERT2"])) { OtherCert2.Text = (string)dt.Rows[0]["OTHER_CERT2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_NAME1"])) { RefNameBox1.Text = (string)dt.Rows[0]["REF_NAME1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_OF_KIN_REL1"])) { RefRelBox1.Text = (string)dt.Rows[0]["REF_OF_KIN_REL1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_PHONE_NO1"])) { RefPhoneBox1.Text = (string)dt.Rows[0]["REF_PHONE_NO1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_EMAIL1"])) { RefEmailBox1.Text = (string)dt.Rows[0]["REF_EMAIL1"]; //41 } if (!DBNull.Value.Equals(dt.Rows[0]["REF_ADR1"])) { RefAdrBox1.Text = (string)dt.Rows[0]["REF_ADR1"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_NAME2"])) { RefNameBox2.Text = (string)dt.Rows[0]["REF_NAME2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_OF_KIN_REL2"])) { RefRelBox2.Text = (string)dt.Rows[0]["REF_OF_KIN_REL2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_PHONE_NO2"])) { RefPhoneBox2.Text = (string)dt.Rows[0]["REF_PHONE_NO2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_EMAIL2"])) { RefEmailBox2.Text = (string)dt.Rows[0]["REF_EMAIL2"]; } if (!DBNull.Value.Equals(dt.Rows[0]["REF_ADR2"])) { RefAdrBox2.Text = (string)dt.Rows[0]["REF_ADR2"]; //47 } } } } catch (Exception ex) { StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void SubmitButton_Click(object sender, EventArgs e) { try { StatusDiv.Visible = true; StatusLabel.Visible = true; bool buttonChk; if (DocRadioButton.Checked) { buttonChk = DocRoleList.SelectedIndex != 0; } else if (StfRadioButton.Checked) { buttonChk = StfRoleList.SelectedIndex != 0; } else { buttonChk = true; } string existQuery = DataProvider.RegistrationPage.ExistQuery(EmailBox.Text.ToUpper().Trim()); DataTable dt = HospitalClass.getDataTable(existQuery); bool checkName = HospitalClass.sqlProtect(FirstNameBox.Text); bool checkPassword = HospitalClass.sqlProtect(PasswordBox.Text); if (buttonChk && GenderList.SelectedIndex != 0 && dt.Rows.Count == 0 && checkName && checkPassword) //validate selection of drop down list values { if (DocRadioButton.Checked == true) { role = DocRoleList.SelectedItem.Value; updateCode = "DOC_REG"; } else if (StfRadioButton.Checked == true) { role = StfRoleList.SelectedItem.Value; updateCode = "STF_REG"; } else { role = "PAT"; updateCode = "PAT_REG";; } string month, year; if (DateTime.Now.Month < 10) { month = "0" + DateTime.Now.Month; } else { month = DateTime.Now.Month.ToString(); } year = (DateTime.Now.Year.ToString()).Remove(0, 2); string lastIdQuery = DataProvider.RegistrationPage.LastIdQuery(role.Remove(2)); DataTable lastDt = HospitalClass.getDataTable(lastIdQuery); if (lastDt.Rows.Count == 0) //first role user registration { if (PatientRadioButton.Checked || !CheckBoxDiv.Visible) { userId = role + month + year + "0001"; } else { userId = role + month + year + "001"; } } else //generate new id for patient, doctor or staff { string lastId = (string)lastDt.Rows[0][0]; string editId; if (PatientRadioButton.Checked || !CheckBoxDiv.Visible) { editId = lastId.Remove(0, lastId.Length - 4); } else { editId = lastId.Remove(0, lastId.Length - 3); } int newIdInt = int.Parse(editId) + 1; string newId; if (newIdInt < 10) { newId = editId.Remove(editId.Length - 1) + newIdInt.ToString(); } else if (newIdInt < 100) { newId = editId.Remove(editId.Length - 2) + newIdInt.ToString(); } else if (newIdInt < 1000) { newId = editId.Remove(editId.Length - 3) + newIdInt.ToString(); } else { newId = newIdInt.ToString(); } userId = role + month + year + newId; } if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else if (Session["Admin"] != null) { updaterId = (string)Session["Admin"]; } else { updaterId = userId; } List <string> values = new List <string>(); values.Add(EmailBox.Text.Trim()); values.Add(FirstNameBox.Text.Trim()); values.Add(GenderList.SelectedItem.Text); values.Add(LastnameBox.Text.Trim()); values.Add(OtherNameBox.Text.Trim()); values.Add(HospitalClass.Encrypt(PasswordBox.Text)); values.Add(PhoneBox.Text); values.Add(updateCode); values.Add(updaterId); values.Add(userId); values.Add(HospitalClass.getTransactionId()); int status = DataConsumer.executeProcedure("initial_reg", values); StatusLabel.CssClass = "success big"; StatusLabel.Text = "You have been successfully registered.<br/>Your ID is: " + userId + ".<br/>"; goToLogin.Visible = true; InfoDiv.Visible = false; RegLabel.Visible = false; CheckBoxDiv.Visible = false; } else { if (!checkName) { StatusLabel.Text = "Unsecure name entry. Please remove all ' and -- symbols"; } else if (!checkPassword) { StatusLabel.Text = "Unsecure password choice. Please remove all ' and -- symbols"; } else if (GenderList.SelectedIndex == 0) { StatusLabel.Text = "Please select your sex"; } else if (dt.Rows.Count > 0) { StatusLabel.Text = "This email address has already been registered"; } else { StatusLabel.Text = "Please choose a classification/role"; } } } catch (Exception ex) { StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void SubmitButton_Click(object sender, EventArgs e) { try { bool checkId = HospitalClass.sqlProtect(UserIdBox.Text); //security for user id input against sqlInjection bool checkPwd = HospitalClass.sqlProtect(PasswordBox.Text); //security for password input against sqlInjection if (UserIdBox.Text.Length != 0 && checkId && checkPwd) { string passwordQuery = DataProvider.LoginPage.PasswordQuery(UserIdBox.Text.ToUpper().Trim()); DataTable dt = HospitalClass.getDataTable(passwordQuery); if (dt.Rows.Count > 0) { string encryptPassword = HospitalClass.Encrypt(PasswordBox.Text); int checkPassword = 0; string userIdPass = ""; foreach (DataRow row in dt.Rows) { if (encryptPassword == row[0].ToString()) //check if password correlate { checkPassword = 1; userIdPass = row[1].ToString(); //check first name repetition } userId = row[1].ToString(); if (userIdPass.Length > 0) { userId = userIdPass; } } if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else if (Session["Admin"] != null) { updaterId = (string)Session["Admin"]; } else { updaterId = userId; } bool rights; if (userId.StartsWith("ADM") || userId.StartsWith("SUP")) { rights = false; } else { rights = true; } //for either a basic user or a privileged user if ((Session["SuperUser"] != null || Session["Admin"] != null || (checkPassword == 1 && rights)) || (!rights && checkPassword == 1)) { bool auditTrailValidator = false; string oldUser = ""; //to check the access of an administrator or a superuser if (Session["SuperUser"] != null) { oldUser = Session["SuperUser"].ToString(); } else if (Session["Admin"] != null) { oldUser = Session["Admin"].ToString(); } Session["User"] = userId; //using linq to datasets to query the datatable (to guard against two users with the same first name) Session["FirstName"] = (from FirstName in dt.AsEnumerable() where FirstName.Field <string>("USER_ID") == userId select FirstName.Field <string>("FIRST_NAME")).First().ToString(); Session["RegStatus"] = (from Status in dt.AsEnumerable() where Status.Field <string>("USER_ID") == userId select Status.Field <string>("STATUS")).First().ToString(); //login for users if ((Session["SuperUser"] != null || Session["Admin"] != null || checkPassword == 1) && rights) { if (userId.StartsWith("PAT")) { updateCode = "PAT_LGN"; } else if (userId.StartsWith("DC")) { updateCode = "DOC_LGN"; } else { updateCode = "STF_LGN"; }; Response.Redirect("~/LoggedInPage.aspx", false); auditTrailValidator = true; } //login for admin and superuser else if (!rights && checkPassword == 1) { if (userId.StartsWith("SUP")) { Session["SuperUser"] = userId; updateCode = "SUP_LGN"; } else { Session["Admin"] = userId; updateCode = "ADM_LGN"; } Response.Redirect("~/LoggedInPage.aspx", false); auditTrailValidator = true; } //extraneous login for superuser and administrator else { //to catch unauthorized access to another privileged user's account if ((Session["SuperUser"] != null && !userId.StartsWith("SUP")) || oldUser == userId) //for privileged user relogin { Session["User"] = userId; if (oldUser == userId) { Session["Info"] = "Welcome Back"; } if (userId.ToUpper().StartsWith("ADM")) { updateCode = "ADM_LGN"; } else { updateCode = "SUP_LGN"; } Response.Redirect("~/LoggedInPage.aspx", false); auditTrailValidator = true; } else { StatusLabel.Text = "You do not have access to this profile"; if (oldUser.StartsWith("SUP")) { Session["User"] = Session["SuperUser"].ToString(); } else { Session["User"] = Session["Admin"].ToString(); } auditTrailValidator = false; } } if (auditTrailValidator) { object[] values = new object[4]; values[0] = (HospitalClass.getTransactionId()); values[1] = (updateCode); values[2] = (updaterId); values[3] = (userId); int status = DataConsumer.executeProc("audit_trail_proc", values); } } else { if (PasswordBox.Text.Length == 0) { StatusLabel.Text = "Please enter your password"; } else { StatusLabel.Text = "Wrong user Id/password combination.<br/>Note: Password is case-sensitive."; } } } else { StatusLabel.Text = "You are not a user on our database. Please register."; } } else { if (UserIdBox.Text.Length == 0) { StatusLabel.Text = "Please enter your user id, first name or email address"; } else if (!checkId) { StatusLabel.Text = "Unsecure user Id"; } else { StatusLabel.Text = "Unsecure password"; } } } catch (Exception ex) { StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); //ex.Logger(); } }
protected void DivAddButton_Click(object sender, EventArgs e) { string check = ""; if (RoleList.SelectedIndex == 0) { check = DataProvider.DoctorStaffHistory.checkExistDoc(DivUserIdBox.Text, DivWorkPlaceBox.Text.Trim(), DivPositionBox.Text.Trim()); } else { check = DataProvider.DoctorStaffHistory.checkExistStf(DivUserIdBox.Text, DivWorkPlaceBox.Text.Trim(), DivPositionBox.Text.Trim()); } System.Data.DataTable dt = HospitalClass.getDataTable(check); bool validateDoc = DivUserIdBox.Text.StartsWith("DC") && RoleList.SelectedIndex == 0; bool validateStf = DivUserIdBox.Text.StartsWith("ST") && RoleList.SelectedIndex == 1; string dateRegex = @"^(?:0[1-9]|[12]\d|3[01])([\/.-])(?:0[1-9]|1[012])\1(?:19|20)\d\d$"; if (DivWorkPlaceBox.Text.Trim().Length > 1 && DivWorkTypeBox.Text.Trim().Length > 1 && DivPositionBox.Text.Trim().Length > 1 && dt.Rows.Count == 0 && Regex.IsMatch(DivStartDateBox.Text.Trim(), dateRegex) && Regex.IsMatch(DivEndDateBox.Text.Trim(), dateRegex) && (validateDoc || validateStf)) { string updaterId = "", updateCode = ""; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } if (RoleList.SelectedIndex == 0) { updateCode = "DOC_WKAD"; } else { updateCode = "STF_WKAD"; } List <string> values = new List <string>(); values.Add(DivWorkPlaceBox.Text.Trim()); values.Add(DivWorkTypeBox.Text.Trim()); values.Add(DivPositionBox.Text.Trim()); values.Add(DivStartDateBox.Text.Trim()); values.Add(DivEndDateBox.Text.Trim()); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(DivUserIdBox.Text); if (RoleList.SelectedIndex == 0) { values.Add("doc insert"); } else { values.Add("stf insert"); } int status = DataConsumer.executeProcedure("docstf_wk_proc", values); DivStatusLabel.CssClass = "success normal"; DivStatusLabel.Text = "Successfully added.<br>Work place: " + DivWorkPlaceBox.Text.Trim() + "."; StatusLabel.CssClass = "success paraNormal"; StatusLabel.Text = "Done"; BindListView(); BindSearchListView(); } else { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "User input error below"; string form = "(Format: 25/12/2000 or 25-12-2000)."; DivStatusLabel.CssClass = "error paraNormal"; if (!(validateDoc || validateStf)) { if (RoleList.SelectedIndex == 0) { DivStatusLabel.Text = "Invalid user. User must be a doctor"; } else { DivStatusLabel.Text = "Invalid user. User must be a staff"; } } else if (dt.Rows.Count > 0) { DivStatusLabel.Text = "This entry already exists"; } else if (DivWorkPlaceBox.Text.Trim().Length <= 1) { DivStatusLabel.Text = "Please enter a valid work place"; } else if (DivWorkTypeBox.Text.Trim().Length <= 1) { DivStatusLabel.Text = "Please enter a valid work type"; } else if (DivPositionBox.Text.Trim().Length <= 1) { DivStatusLabel.Text = "Please enter a valid position"; } else if (!Regex.IsMatch(DivStartDateBox.Text.Trim(), dateRegex)) { DivStatusLabel.Text = "Invalid start date. " + form; } else { DivStatusLabel.Text = "Invalid end date. " + form; } } ListView1.SelectedIndex = -1; }