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; }
protected void ModifyDivButton_Click(object sender, EventArgs e) { string createId = "", organ = ""; bool check = true; if (HoldLabel.Text == "Search") { check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("SearchOrganLabel")).Text == DivOrganList.SelectedItem.Text; check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("SearchDescLabel")).Text == DivDescBox.Text; check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("SearchStatusLabel")).Text == DivStatusList.SelectedItem.Text; createId = ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("SearchIdLabel")).Text; organ = ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("SearchOrganLabel")).Text; } else { check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("OrganLabel")).Text == DivOrganList.SelectedItem.Text; check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DescLabel")).Text == DivDescBox.Text; check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("StatusLabel")).Text == DivStatusList.SelectedItem.Text; createId = ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("IdLabel")).Text; organ = ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("OrganLabel")).Text; } if (!check && DivStatusList.SelectedIndex != 0) { string updaterId = "", updateCode = "DISB_UPD"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } List <string> values = new List <string>(); values.Add(DivOrganList.SelectedItem.Text); values.Add(DivDescBox.Text); values.Add(DivStatusList.SelectedItem.Text); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(createId); values.Add("update"); int status = DataConsumer.executeProcedure("pat_disab_proc", values); addDelDiv.Visible = false; ListView1.SelectedIndex = -1; SearchListView.SelectedIndex = -1; StatusLabel.CssClass = "success normal"; StatusLabel.Text = "Successful update.<br/>User Id: " + DivUserIdBox.Text + "<br/>Organ: " + organ; BindListView(); BindSearchListView(); } else { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "User input error below"; DivStatusLabel.CssClass = "error paraNormal"; if (check) { DivStatusLabel.Text = "No changes made"; } else { DivStatusLabel.Text = "Please select a treatment status"; } } }
protected void ModifyDivButton_Click(object sender, EventArgs e) { string createId = "", workPlace = ""; string dateRegex = @"^(?:0[1-9]|[12]\d|3[01])([\/.-])(?:0[1-9]|1[012])\1(?:19|20)\d\d$"; bool check = true; if (HoldLabel.Text == "Search") { check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("WorkPlaceLabel")).Text == DivWorkPlaceBox.Text; check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("WorkTypeLabel")).Text == DivWorkTypeBox.Text; check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("PositionLabel")).Text == DivPositionBox.Text; check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("DateStartLabel")).Text == DivStartDateBox.Text; check &= ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("DateEndLabel")).Text == DivEndDateBox.Text; createId = ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("IdLabel")).Text; workPlace = ((Label)SearchListView.Items[SearchListView.SelectedIndex].FindControl("WorkPlaceLabel")).Text; } else { check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WorkPlaceLabel")).Text == DivWorkPlaceBox.Text; check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WorkTypeLabel")).Text == DivWorkTypeBox.Text; check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("PositionLabel")).Text == DivPositionBox.Text; check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DateStartLabel")).Text == DivStartDateBox.Text; check &= ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("DateEndLabel")).Text == DivEndDateBox.Text; createId = ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("IdLabel")).Text; workPlace = ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WorkPlaceLabel")).Text; } if (!check && Regex.IsMatch(DivStartDateBox.Text.Trim(), dateRegex) && Regex.IsMatch(DivEndDateBox.Text.Trim(), dateRegex)) { string updaterId = "", updateCode = ""; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } if (RoleList.SelectedIndex == 0) { updateCode = "DOC_WKUD"; } else { updateCode = "STF_WKUD"; } List <string> values = new List <string>(); values.Add(DivWorkPlaceBox.Text); values.Add(DivWorkTypeBox.Text); values.Add(DivPositionBox.Text); values.Add(DivStartDateBox.Text); values.Add(DivEndDateBox.Text); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(createId); if (RoleList.SelectedIndex == 0) { values.Add("doc update"); } else { values.Add("stf update"); } int status = DataConsumer.executeProcedure("docstf_wk_proc", values); addDelDiv.Visible = false; ListView1.SelectedIndex = -1; SearchListView.SelectedIndex = -1; StatusLabel.CssClass = "success normal"; StatusLabel.Text = "Successful update.<br/>User Id: " + DivUserIdBox.Text + "<br/>Work place: " + workPlace; 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 (check) { DivStatusLabel.Text = "No changes made"; } else if (!Regex.IsMatch(DivStartDateBox.Text.Trim(), dateRegex)) { DivStatusLabel.Text = "Invalid start date. " + form; } else { DivStatusLabel.Text = "Invalid end date. " + form; } } }
protected void DivModifyButton_Click(object sender, EventArgs e) { addDelDiv.Visible = true; //check for changes bool check = DivTopicBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("TopicLabel")).Text.ToUpper(); check = check && DivIdBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("SenderLabel")).Text.ToUpper(); check = check && DivDescBox.Text == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("InformationLabel")).Text; check = check && RecipientList.SelectedItem.Text == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("RecipientLabel")).Text; //check for existence string checkTopic = DataProvider.DeleteInformationPage.checkTopic(HospitalClass.PascalCasing(DivTopicBox.Text.Trim())); DataTable dt = HospitalClass.getDataTable(checkTopic); //check for acceptance of change bool check2 = DivTopicBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("TopicLabel")).Text.ToUpper(); if (DivTopicBox.Text.Trim().Length >= 2 && DivDescBox.Text.Length >= 3 && DivIdBox.Text.Trim().Length >= 1 && RecipientList.SelectedIndex != 0 && !check && ((!check2 && dt.Rows.Count == 0) || (check2 && dt.Rows.Count == 1))) { string updaterId = "", updateCode = "INFO_UPD"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } List <string> values = new List <string>(); values.Add(DivDescBox.Text); values.Add(RecipientList.SelectedItem.Value); values.Add(HospitalClass.PascalCasing(DivTopicBox.Text.Trim())); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(DivIdBox.Text); values.Add(((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("TopicLabel")).Text); values.Add("update"); int status = DataConsumer.executeProcedure("info_proc", values); TopicDelLabel.CssClass = "success normal"; TopicDelLabel.Text = "Successful information modification.<br/> Updater: " + updaterId; addDelDiv.Visible = false; SortButton_Click(new object(), new EventArgs()); ListView1.SelectedIndex = -1; } else { TopicDelLabel.CssClass = "error paraNormal"; TopicDelLabel.Text = "User input error below"; DivStatusLabel.CssClass = "error paraNormal"; if (DivIdBox.Text.Trim().Length < 1) { DivStatusLabel.Text = "Enter a valid ID"; } else if (DivTopicBox.Text.Trim().Length < 2) { DivStatusLabel.Text = "Enter a valid topic name"; } else if (DivDescBox.Text.Length < 3) { DivStatusLabel.Text = "Enter valid information"; } else if (RecipientList.SelectedIndex == 0) { DivStatusLabel.Text = "Please select a recipient"; } else if (check) { DivStatusLabel.Text = "No change made"; } else { DivStatusLabel.Text = "The topic already exists"; } } }
protected void DeleteButton_Click(object sender, EventArgs e) { try { addDelDiv.Visible = false; if (ListView1.SelectedIndex >= 0) { string wardName = ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardNameLabel")).Text; string wardNoQuery = DataProvider.Wards.roomDeptAvail(wardName); //check for room linkage DataTable dt = HospitalClass.getDataTable(wardNoQuery); if (dt.Rows[0][0].ToString() == "0" && ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardDeptLabel")).Text == "None") { string updaterId = "", updateCode = "WARD_DEL"; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } List <string> values = new List <string>(); values.Add(""); values.Add(wardName); values.Add(""); values.Add(""); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add("delete"); int status = DataConsumer.executeProcedure("ward_proc", values); StatusLabel.CssClass = "success normal"; StatusLabel.Text = "Successful ward deletion.<br>Ward ID: " + ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardIdLabel")).Text + "<br/>Ward Name: " + wardName + "."; ListView1.SelectedIndex = -1; SortButton_Click(new object(), new EventArgs()); } else { StatusLabel.CssClass = "error normal"; if (dt.Rows[0][0].ToString() != "0") { StatusLabel.Text = "This ward is already linked to room(s).<br/>Disconnect/Unrelate before deleting."; } else { StatusLabel.Text = "This ward is linked to a parent department.<br/>Disconnect/Unrelate before deleting"; } } } else { StatusLabel.CssClass = "error paraNormal"; if (ListView1.SelectedIndex < 0) { StatusLabel.Text = "No item selected for deletion"; } } } catch (Exception ex) { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void DivModifyButton_Click(object sender, EventArgs e) { try { addDelDiv.Visible = true; //check for change in values bool check = DivNameBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardNameLabel")).Text.ToUpper(); check = check && DivIdBox.Text.ToUpper() == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardIdLabel")).Text.ToUpper(); check = check && DivDescBox.Text == ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardDescLabel")).Text; //check for existence string checkWardIdName = DataProvider.Wards.wardIdName(DivIdBox.Text.Trim().ToUpper(), HospitalClass.PascalCasing(DivNameBox.Text.Trim())); DataTable dt = HospitalClass.getDataTable(checkWardIdName); //check for acceptance of change bool check2 = DivNameBox.Text.ToUpper() != ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardNameLabel")).Text.ToUpper(); check2 = check2 && DivIdBox.Text.ToUpper() != ((Label)ListView1.Items[ListView1.SelectedIndex].FindControl("WardIdLabel")).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 = "WARD_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("WardNameLabel")).Text); values.Add(DivDescBox.Text); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add("update"); int status = DataConsumer.executeProcedure("ward_proc", values); StatusLabel.CssClass = "success normal"; StatusLabel.Text = "Successful ward modification.<br/> Ward ID: " + DivIdBox.Text.Trim().ToUpper() + "<br/>Ward Name:" + HospitalClass.PascalCasing(DivNameBox.Text.Trim()) + "."; addDelDiv.Visible = false; ListView1.SelectedIndex = -1; SortButton_Click(new object(), new EventArgs()); } 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 = "Ward ID/name already exists for another ward"; } } } 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 checkWardIdName = DataProvider.Wards.wardIdName(DivIdBox.Text.Trim().ToUpper(), HospitalClass.PascalCasing(DivNameBox.Text.Trim())); DataTable dt = HospitalClass.getDataTable(checkWardIdName); if (dt.Rows.Count == 0) { string updaterId = "", updateCode = "WARD_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("ward_proc", values); DivStatusLabel.CssClass = "success normal"; DivStatusLabel.Text = "Successful ward addition. <br/>Ward ID: " + DivIdBox.Text.Trim().ToUpper() + "<br/>Ward Name:" + HospitalClass.PascalCasing(DivNameBox.Text.Trim()) + "."; StatusLabel.CssClass = "success paraNormal"; StatusLabel.Text = "Done"; ListView1.SelectedIndex = -1; 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 = "Ward ID already exists"; } else { DivStatusLabel.Text = "Ward 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 ward id"; } else if (DivNameBox.Text.Length < 2) { DivStatusLabel.Text = "Enter a valid ward name"; } else { DivStatusLabel.Text = "Enter a valid ward description"; } } } catch (Exception ex) { StatusLabel.CssClass = "error paraNormal"; StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }
protected void SubmitButton_Click(object sender, EventArgs e) { try { if (UnsubscribeCheckBox.Checked && ReasonBox.Text.Trim().Length > 3) { string updateCode = "", updaterId = ""; if (Session["SuperUser"] != null) { updaterId = (string)Session["SuperUser"]; } else { updaterId = (string)Session["Admin"]; } if (UserIdBox.Text.StartsWith("ST")) { updateCode = "UNSB_STF"; } else { updateCode = "UNSB_" + HospitalClass.getTableName(UserIdBox.Text.Substring(0, 2)).Substring(0, 3).ToUpper(); } //delete picture from iis server string picAddressQuery = DataProvider.Unsubscribe.getPicAddress(UserIdBox.Text); System.Data.DataTable dt = HospitalClass.getDataTable(picAddressQuery); if (dt.Rows.Count == 1) { System.IO.File.Delete(Server.MapPath(dt.Rows[0][0].ToString())); } //delete from database and update necessary tables List <string> values = new List <string>(); values.Add(ReasonBox.Text); values.Add(HospitalClass.getTransactionId()); values.Add(updateCode); values.Add(updaterId); values.Add(UserIdBox.Text); values.Add(HospitalClass.getTableName(UserIdBox.Text.Substring(0, 2))); int status = DataConsumer.executeProcedure("unsb_proc", values); //return user privileges if (Session["SuperUser"] != null) { if (Session["SuperUser"].ToString() != Session["User"].ToString()) { Session["User"] = Session["SuperUser"].ToString(); } else { Session["SuperUser"] = null; Session["Admin"] = null; Session["User"] = null; Response.Redirect("~/Login.aspx"); } } else if (Session["Admin"] != null) { if (Session["Admin"].ToString() != Session["User"].ToString()) { Session["User"] = Session["Admin"].ToString(); } else { Session["SuperUser"] = null; Session["Admin"] = null; Session["User"] = null; Response.Redirect("~/Login.aspx"); } } SubmitButton.Visible = false; StatusLabel.CssClass = "success"; StatusLabel.Text = "Successful Unsubscription.<br>User Id: " + UserIdBox.Text; } else { StatusLabel.CssClass = "error"; if (!UnsubscribeCheckBox.Checked) { StatusLabel.Text = "Unsubscription was not enforced"; } else { StatusLabel.Text = "Please enter a valid reason"; } } } catch (Exception ex) { StatusLabel.CssClass = "error"; StatusLabel.Text = "Error: " + ex.Message; HospitalClass.Log(ex); } }