protected void PopulateForms(string rxNo, string refillNo) { // Cancel if either parameter empty if (rxNo == "" || refillNo == "") { return; } try { // Populate Rx No. and Refill No text boxes txtRxNo.Text = rxNo; txtRefillNo.Text = refillNo; // Execute stored procedure LouisDataTier dataTier = new LouisDataTier(); DataSet refillData = dataTier.GetRefill(rxNo, refillNo); if (refillData.Tables[0].Rows.Count > 0) // If anything is returned { // Populate text/combo boxes with values txtRefillDateTime.Text = ((DateTime)refillData.Tables[0].Rows[0]["refillDateTime"]).ToString("yyyy-MM-dd HH:mm"); //txtRefillDateTime.Text = refillData.Tables[0].Rows[0]["refillDateTime"].ToString(); } } catch { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to populate controls")); } }
protected void PopulateForms(string drugID) { try { // Populate drug ID textbox with input value txtDrugID.Text = drugID; // Execute stored procedure LouisDataTier dataTier = new LouisDataTier(); DataSet drugData = dataTier.GetDrug(drugID); if (drugData.Tables[0].Rows.Count > 0) // If anything is returned { // Populate text/combo boxes with values txtDrugID.Text = drugData.Tables[0].Rows[0]["drugID"].ToString(); txtDrugName.Text = drugData.Tables[0].Rows[0]["drugName"].ToString(); txtDrugDesc.Text = drugData.Tables[0].Rows[0]["drugDesc"].ToString(); txtMethodOfAdmin.Text = drugData.Tables[0].Rows[0]["methodOfAdmin"].ToString(); } } catch { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to populate controls")); } }
protected void PopulateGridView() { if (((BasePage)Page).SearchData == null) // Check for any saved data { // Declare variables string rxNo = ""; string patientID = ""; string drugID = ""; string physicianID = ""; string refillDate = ""; // Get text box values if (((BasePage)Page).SearchFields != null) // Check if SearchFields array exists { if (((string[])((BasePage)Page).SearchFields).Length > 0) // Check if array has values { rxNo = ((BasePage)Page).SearchFields[0]; patientID = ((BasePage)Page).SearchFields[1]; drugID = ((BasePage)Page).SearchFields[2]; physicianID = ((BasePage)Page).SearchFields[3]; refillDate = ((BasePage)Page).SearchFields[4]; } } // Initiate data tier and fill data set LouisDataTier dataTier = new LouisDataTier(); DataSet refillData = dataTier.SearchRefills(rxNo, patientID, drugID, physicianID, refillDate); // Populate GridView with dataset grdRefills.DataSource = refillData.Tables[0]; // Save data to ViewState ((BasePage)Page).SearchData = refillData; } else // Saved data exists { // Populate GridView from saved data grdRefills.DataSource = ((BasePage)Page).SearchData.Tables[0]; } // Bind data to GridView grdRefills.DataBind(); // Show/Enable Delete Selected button if table has rows if (grdRefills.Rows.Count > 0) { btnDeleteChecked.Enabled = true; btnDeleteChecked.Visible = true; } else // Table empty, hide Delete Selected button { btnDeleteChecked.Enabled = false; btnDeleteChecked.Visible = false; } // Set value that prescription search has been performed ((BasePage)Page).HasSearched = true; }
public void DeleteConfirmed(object sender, CommandEventArgs e) { // Initiate data tier and variables LouisDataTier dataTier = new LouisDataTier(); bool deleteSuccess = false; string plural = ""; // Check delete type switch (e.CommandArgument.ToString()) { case "single": // Deleting a single record string singleRxNo = cipher.Decrypt(Convert.ToString(Session["delRxNo"])); string singleRefillNo = cipher.Decrypt(Convert.ToString(Session["delRefillNo"])); deleteSuccess = dataTier.DeleteRefill(singleRxNo, singleRefillNo); break; case "multi": // Deleting all checked records plural = "s"; if (grdRefills.Rows.Count > 0) { // Loop through rows foreach (GridViewRow row in grdRefills.Rows) { // Find checkbox of row CheckBox chkSelectRefill = new CheckBox(); chkSelectRefill = (CheckBox)row.FindControl("chkRefill"); // Delete record if checkbox checked if (chkSelectRefill.Checked) { string multiRxNo = row.Cells[1].Text; string multiRefillNo = row.Cells[2].Text; deleteSuccess = dataTier.DeleteRefill(multiRxNo, multiRefillNo); } } } break; } if (deleteSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Refill record" + plural + " deleted successfully")); // Clear saved data ((BasePage)Page).SearchData = null; } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to delete refill record" + plural)); } // Remove delete confirmation control and update GridView RemoveDeleteConfirmation(); PopulateGridView(); }
protected void PopulateGridView() { if (((BasePage)Page).SearchData == null) // Cache is empty{ { // Declare variables string physicianID = ""; string lastName = ""; string firstName = ""; string employer = ""; // Get text box values if (((BasePage)Page).SearchFields != null) // Check if SearchFields array exists { if (((string[])((BasePage)Page).SearchFields).Length > 0) // Check if array has values { physicianID = ((BasePage)Page).SearchFields[0]; lastName = ((BasePage)Page).SearchFields[1]; firstName = ((BasePage)Page).SearchFields[2]; employer = ((BasePage)Page).SearchFields[3]; } } // Initiate data tier and fill data set LouisDataTier dataTier = new LouisDataTier(); DataSet physicianData = dataTier.SearchPhysicians(physicianID, lastName, firstName, employer); // Populate GridView with dataset grdPhysicians.DataSource = physicianData.Tables[0]; // Save data to ViewState ((BasePage)Page).SearchData = physicianData; } else // Saved data exists { // Populate GridView from saved data grdPhysicians.DataSource = ((BasePage)Page).SearchData.Tables[0]; } // Bind data to GridView grdPhysicians.DataBind(); // Show/Enable Delete Selected button if table has rows if (grdPhysicians.Rows.Count > 0) { btnDeleteChecked.Enabled = true; btnDeleteChecked.Visible = true; } else // Table empty, hide Delete Selected button { btnDeleteChecked.Enabled = false; btnDeleteChecked.Visible = false; } // Set value that prescription search has been performed ((BasePage)Page).HasSearched = true; }
protected void PopulateGridView() { if (((BasePage)Page).SearchData == null) // No saved data { // Declare variables string drugID = ""; string drugName = ""; string drugDesc = ""; // Get text box values if (((BasePage)Page).SearchFields != null) // Check if SearchFields array exists { if (((BasePage)Page).SearchFields.Length > 0) // Check if array has values { drugID = ((BasePage)Page).SearchFields[0]; drugName = ((BasePage)Page).SearchFields[1]; drugDesc = ((BasePage)Page).SearchFields[2]; } } // Initiate data tier and fill data set LouisDataTier dataTier = new LouisDataTier(); DataSet drugData = dataTier.SearchDrugs(drugID, drugName, drugDesc); // Populate GridView with dataset grdDrugs.DataSource = drugData.Tables[0]; // Save data to ViewState ((BasePage)Page).SearchData = drugData; } else // Saved data exists { // Populate GridView from saved data grdDrugs.DataSource = ((BasePage)Page).SearchData.Tables[0]; } // Bind data to GridView grdDrugs.DataBind(); // Show/Enable Delete Selected button if table has rows if (grdDrugs.Rows.Count > 0) { btnDeleteChecked.Enabled = true; btnDeleteChecked.Visible = true; } else // Table empty, hide Delete Selected button { btnDeleteChecked.Enabled = false; btnDeleteChecked.Visible = false; } // Set value that prescription search has been performed ((BasePage)Page).HasSearched = true; }
protected void PopulateForms(string patientID) { try { // Populate Patient ID textbox with input value txtPatientID.Text = patientID; // Execute stored procedure LouisDataTier dataTier = new LouisDataTier(); DataSet patientData = dataTier.GetPatient(patientID); if (patientData.Tables[0].Rows.Count > 0) // If anything is returned { // Populate text/combo boxes with values txtLastName.Text = patientData.Tables[0].Rows[0]["lName"].ToString(); txtFirstName.Text = patientData.Tables[0].Rows[0]["fName"].ToString(); txtMidInit.Text = patientData.Tables[0].Rows[0]["mInit"].ToString(); txtDateOfBirth.Text = patientData.Tables[0].Rows[0]["dateOfBirth"].ToString().Trim().Substring(0, 10); txtInsuranceCo.Text = patientData.Tables[0].Rows[0]["insuranceCo"].ToString(); txtAcctBalance.Text = patientData.Tables[0].Rows[0]["acctBalance"].ToString(); txtAddrLine1.Text = patientData.Tables[0].Rows[0]["addrLine1"].ToString(); txtAddrLine2.Text = patientData.Tables[0].Rows[0]["addrLine2"].ToString(); txtAddrCity.Text = patientData.Tables[0].Rows[0]["addrCity"].ToString(); ddlAddrState.SelectedValue = patientData.Tables[0].Rows[0]["addrState"].ToString().Trim(); txtAddrZip.Text = patientData.Tables[0].Rows[0]["addrZip"].ToString(); txtEmail1.Text = patientData.Tables[0].Rows[0]["email1"].ToString(); txtEmail2.Text = patientData.Tables[0].Rows[0]["email2"].ToString(); txtHomePhoneNo.Text = patientData.Tables[0].Rows[0]["homePhoneNo"].ToString(); txtCellPhoneNo.Text = patientData.Tables[0].Rows[0]["cellPhoneNo"].ToString(); // Select gender radio button char selectedGender; char.TryParse(patientData.Tables[0].Rows[0]["gender"].ToString().Trim(), out selectedGender); // Set radio buttons based on selected gender value if (selectedGender == 'M') { rdoGenderM.Checked = true; rdoGenderF.Checked = false; } else { rdoGenderF.Checked = true; rdoGenderM.Checked = false; } } } catch { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to populate controls")); } }
protected void PopulateForms(string rxNo) { try { // Populate Rx No. textbox with input value txtRxNo.Text = rxNo; // Execute stored procedure LouisDataTier dataTier = new LouisDataTier(); DataSet prescriptionData = dataTier.GetPrescription(rxNo); if (prescriptionData.Tables[0].Rows.Count > 0) // If anything is returned { // Populate text/combo boxes with values txtRxNo.Text = prescriptionData.Tables[0].Rows[0]["rxNo"].ToString(); txtPatientID.Text = prescriptionData.Tables[0].Rows[0]["patientID"].ToString(); ddlPatientName.SelectedValue = prescriptionData.Tables[0].Rows[0]["patientID"].ToString(); txtDrugID.Text = prescriptionData.Tables[0].Rows[0]["drugID"].ToString(); ddlDrugName.SelectedValue = prescriptionData.Tables[0].Rows[0]["drugID"].ToString(); txtPhysicianID.Text = prescriptionData.Tables[0].Rows[0]["physicianID"].ToString(); ddlPhysicianName.SelectedValue = prescriptionData.Tables[0].Rows[0]["physicianID"].ToString(); txtDosage.Text = prescriptionData.Tables[0].Rows[0]["dosage"].ToString(); txtFrequency.Text = prescriptionData.Tables[0].Rows[0]["frequency"].ToString(); txtRefillsGiven.Text = prescriptionData.Tables[0].Rows[0]["refillsGiven"].ToString(); txtRefillsLeft.Text = prescriptionData.Tables[0].Rows[0]["refillsLeft"].ToString(); txtCost.Text = prescriptionData.Tables[0].Rows[0]["cost"].ToString(); txtStartDate.Text = prescriptionData.Tables[0].Rows[0]["startDate"].ToString().Trim().Substring(0, 10); txtFinishDate.Text = prescriptionData.Tables[0].Rows[0]["finishDate"].ToString().Trim().Substring(0, 10); } } catch { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to populate controls")); } }
protected void PopulateDropDownLists() { try { // Initiate data tier LouisDataTier dataTier = new LouisDataTier(); // Populate Patient Name search field if (Cache["patientNames"] == null) // Check if cache empty { DataSet patientNames = dataTier.PopulateDDL("patient"); ddlSrchPatientName.DataSource = patientNames; Cache.Add("patientNames", new DataView(patientNames.Tables[0]), null, Cache.NoAbsoluteExpiration, System.TimeSpan.FromMinutes(60), CacheItemPriority.Default, null); } else // Cached data exists { ddlSrchPatientName.DataSource = Cache["patientNames"]; } ddlSrchPatientName.DataTextField = "patient"; ddlSrchPatientName.DataValueField = "patientID"; ddlSrchPatientName.Items.Insert(0, new ListItem(string.Empty, string.Empty)); // Add leading blank row ddlSrchPatientName.DataBind(); // Populate Drug Name search field if (Cache["drugNames"] == null) // Check if cache empty { DataSet drugNames = dataTier.PopulateDDL("drug"); ddlSrchDrugName.DataSource = drugNames; Cache.Add("drugNames", new DataView(drugNames.Tables[0]), null, Cache.NoAbsoluteExpiration, System.TimeSpan.FromMinutes(60), CacheItemPriority.Default, null); } else // Cached data exists { ddlSrchDrugName.DataSource = Cache["drugNames"]; } ddlSrchDrugName.DataTextField = "drug"; ddlSrchDrugName.DataValueField = "drugID"; ddlSrchDrugName.Items.Insert(0, new ListItem(string.Empty, string.Empty)); // Add leading blank row ddlSrchDrugName.DataBind(); // Populate Physician Name search field if (Cache["physicianNames"] == null) // Check if cache empty { DataSet physicianNames = dataTier.PopulateDDL("physician"); ddlSrchPhysicianName.DataSource = physicianNames; Cache.Add("physicianNames", new DataView(physicianNames.Tables[0]), null, Cache.NoAbsoluteExpiration, System.TimeSpan.FromMinutes(60), CacheItemPriority.Default, null); } else // Cached data exists { ddlSrchPhysicianName.DataSource = Cache["physicianNames"]; } ddlSrchPhysicianName.DataTextField = "physician"; ddlSrchPhysicianName.DataValueField = "physicianID"; ddlSrchPhysicianName.Items.Insert(0, new ListItem(string.Empty, string.Empty)); // Add leading blank row ddlSrchPhysicianName.DataBind(); } catch //(Exception ex) { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to populate DropDownLists")); //RegisterAlertScript(new CommandEventArgs("script", ex.Message)); } }
protected void btnSubmit_Click(object sender, EventArgs e) { // Get Patient, Drug, and Physician based on input type string patientID = "", drugID = "", physicianID = "", msgID = ""; switch (((BasePage)Page).InputType) { case "byID": patientID = txtPatientID.Text.Trim(); drugID = txtDrugID.Text.Trim(); physicianID = txtPhysicianID.Text.Trim(); break; case "byName": patientID = ddlPatientName.SelectedValue; drugID = ddlDrugName.SelectedValue; physicianID = ddlPhysicianName.SelectedValue; msgID = " ID"; break; default: RegisterAlertScript(new CommandEventArgs("script", "Invalid InputType")); return; } // Check for invalid null values and show error message StringBuilder emptyMessage = new StringBuilder(); emptyMessage.Append("The following fields cannot be empty:" + "\\n"); // Double backslashes are required for registering JS to work bool emptyFields = false; if (txtRxNo.Text.Trim() == string.Empty) { emptyMessage.Append("Rx No." + "\\n"); emptyFields = true; } if (patientID == string.Empty) { emptyMessage.Append("Patient" + msgID + "\\n"); emptyFields = true; } if (drugID == string.Empty) { emptyMessage.Append("Drug" + msgID + "\\n"); emptyFields = true; } if (physicianID == string.Empty) { emptyMessage.Append("Physician" + msgID + "\\n"); emptyFields = true; } if (txtRefillsGiven.Text.Trim() == string.Empty) { emptyMessage.Append("Refills Given" + "\\n"); emptyFields = true; } if (PageType == "edit" && txtRefillsLeft.Text.Trim() == string.Empty) { emptyMessage.Append("Refills Left"); emptyFields = true; } if (emptyFields == true) { RegisterAlertScript(new CommandEventArgs("script", emptyMessage.ToString())); return; } // Initiate data tier LouisDataTier dataTier = new LouisDataTier(); // Determine editing or adding record switch (PageType) { case "edit": // Execute stored procedure (returns true if successful) bool updateSuccess = dataTier.UpdatePrescription( txtRxNo.Text.Trim(), drugID, patientID, physicianID, txtDosage.Text.Trim(), txtFrequency.Text.Trim(), txtStartDate.Text.Trim(), txtFinishDate.Text.Trim(), txtRefillsLeft.Text.Trim(), txtCost.Text.Trim(), txtRefillsGiven.Text.Trim() ); if (updateSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Prescription record updated successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to update prescription record")); } break; case "add": // Execute stored procedure (returns true if successful) bool addSuccess = dataTier.AddPrescription( txtRxNo.Text.Trim(), drugID, patientID, physicianID, txtDosage.Text.Trim(), txtFrequency.Text.Trim(), txtStartDate.Text.Trim(), txtFinishDate.Text.Trim(), txtRefillsGiven.Text.Trim(), txtCost.Text.Trim() ); if (addSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Prescription record added successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to add prescription record")); } break; default: // Display error message RegisterAlertScript(new CommandEventArgs("script", "Invalid pageType")); break; } }
protected void btnSubmit_Click(object sender, EventArgs e) { // Check for invalid null values and show error message StringBuilder emptyMessage = new StringBuilder(); emptyMessage.Append("The following fields cannot be empty:" + "\\n"); // Double backslashes are required for registering JS to work bool emptyFields = false; if (txtRxNo.Text.Trim() == string.Empty) { emptyMessage.Append("Rx No." + "\\n"); emptyFields = true; } if (txtRefillDateTime.Text.Trim() == string.Empty) { emptyMessage.Append("Time of Refill"); emptyFields = true; } if (emptyFields == true) { RegisterAlertScript(new CommandEventArgs("script", emptyMessage.ToString())); return; } // Initiate data tier LouisDataTier dataTier = new LouisDataTier(); // Determine editing or adding record switch (PageType) { case "edit": // Execute stored procedure (returns true if successful) bool updateSuccess = dataTier.UpdateRefill( txtRxNo.Text.Trim(), txtRefillNo.Text.Trim(), txtRefillDateTime.Text.Trim() ); if (updateSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Refill record updated successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to update refill record")); } break; case "refill-auto": case "add-manual": // Check for refills left by Rx No. DataSet refilledPresc = dataTier.GetPrescription(txtRxNo.Text.Trim()); int refillsLeft = 0; try { // Parse refills left; catches if prescription doesn't exist int.TryParse(refilledPresc.Tables[0].Rows[0]["refillsLeft"].ToString(), out refillsLeft); if (refillsLeft > 0) { // Execute stored procedure (returns true if successful) bool addSuccess = dataTier.AddRefill( txtRxNo.Text.Trim(), txtRefillDateTime.Text.Trim() ); if (addSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Prescription refilled successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to refill prescriptions")); } } else // refillsLeft < 1 { RegisterAlertScript(new CommandEventArgs("script", "There are no refills left for prescription " + txtRxNo.Text.Trim())); } } catch // Prescription doesn't exist { RegisterAlertScript(new CommandEventArgs("script", "Prescription " + txtRxNo.Text.Trim() + " does not exist")); } break; default: // Display error message RegisterAlertScript(new CommandEventArgs("script", "Invalid pageType")); break; } if (PageType == "refill-auto") { // Automatically return to Prescriptions search page GoBackButtonClicked(e); } }
protected void btnSubmit_Click(object sender, EventArgs e) { // Retrieve page type string pageType = PageType; // Check for invalid null values and show error message StringBuilder emptyMessage = new StringBuilder(); emptyMessage.Append("The following fields cannot be empty:" + "\\n"); // Double backslashes are required for registering JS to work bool emptyFields = false; if (txtPhysicianID.Text.Trim() == string.Empty) { emptyMessage.Append("Physician ID" + "\\n"); emptyFields = true; } if (txtLastName.Text.Trim() == string.Empty) { emptyMessage.Append("Last Name" + "\\n"); emptyFields = true; } if (txtFirstName.Text.Trim() == string.Empty) { emptyMessage.Append("First Name" + "\\n"); emptyFields = true; } if (rdoGenderM.Checked == false && rdoGenderF.Checked == false) { emptyMessage.Append("Gender" + "\\n"); emptyFields = true; } if (txtDateOfBirth.Text.Trim() == string.Empty) { emptyMessage.Append("Date of Birth"); emptyFields = true; } if (emptyFields == true) { RegisterAlertScript(new CommandEventArgs("script", emptyMessage.ToString())); return; } // Determine selected gender char selectedGender = 'Z'; if (rdoGenderM.Checked == true) { selectedGender = 'M'; } else // rdoGenderF.Checked == true { selectedGender = 'F'; } // Initiate data tier LouisDataTier dataTier = new LouisDataTier(); // Determine editing or adding record switch (pageType) { case "edit": // Execute stored procedure (returns true if successful) bool updateSuccess = dataTier.UpdatePhysician( txtPhysicianID.Text.Trim(), txtFirstName.Text.Trim(), txtLastName.Text.Trim(), txtMidInit.Text.Trim(), selectedGender, txtDateOfBirth.Text.Trim(), txtEmployer.Text.Trim(), txtSpecialty1.Text.Trim(), txtSpecialty2.Text.Trim(), txtSpecialty3.Text.Trim(), txtAddrLine1.Text.Trim(), txtAddrLine2.Text.Trim(), txtAddrCity.Text.Trim(), ddlAddrState.SelectedValue.ToString(), txtAddrZip.Text.Trim(), txtWorkEmail.Text.Trim(), txtPersonalEmail.Text.Trim(), txtWorkPhoneNo.Text.Trim(), txtHomePhoneNo.Text.Trim(), txtCellPhoneNo.Text.Trim() ); if (updateSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Physician record updated successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to update physician record")); } break; case "add": // Execute stored procedure (returns true if successful) bool addSuccess = dataTier.AddPhysician( txtPhysicianID.Text.Trim(), txtFirstName.Text.Trim(), txtLastName.Text.Trim(), txtMidInit.Text.Trim(), selectedGender, txtDateOfBirth.Text.Trim(), txtEmployer.Text.Trim(), txtSpecialty1.Text.Trim(), txtSpecialty2.Text.Trim(), txtSpecialty3.Text.Trim(), txtAddrLine1.Text.Trim(), txtAddrLine2.Text.Trim(), txtAddrCity.Text.Trim(), ddlAddrState.SelectedValue.ToString(), txtAddrZip.Text.Trim(), txtWorkEmail.Text.Trim(), txtPersonalEmail.Text.Trim(), txtWorkPhoneNo.Text.Trim(), txtHomePhoneNo.Text.Trim(), txtCellPhoneNo.Text.Trim() ); if (addSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Physician record added successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to add physician record")); } break; default: // Display error message RegisterAlertScript(new CommandEventArgs("script", "Invalid pageType")); break; } }
protected void btnSubmit_Click(object sender, EventArgs e) { // Check for invalid null values and show error message StringBuilder emptyMessage = new StringBuilder(); emptyMessage.Append("The following fields cannot be empty:" + "\\n"); // Double backslashes are required for registering JS to work bool emptyFields = false; if (txtDrugID.Text.Trim() == string.Empty) { emptyMessage.Append("Drug ID" + "\\n"); emptyFields = true; } if (txtDrugName.Text.Trim() == string.Empty) { emptyMessage.Append("Drug Name" + "\\n"); emptyFields = true; } if (txtDrugDesc.Text.Trim() == string.Empty) { emptyMessage.Append("Drug Description" + "\\n"); emptyFields = true; } if (txtMethodOfAdmin.Text.Trim() == string.Empty) { emptyMessage.Append("Method of Admin." + "\\n"); emptyFields = true; } if (emptyFields == true) { RegisterAlertScript(new CommandEventArgs("script", emptyMessage.ToString())); return; } // Initiate data tier LouisDataTier dataTier = new LouisDataTier(); // Determine editing or adding record switch (PageType) { case "edit": // Execute stored procedure (returns true if successful) bool updateSuccess = dataTier.UpdateDrug( txtDrugID.Text.Trim(), txtDrugName.Text.Trim(), txtDrugDesc.Text.Trim(), txtMethodOfAdmin.Text.Trim() ); if (updateSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Drug record updated successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to update drug record")); } break; case "add": // Execute stored procedure (returns true if successful) bool addSuccess = dataTier.AddDrug( txtDrugID.Text.Trim(), txtDrugName.Text.Trim(), txtDrugDesc.Text.Trim(), txtMethodOfAdmin.Text.Trim() ); if (addSuccess == true) { // Display success message RegisterAlertScript(new CommandEventArgs("script", "Drug record added successfully")); // Clear saved data ClearSavedData(); } else { // Display failure message RegisterAlertScript(new CommandEventArgs("script", "Failed to add drug record")); } break; default: // Display error message RegisterAlertScript(new CommandEventArgs("script", "Invalid pageType")); break; } }