Example #1
0
        protected override void Page_Load(object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);

            DataTool dbTool = new DataTool();

            Page.Focus();

            DataTable dtRigs      = dbTool.getRigIDs();
            DataTable dtEmployers = dbTool.getEmpolyerIDs();
            DataTable dtCompanies = dbTool.getCompanyIDs();

            initDropDown_BL(cboRigID, dtRigs, 1);
            initDropDown_BL(cboEmployer, dtEmployers, 1);
            initDropDown_BL(cboDrillFor, dtCompanies, 1);
            initDropDown_BL(cboMedic, dbTool.getAllMedics(), 1);
        }
        protected override void Page_Load(object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);

            EncodeControls();
            // check if the query string has any values, if so set the session variables accordingly
            if (cboIncomplete.SelectedValue.Length < 1 && Convert.ToBoolean(Request.QueryString.Count))
            {
                if (Request.QueryString["pKey"] != null)
                {
                    Session["PatientID"] = Request.QueryString["pKey"].ToString();
                }
                if (Request.QueryString["mode"] != null)
                {
                    Session["mode"] = Request.QueryString["mode"].ToString();
                }
            }

            // on change event to the birthdate field to calculate the age
            txtBirthdate.Attributes.Add("onBlur", "calcAge(this.form.elements['txtBirthdate'].value);");
            lblSSN.ToolTip = "Social Security #: 123-45-6789\nPassport #: 12345678";
            txtSSN.ToolTip = "Social Security #: 123-45-6789\nPassport #: 12345678";

            // get the authenticated username and put it in a session variable
            User   authUser = new User(HttpContext.Current.User.Identity.Name);
            string tmpUser  = authUser.ReturnUser();

            if (!IsPostBack)
            {
                DataTool  dbTool    = new DataTool();
                DataTable medicInfo = dbTool.getMedicInfo(tmpUser);

                if (medicInfo.Rows.Count > 0)
                {
                    Session["MedicID"] = medicInfo.Rows[0]["UserName"].ToString();

                    // Storing the Medic's ID here to fix the search page
                    // Lancelot 7/7/04
                    Session["MedicPK"] = medicInfo.Rows[0]["MedicID"].ToString();

                    // 7/23/2004 Scott
                    // if the medic is in the table, but is not assigned to a rig they are considered an admin user
                    // this user can see encounters for all rigs
                    if (Convert.IsDBNull(medicInfo.Rows[0]["RigID"]))
                    {
                        Session["RigID"] = "0";
                    }
                    else
                    {
                        Session["RigID"] = medicInfo.Rows[0]["RigID"].ToString();
                    }

                    //Logging program use to IntranetLog
                    //Latham 05/20/2005
                    dbTool.LogUse(System.Convert.ToInt32(Session["MedicPK"]), 5);


                    DataTable dtIncompletes = new DataTable();
                    // incomplete sql, if the user has a 0 for their rigid then they can see all encounters
                    if (Session["RigID"].ToString() == "0")
                    {
                        dtIncompletes = dbTool.getAllIncomplete();
                    }
                    else
                    {
                        dtIncompletes = dbTool.getRigIncomplete(Session["MedicPK"].ToString());
                    }

                    // load the drop downlists
                    DataTable dtRigs      = dbTool.getRigIDs();
                    DataTable dtEmployers = dbTool.getEmpolyerIDs();
                    DataTable dtCompanies = dbTool.getCompanyIDs();
                    DataTable dtRigIDs    = new DataTable();

                    initDropDown_BL(cboIncomplete, dtIncompletes, 1);
                    initDropDown_BL(cboRigID, dtRigs, 1);
                    initDropDown_BL(cboEmployer, dtEmployers, 1);
                    initDropDown_BL(cboDrillFor, dtCompanies, 1);

                    // if there are no incomplete encounters for this rig then do not show this section
                    if (cboIncomplete.Items.Count < 2)
                    {
                        spIncomplete.Visible = false;
                    }

                    // hide the edit button
                    btnEdit.Visible = false;

                    if (Session["mode"] != null && Session["mode"].ToString() == "view")
                    {
                        // if there is no patient key in the querystring then set the form to add mode
                        if (Request.QueryString["pKey"] != null)
                        {
                            // add the javascript initSpan function to the onload of the body
                            bodyMain.Attributes.Add("onLoad", "initSpan()");

                            // disable the input boxes and show the data from the database
                            enterData();

                            LoadData(Convert.ToInt32(Request.QueryString["pKey"]), true);

                            // disable the asp.net button
                            btnReset.Visible    = false;
                            btnContinue.Visible = false;
                            btnEdit.Visible     = true;
                            btnEdit.Attributes.Add("onClick", "location.href='Medical.aspx';");
                        }
                    }

                    // Shortcut because Lance is a lazy bastard and hates typing all this
                    // crap out every time.
                    if (Environment.MachineName == "HTX5Y21")
                    {
                        FillOutControls();
                    }
                }
                else
                {
                    // redirect to custom error page and send a parameter user=unauthorized
                    // display a custom error telling them they have to be assigned to a rig to enter the application
                    Response.Redirect("CustError.aspx?user=unauthorized");
                }
            }

            if (System.Convert.ToBoolean(Session["SearchComplete"]) == true)
            {
                if (Session["mode"] != null && Session["mode"].ToString() == "view")
                {
                    // if there is no patient key in the querystring then set the form to add mode
                    if (Session["PatientID"] != null)
                    {
                        // add the javascript initSpan function to the onload of the body
                        bodyMain.Attributes.Add("onLoad", "initSpan()");

                        // disable the input boxes and show the data from the database
                        enterData();
                        SQLPatient sqlPatient = new SQLPatient();
                        DataTool   dbTool     = new DataTool();
                        DataTable  dT         = dbTool.getPatientInfo(Int32.Parse(Session["PatientID"].ToString()));
                        Patients   Patient    = new Patients();
                        sqlPatient.LoadObject(Patient, dT);
                        LoadControls_BL(Patient);

                        // disable the asp.net button
                        btnReset.Visible    = false;
                        btnContinue.Visible = false;
                        btnEdit.Visible     = true;
                        btnEdit.Attributes.Add("onClick", "location.href='Medical.aspx';");
                    }
                }
            }
            Session["SearchComplete"] = false;
        }