protected void Page_Load(object sender, EventArgs e) { //IsPostback will not work if you are opening a new child page //To stop the user from clicking the back button after they leave the page //This is not a great solution but it gets the job done if (!IsPostBack) { Response.Cache.SetNoStore(); Response.Cache.AppendCacheExtension("no-cache"); Response.Expires = 0; } string strValidLogin = ""; //Will need to test to see if a session variable VALIDLOGIN to know if you are posting back if (Session["VALIDLOGIN"] != null) //A user has already possibly logedin { strValidLogin = Session["VALIDLOGIN"].ToString(); } if (strValidLogin == "true") { NavbarSetup(showAdmin, showTech); } else { NavbarSetup(false, false); } getPostBackControl FindCtrl = new getPostBackControl(); string CtrlName = FindCtrl.getPostBackControlName(Page); switch (CtrlName) { case "btnLogin": LoginSetup(); break; case "lnkLogout": LogoutSetup(); break; } }
protected void Page_Load(object sender, EventArgs e) { try { //Open a connection to the database string conStr = ConfigurationManager.ConnectionStrings["conAW"].ConnectionString; SqlConnection conAW = new SqlConnection(conStr); conAW.Open(); if (!IsPostBack) { //We are loading the page for the first time loadUser(conAW); } else { //We need to find out what control caused the postback getPostBackControl clsCtl = new getPostBackControl(); string ctl = clsCtl.getPostBackControlName(Page); switch (ctl) { case "dlaNumber": loadDetail(conAW); break; case "btnEdit": //Call the js function to show the modal popup lblAddEditUser.InnerHtml = "Edit User"; cEdit = true; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditUser');", true); break; case "btnNewUserSave": //We need to see if we are saving or editing if (cEdit) { //saving an edited user SaveEditUser(conAW); cEdit = false; loadUser(conAW); //select the edited user record for (int Loop = 0; Loop < dlaNumber.Items.Count; Loop++) { if (dlaNumber.Items[Loop].Value == editUserId) { //we have found the edited user dlaNumber.SelectedIndex = Loop; } } loadDetail(conAW); } else { //we are saving a new user SaveNewUser(conAW); //reload the list loadUser(conAW); //now select the new user record for (int Loop = 0; Loop < dlaNumber.Items.Count; Loop++) { if (dlaNumber.Items[Loop].Value == newUserId) { //we found the new user dlaNumber.SelectedIndex = Loop; } } //reload the form loadDetail(conAW); } break; case "btnAdd": //clear out modal form txtAnumber.Text = ""; txtUserName.Text = ""; txtPassword.Text = ""; txtSecurity.Text = ""; lblAddEditUser.InnerHtml = "Add new User"; Page.ClientScript.RegisterStartupScript(this.GetType(), "mysScript", "initMyModal('mdlNewEditUser');", true); break; case "btnNewUserCancel": cEdit = false; break; case "btnDelete": lblDeleteUserMessage.InnerHtml = "Are you sure you want to delete the User: "******" ?"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteUser');", true); break; case "btnDeleteUserSave": DeleteUser(conAW); //Reload user list loadUser(conAW); //Reload main form loadDetail(conAW); break; } } //Close the connection to the DB conAW.Close(); conAW.Dispose(); } catch (Exception ex) { ErrLog EL = new ErrLog(); EL.SaveErrLog("Module: DefaultPage" + Environment.NewLine + "Function: Page_Load" + Environment.NewLine + "ErrorMessage: " + ex.Message); Response.Write(@"<script>alert('Error Message: " + ex.Message.ToString() + "');</script>"); } //To stop the user from entering this page if they are not logged in. string strValidLogin = ""; string userType = ""; if (Session["VALIDLOGIN"] != null) { strValidLogin = Session["VALIDLOGIN"].ToString(); userType = Session["USERTYPE"].ToString(); if (strValidLogin == "false" || userType == "Tech") { Response.Redirect("Default.aspx"); } } else { Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { try { //Open a connection to the database string conStr = ConfigurationManager.ConnectionStrings["conAW"].ConnectionString; SqlConnection conAW = new SqlConnection(conStr); conAW.Open(); if (!IsPostBack) { //We are loading the page for the first time loadComputer(conAW); } else { //We need to find out what control caused the postback getPostBackControl clsCtl = new getPostBackControl(); string ctl = clsCtl.getPostBackControlName(Page); switch (ctl) { case "ddlEquipNum": loadDetail(conAW); LoadAllSoftwareList(conAW); break; case "btnEdit": //Call the js function to show the modal popup lblAddEditComputer.InnerHtml = "Edit Computer"; cEdit = true; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditComputer');", true); break; case "btnNewCompSave": //Will need more code to see if we are editing or saving a new computer if (cEdit) { //We are saving an edited computer SaveEditComputer(conAW); cEdit = false; loadComputer(conAW); //Now Select the edited computer record for (int Loop = 0; Loop < ddlEquipNum.Items.Count; Loop++) { if (ddlEquipNum.Items[Loop].Value == editComputerID) { //We found the edited computer ddlEquipNum.SelectedIndex = Loop; } } loadDetail(conAW); } else { //We are saving a new computer SaveNewComputer(conAW); //Reload the dropdown list loadComputer(conAW); //Now select the new computer record for (int Loop = 0; Loop < ddlEquipNum.Items.Count; Loop++) { if (ddlEquipNum.Items[Loop].Value == newComputerID) { //we found the new computer ddlEquipNum.SelectedIndex = Loop; } } //Reload the main form loadDetail(conAW); } //Also need code to reload the dropdownlist and reload the page detail break; case "btnAdd": //Clear out the modal form ClearFormModel(); //txtNSCCEquipmentNumber.Text = ""; //txtMake.Text = ""; //txtModel.Text = ""; //txtSerialNumber.Text = ""; //txtPurchaseOrderNumber.Text = ""; //txtPurchaseDate.Text = ""; //txtWarrantyStartDate.Text = ""; //LoadEditLocationComboBox(); //txtBuilding.Text = ""; //txtRoom.Text = ""; lblAddEditComputer.InnerHtml = "Add New Computer"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditComputer');", true); break; case "btnNewCompCancel": cEdit = false; break; case "btnDelete": lblDeleteCompMsg.InnerHtml = "Are you sure you want to delete this computer: " + ddlEquipNum.SelectedItem.Value + "?"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteComputer');", true); break; case "btnDeleteCompSave": DeleteComputer(conAW); //Reload the dropdown list loadComputer(conAW); //Reload the main form loadDetail(conAW); break; case "btnAddSoftware": LoadAllSoftwareList(conAW); lblAddNewSoftware.InnerHtml = "Add New Software"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewSoftwareInstall');", true); break; case "btnSoftwareInstallCancel": loadSoftwareForComputer(conAW); loadSoftwareForComputerList(conAW); cEdit = false; break; case "btnSoftwareInstallSave": { // SaveAddNewSoftware(conAW); //SaveAddNewSoftware loadSoftwareForComputer(conAW); loadSoftwareForComputerList(conAW); //LoadAllSoftwareList(conAW); } //Also need code to reload the dropdownlist and reload the page detail break; case "btnDeleteSoftware": lblDeleteComputerSWMsg.InnerHtml = "Are you sure you want to delete the Software from this computer: " + dlSoftwareInstalled.SelectedItem.Value + " ?"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteSoftware');", true); break; case "btnDeleteSoftwareSave": //DeleteComputer(conAW); //Reload the dropdown list DeleteSoftwareInstalled(conAW); loadSoftwareForComputer(conAW); loadSoftwareForComputerList(conAW); //loadComputer(conAW); //Reload the main form //loadDetail(conAW); break; case "btnDeleteSoftwareCancel": loadSoftwareForComputer(conAW); loadSoftwareForComputerList(conAW); cEdit = false; break; } } //Close the connection to the DB conAW.Close(); conAW.Dispose(); } catch (Exception ex) { ErrLog EL = new ErrLog(); EL.SaveErrLog("Module: DefaultPage" + Environment.NewLine + "Function: Page_Load" + Environment.NewLine + "Error Message: " + ex.Message); Response.Write(@"<script>alert('Error Message: " + ex.Message.ToString() + "';</script>"); } //To stop the user from entering this page if they are not logged in. string strValidLogin = ""; if (Session["VALIDLOGIN"] != null) { strValidLogin = Session["VALIDLOGIN"].ToString(); if (strValidLogin == "false") { Response.Redirect("Default.aspx"); } } else { Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { try { //Open a connection to the database string conStr = ConfigurationManager.ConnectionStrings["conAW"].ConnectionString; SqlConnection conAW = new SqlConnection(conStr); conAW.Open(); if (!IsPostBack) { //We are loading the page for the first time loadComputer(conAW); } else { //We need to find out what control caused the postback getPostBackControl clsCtl = new getPostBackControl(); string ctl = clsCtl.getPostBackControlName(Page); switch (ctl) { case "dlEquipNum": loadDetail(conAW); break; case "btnEdit": //Call the js function to show the modal popup lblAddEditCourse.InnerHtml = "Edit Computer"; cEdit = true; txtComputerNSCCeNumber.Enabled = false; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditComputer');", true); break; case "btnNewComputerSave": //Will need more code to see if we are editing or saving a new employee btnSoftwareInstallSave if (cEdit) { //We are saving an edited customer SaveEditComputer(conAW); cEdit = false; loadComputer(conAW); //Now select the edited customer record for (int Loop = 0; Loop < dlEquipNum.Items.Count; Loop++) { if (dlEquipNum.Items[Loop].Value == editNSCCEquipmentNumber) { //We found the edited Customer dlEquipNum.SelectedIndex = Loop; } } loadDetail(conAW); } else { //We are saving a new customer SaveNewComputer(conAW); //Reload the dropdown list loadComputer(conAW); //Now select the new customer record for (int Loop = 0; Loop < dlEquipNum.Items.Count; Loop++) { if (dlEquipNum.Items[Loop].Value == newNSCCEquipmentNumber) { //We found the new Customer dlEquipNum.SelectedIndex = Loop; } } //Reload the main form loadDetail(conAW); } //Also need code to reload the dropdownlist and reload the page detail break; case "btnAdd": cEdit = false; //dlEquipNum.SelectedItem.Value = ""; //txtSerialNum.Text = ""; //lblMake.Text = ""; //txtModel.Text = ""; //txtSerialNum.Text = ""; //txtPoNum.Text = ""; //txtDatePurch.Text = ""; //txtWarrantyDate.Text = ""; //txtCampus.Text = ""; //txtBuilding.Text = ""; //txtRoomNum.Text = ""; //txtSoftName.Text = ""; //txtSoftMan.Text = ""; //txtVersion.Text = ""; //Clear out the modal form dlComputerCampusName.Items.Clear(); string selectStatement = "SELECT CampusName " + "FROM Location " + "ORDER BY CampusName"; SqlCommand selectCommand = new SqlCommand(selectStatement, conAW); SqlDataReader SQLdr = selectCommand.ExecuteReader(); if (SQLdr.HasRows) { while (SQLdr.Read()) { dlComputerCampusName.Items.Insert(dlComputerCampusName.Items.Count, new ListItem(SQLdr[0].ToString())); //dlMake.Items.Insert(dlMake.Items.Count, new ListItem(SQLdr[3].ToString() + ", " + SQLdr[2].ToString(), SQLdr[1].ToString())); //dlEquipNum.Items.Insert(dlEquipNum.Items.Count, new ListItem(SQLdr[0].ToString() + ", " + SQLdr[1].ToString(), SQLdr[0].ToString())); } dlComputerCampusName.Items.Insert(0, new ListItem("Select Campus Location ", "")); } SQLdr.Close(); SQLdr.Dispose(); selectCommand.Dispose(); txtComputerNSCCeNumber.Enabled = true; txtComputerNSCCeNumber.Text = ""; txtComputerMake.Text = ""; txtComputerModel.Text = ""; txtComputerSerialNumber.Text = ""; txtComputerPONumber.Text = ""; txtComputerDateOfPurchase.Text = ""; txtComputerWarrantyStartdate.Text = ""; //txtComputerLocationID.Text = ""; txtComputerBuilding.Text = ""; txtComputerRoom.Text = ""; lblAddEditCourse.InnerHtml = "Add New Computer"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditComputer');", true); break; case "btnNewComputerCancel": cEdit = false; loadComputer(conAW); break; case "btnDelete": lblDeleteComputerMsg.InnerHtml = "Are you sure you want to delete the Computer: " + lblMake.Text + " " + txtModel.Text + " " + txtSerialNum.Text; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteComputer');", true); break; case "btnDeleteComputerSave": DeleteComputer(conAW); //Reload the dropdown list loadComputer(conAW); //Reload the main form loadDetail(conAW); break; case "btnAddSoftware": //Clear out the modal form dlAddSoftwareInstalled.Items.Clear(); string selectStatement1 = "SELECT Distinct ProductName + ' #V' + Version AS SoftwareName " + "FROM Software " + "ORDER BY SoftwareName"; SqlCommand selectCommand1 = new SqlCommand(selectStatement1, conAW); SqlDataReader SQLdr1 = selectCommand1.ExecuteReader(); if (SQLdr1.HasRows) { while (SQLdr1.Read()) { dlAddSoftwareInstalled.Items.Insert(dlAddSoftwareInstalled.Items.Count, new ListItem(SQLdr1[0].ToString())); //dlMake.Items.Insert(dlMake.Items.Count, new ListItem(SQLdr[3].ToString() + ", " + SQLdr[2].ToString(), SQLdr[1].ToString())); //dlEquipNum.Items.Insert(dlEquipNum.Items.Count, new ListItem(SQLdr[0].ToString() + ", " + SQLdr[1].ToString(), SQLdr[0].ToString())); } dlAddSoftwareInstalled.Items.Insert(0, new ListItem("Select Software ", "")); } SQLdr1.Close(); SQLdr1.Dispose(); selectCommand1.Dispose(); lblAddNewSoftware.InnerHtml = "Add New Software"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewSoftwareInstall');", true); break; case "btnSoftwareInstallSave": //Will need more code to see if we are editing or saving a new employee //if (cEdit) //{ //We are saving an edited customer // SaveEditComputer(conAW); // cEdit = false; // loadComputer(conAW); // //Now select the edited customer record // for (int Loop = 0; Loop < dlEquipNum.Items.Count; Loop++) // { // if (dlEquipNum.Items[Loop].Value == editNSCCEquipmentNumber) // { // //We found the edited Customer // dlEquipNum.SelectedIndex = Loop; // } // } // loadDetail(conAW); //} //else { //We are saving a new customer SaveAddNewSoftware(conAW); //SaveAddNewSoftware //Reload the dropdown list loadComputer(conAW); //Now select the new customer record for (int Loop = 0; Loop < dlEquipNum.Items.Count; Loop++) { if (dlEquipNum.Items[Loop].Value == editNSCCEquipmentNumber) { //We found the new Customer dlEquipNum.SelectedIndex = Loop; } } //Reload the main form loadDetail(conAW); } //Also need code to reload the dropdownlist and reload the page detail break; case "btnSoftwareInstallCancel": cEdit = false; break; case "btnDeleteSoftware": lblDeleteComputerSWMsg.InnerHtml = "Are you sure you want to delete the Software from this computer: " + dlComputerCampusName.SelectedItem.Value + " ?"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteSoftware');", true); break; case "btnDeleteSoftwareSave": //DeleteComputer(conAW); //Reload the dropdown list loadComputer(conAW); //Reload the main form loadDetail(conAW); break; } } //Close the connection to the DB conAW.Close(); conAW.Dispose(); } catch (Exception ex) { ErrLog EL = new ErrLog(); EL.SaveErrLog("Module: DefaultPage" + Environment.NewLine + "Function: Page_Load" + Environment.NewLine + "Error Message: " + ex.Message); Response.Write(@"<script>alert('Error Message: " + ex.Message.ToString() + "');</script>"); } // this is was before add the above ////Open a connection to the database //string conStr = ConfigurationManager.ConnectionStrings["conAW"].ConnectionString; //SqlConnection conAW = new SqlConnection(conStr); //conAW.Open(); //if (!IsPostBack) //{ // //We are loading the page for the first time // loadComputer(conAW); //} //else //{ // //We need to find out what control caused the postback // getPostBackControl clsCtl = new getPostBackControl(); // string ctl = clsCtl.getPostBackControlName(Page); // switch (ctl) // { // case "dlEquipNum": // loadDetail(conAW); // break; // } //} ////Close the connection to the DB //conAW.Close(); //conAW.Dispose(); //To stop the user from entering this page if they are not logged in. string strValidLogin = ""; if (Session["VALIDLOGIN"] != null) { strValidLogin = Session["VALIDLOGIN"].ToString(); if (strValidLogin == "false") { Response.Redirect("Default.aspx"); } } else { Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { //To stop the user from entering this page if they are not logged in. string strValidLogin = ""; string userType = ""; if (Session["VALIDLOGIN"] != null) { strValidLogin = Session["VALIDLOGIN"].ToString(); userType = Session["USERTYPE"].ToString(); if (strValidLogin == "false") { Response.Redirect("Default.aspx"); } } else { Response.Redirect("Default.aspx"); } if (dlProduct.SelectedIndex == -1 || dlSoftNum.SelectedIndex == 0) { dlProduct.Enabled = false; } else { dlProduct.Enabled = true; } if (dlVersion.SelectedIndex == -1 || dlProduct.SelectedIndex == 0 || dlSoftNum.SelectedIndex == 0) { dlVersion.Enabled = false; } else { dlVersion.Enabled = true; } try { //Open a connection to the database string conStr = ConfigurationManager.ConnectionStrings["conAW"].ConnectionString; SqlConnection conAW = new SqlConnection(conStr); conAW.Open(); if (!IsPostBack) { //We are loading the page for the first time loadSoftware(conAW); PopulateGridview(conAW); } else { //We need to find out what control caused the postback getPostBackControl clsCtl = new getPostBackControl(); string ctl = clsCtl.getPostBackControlName(Page); PopulateGridview(conAW); switch (ctl) { case "dlSoftNum": loadProductName(conAW); //loadDetail(conAW); break; case "dlProduct": loadVersion(conAW); //loadDetail(conAW); break; case "dlVersion": //loadVersion(conAW); loadDetail(conAW); break; case "btnEdit": //Call the js function to show the modal popup lblAddEditSoftware.InnerHtml = "Edit Software"; txtSoftID.Enabled = false; cEdit = true; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditSoftware');", true); break; case "btnNewSoftwareSave": //We need to see if we are saving or editing if (cEdit) { //saving an edited user SaveEditUser(conAW); cEdit = false; loadSoftware(conAW); //select the edited user record for (int Loop = 0; Loop < dlSoftNum.Items.Count; Loop++) { if (dlSoftNum.Items[Loop].Value == txtDeveloper.Text) { //we have found the edited user dlSoftNum.SelectedIndex = Loop; } } loadProductName(conAW); for (int Loop = 0; Loop < dlProduct.Items.Count; Loop++) { if (dlProduct.Items[Loop].Value == txtProduct.Text) { //we found the new user dlProduct.SelectedIndex = Loop; } } loadVersion(conAW); for (int Loop = 0; Loop < dlVersion.Items.Count; Loop++) { if (dlVersion.Items[Loop].Value == txtVersion.Text) { //we found the new user dlVersion.SelectedIndex = Loop; } } loadDetail(conAW); } else { //we are saving a new user SaveNewSoftware(conAW); //reload the list loadSoftware(conAW); //now select the new user record for (int Loop = 0; Loop < dlSoftNum.Items.Count; Loop++) { if (dlSoftNum.Items[Loop].Value == txtDeveloper.Text) { //we found the new user dlSoftNum.SelectedIndex = Loop; } } loadProductName(conAW); for (int Loop = 0; Loop < dlProduct.Items.Count; Loop++) { if (dlProduct.Items[Loop].Value == txtProduct.Text) { //we found the new user dlProduct.SelectedIndex = Loop; } } loadVersion(conAW); for (int Loop = 0; Loop < dlVersion.Items.Count; Loop++) { if (dlVersion.Items[Loop].Value == txtVersion.Text) { //we found the new user dlVersion.SelectedIndex = Loop; } } //reload the form loadDetail(conAW); } break; case "btnAdd": ClearFormModel(); //clear out modal form //txtSoftID.Text = "This is Auto Generate Number"; //txtSoftID.Enabled = false; //txtProduct.Text = ""; //txtDeveloper.Text = ""; //txtLicenseKey.Text = ""; //txtVersion.Text = ""; lblAddEditSoftware.InnerHtml = "Add new Software"; Page.ClientScript.RegisterStartupScript(this.GetType(), "mysScript", "initMyModal('mdlNewEditSoftware');", true); break; case "btnNewSoftwareCancel": cEdit = false; break; case "btnDelete": //string alert = ""; //BootstrapAlert(lblMsg, "Congrats! You've won a dismissable booty message.", // BootstrapAlertType.Success, True); //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); if (dlSoftNum.SelectedIndex == 0 || dlProduct.SelectedIndex == 0 || dlVersion.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please select Developer, Product Name, and Version')", true); } else { lblDeleteSoftMsg.InnerHtml = "Are you sure you want to delete the Software: " + dlProduct.SelectedItem.Value + " " + dlVersion.SelectedItem.Value + " ?"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteSoftware');", true); } break; case "btnDeleteSoftSave": DeleteSoftware(conAW); if (noDelete) // if true don't need to clear the table, but if been used, will clear the table { // this is not popup when it is true. //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", //"alert('Sorry Can't delete that software! The Software is used by the Computers: " + nscc + " ')", true); hasData = hasData - 1; table.Append("<table border='1'>"); table.Append("<tr><th>QTY Used</th><th>The Software been used by the Computers:</th>"); table.Append("</tr>"); table.Append("<tr>"); table.Append("<td>" + hasData + "</td>"); table.Append("<td>" + nscc + "</td>"); table.Append("</tr>"); table.Append("</table"); PlaceHolder1.Controls.Add(new Literal { Text = table.ToString() }); } else { //Reload user list loadSoftware(conAW); dlProduct.Items.Clear(); dlProduct.Enabled = false; dlVersion.Items.Clear(); dlVersion.Enabled = false; lblLicense.Enabled = false; lblLicense.Text = ""; //Reload main form //loadDetail(conAW); } break; } //Close the connection to the DB PopulateGridview(conAW); conAW.Close(); conAW.Dispose(); } } catch (Exception ex) { ErrLog EL = new ErrLog(); EL.SaveErrLog("Module: DefaultPage" + Environment.NewLine + "Function: Page_Load" + Environment.NewLine + "ErrorMessage: " + ex.Message); Response.Write(@"<script>alert('Error Message: " + ex.Message.ToString() + "');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { try { //Open a connection to the database string conStr = ConfigurationManager.ConnectionStrings["conAW"].ConnectionString; SqlConnection conAW = new SqlConnection(conStr); conAW.Open(); if (!IsPostBack) { //We are loading the page for the first time loadCampus(conAW); } else { //We need to find out what control caused the postback getPostBackControl clsCtl = new getPostBackControl(); string ctl = clsCtl.getPostBackControlName(Page); switch (ctl) { case "dlCampusName": loadDetail(conAW); break; case "dlBuilding": loadDetailRoom(conAW); break; case "dlRoom": loadComputers(conAW); //Call the js function to show the modal popup //lblAddEditCourse.InnerHtml = "Edit Customer"; //cEdit = true; //Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditEmployee');", true); break; case "dlNSCCEquipmentNumber": //Will need more code to see if we are editing or saving a new employee saveNSCCEquipmentNumber = dlNSCCEquipmentNumber.SelectedItem.Value; loadComputers(conAW); loadSoftwareInstalled(conAW); //if (cEdit) //{ //We are saving an edited customer // SaveEditCustomer(conAW); // cEdit = false; // loadCustomer(conAW); // //Now select the edited customer record // for (int Loop = 0; Loop < dlCustomer.Items.Count; Loop++) // { // if (dlCustomer.Items[Loop].Value == editCustomerID) // { // //We found the edited Customer // dlCustomer.SelectedIndex = Loop; // } // } // loadDetail(conAW); //} //else //{ //We are saving a new customer // SaveNewCustomer(conAW); // //Reload the dropdown list // loadCustomer(conAW); // //Now select the new customer record // for (int Loop = 0; Loop < dlCustomer.Items.Count; Loop++) // { // if (dlCustomer.Items[Loop].Value == newCustomerID) // { // //We found the new Customer // dlCustomer.SelectedIndex = Loop; // } // } // //Reload the main form // loadDetail(conAW); //} //Also need code to reload the dropdownlist and reload the page detail break; //case "btnAdd": // //Clear out the modal form // txtFName.Text = ""; // txtMI.Text = ""; // txtLName.Text = ""; // txtCompanyName.Text = ""; // lblAddEditCourse.InnerHtml = "Add New Customer"; // Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlNewEditEmployee');", true); // break; //case "btnNewEmpCancel": // cEdit = false; // break; //case "btnDelete": // lblDeleteEmpMsg.InnerHtml = "Are you sure you want to delete the employee: " + lblFName.Text + " " // + lblMI.Text + " " // + lblLName.Text; // Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('mdlDeleteEmployee');", true); // break; //case "btnDeleteEmpSave": // DeleteCustomer(conAW); // //Reload the dropdown list // loadCustomer(conAW); // //Reload the main form // loadDetail(conAW); // break; } } //Close the connection to the DB conAW.Close(); conAW.Dispose(); } catch (Exception ex) { ErrLog EL = new ErrLog(); EL.SaveErrLog("Module: DefaultPage" + Environment.NewLine + "Function: Page_Load" + Environment.NewLine + "Error Message: " + ex.Message); Response.Write(@"<script>alert('Error Message: " + ex.Message.ToString() + "');</script>"); } //To stop the user from entering this page if they are not logged in. string strValidLogin = ""; if (Session["VALIDLOGIN"] != null) { strValidLogin = Session["VALIDLOGIN"].ToString(); if (strValidLogin == "false") { Response.Redirect("Default.aspx"); } } else { Response.Redirect("Default.aspx"); } }