コード例 #1
0
    protected void GrdReferrer_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlTitle = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewTitle");
            TextBox      txtName  = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewName");
            TextBox      txtABN   = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewABN");
            TextBox      txtACN   = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewACN");

            OrganisationDB.InsertExtOrg(191, txtName.Text, txtACN.Text, txtABN.Text, false, false, "", "");

            FillGrid();
        }

        if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete"))
        {
            try
            {
                // if getting orgs of a referer, set the reg-ref relationship as active/inactive
                if (Request.QueryString["referrer"] != null)
                {
                    int reg_ref_id = Convert.ToInt32(e.CommandArgument);

                    if (e.CommandName.Equals("_Delete"))
                    {
                        RegisterReferrerDB.UpdateInactive(reg_ref_id);
                    }
                    else
                    {
                        RegisterReferrerDB.UpdateActive(reg_ref_id);
                    }
                }

                // if getting all orgs, set the org as active/inactive
                else
                {
                    int org_id = Convert.ToInt32(e.CommandArgument);

                    if (e.CommandName.Equals("_Delete"))
                    {
                        OrganisationDB.UpdateInactive(org_id);
                    }
                    else
                    {
                        OrganisationDB.UpdateActive(org_id);
                    }
                }
            }
            catch (ForeignKeyConstraintException fkcEx)
            {
                if (Utilities.IsDev())
                {
                    SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
                }
                else
                {
                    SetErrorMessage("Can not delete because other records depend on this");
                }
            }

            FillGrid();
        }

        if (e.CommandName.Equals("ViewPatients"))
        {
            int id = Convert.ToInt32(e.CommandArgument);

            if (Request.QueryString["referrer"] == null)
            {
                FillGrid_Patients(typeof(Organisation), id);
            }
            else
            {
                FillGrid_Patients(typeof(RegisterReferrer), id);
            }
        }
    }
コード例 #2
0
    protected void GrdReferrer_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlRefs               = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewRefs");
            TextBox      txtProviderNumber     = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewProviderNumber");
            CheckBox     chkIsReportEveryVisit = (CheckBox)GrdReferrer.FooterRow.FindControl("chkNewIsReportEveryVisit");
            CheckBox     chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdReferrer.FooterRow.FindControl("chkNewIsBatchSendAllPatientsTreatmentNotes");

            if (RegisterReferrerDB.Exists(Convert.ToInt32(Request.QueryString["org"]), Convert.ToInt32(ddlRefs.SelectedValue)))
            {
                SetErrorMessage("Clinic is already linked to " + ddlRefs.SelectedItem.Text + ". If it is not visible, use the 'show deleted' checkbox and un-delete it.");
                return;
            }

            RegisterReferrerDB.Insert(Convert.ToInt32(Request.QueryString["org"]), Convert.ToInt32(ddlRefs.SelectedValue), txtProviderNumber.Text.Trim(), chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked);

            FillGrid();
        }

        if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete"))
        {
            try
            {
                // if getting referers of an org, set the reg-ref relationship as active/inactive
                if (Request.QueryString["org"] != null)
                {
                    int reg_ref_id = Convert.ToInt32(e.CommandArgument);

                    if (e.CommandName.Equals("_Delete"))
                    {
                        RegisterReferrerDB.UpdateInactive(reg_ref_id);
                    }
                    else
                    {
                        RegisterReferrerDB.UpdateActive(reg_ref_id);
                    }
                }

                // if getting all referrers, set the ref as active/inactive
                else
                {
                    int referrer_id = Convert.ToInt32(e.CommandArgument);

                    if (e.CommandName.Equals("_Delete"))
                    {
                        ReferrerDB.UpdateInactive(referrer_id);
                    }
                    else
                    {
                        ReferrerDB.UpdateActive(referrer_id);
                    }
                }
            }
            catch (ForeignKeyConstraintException fkcEx)
            {
                if (Utilities.IsDev())
                {
                    SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
                }
                else
                {
                    SetErrorMessage("Can not delete because other records depend on this");
                }
            }

            FillGrid();
        }

        if (e.CommandName.Equals("ViewPatients"))
        {
            int id = Convert.ToInt32(e.CommandArgument);

            if (Request.QueryString["org"] == null)
            {
                FillGrid_Patients(typeof(Referrer), id);
            }
            else
            {
                FillGrid_Patients(typeof(RegisterReferrer), id);
            }
        }
    }
コード例 #3
0
    protected void GrdReferrer_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlTitle      = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewTitle");
            TextBox      txtFirstname  = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewFirstname");
            TextBox      txtMiddlename = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewMiddlename");
            TextBox      txtSurname    = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewSurname");
            DropDownList ddlGender     = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewGender");

            txtFirstname.Text  = txtFirstname.Text.Trim();
            txtMiddlename.Text = txtMiddlename.Text.Trim();
            txtSurname.Text    = txtSurname.Text.Trim();

            if (txtSurname.Text.Length == 0)
            {
                SetErrorMessage("Surname can not be empty");
                return;
            }
            if (txtSurname.Text.Length == 0)
            {
                SetErrorMessage("Firstname can not be empty");
                return;
            }

            Staff loggedInStaff = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"]));
            int   person_id     = PersonDB.Insert(loggedInStaff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), "", ddlGender.SelectedValue, new DateTime(1900, 1, 1));
            ReferrerDB.Insert(person_id);

            FillGrid();

            SetErrorMessage("Added.");
        }

        if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete"))
        {
            try
            {
                // if getting referers of an org, set the reg-ref relationship as active/inactive
                if (Request.QueryString["org"] != null)
                {
                    int reg_ref_id = Convert.ToInt32(e.CommandArgument);

                    if (e.CommandName.Equals("_Delete"))
                    {
                        RegisterReferrerDB.UpdateInactive(reg_ref_id);
                    }
                    else
                    {
                        RegisterReferrerDB.UpdateActive(reg_ref_id);
                    }
                }

                // if getting all referrers, set the ref as active/inactive
                else
                {
                    int referrer_id = Convert.ToInt32(e.CommandArgument);

                    if (e.CommandName.Equals("_Delete"))
                    {
                        ReferrerDB.UpdateInactive(referrer_id);
                    }
                    else
                    {
                        ReferrerDB.UpdateActive(referrer_id);
                    }
                }
            }
            catch (ForeignKeyConstraintException fkcEx)
            {
                if (Utilities.IsDev())
                {
                    SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
                }
                else
                {
                    SetErrorMessage("Can not delete because other records depend on this");
                }
            }

            FillGrid();
        }

        if (e.CommandName.Equals("ViewPatients"))
        {
            int id = Convert.ToInt32(e.CommandArgument);

            if (Request.QueryString["org"] == null)
            {
                FillGrid_Patients(typeof(Referrer), id);
            }
            else
            {
                FillGrid_Patients(typeof(RegisterReferrer), id);
            }
        }
    }
コード例 #4
0
    protected void GrdReferrer_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlTitle      = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewTitle");
            TextBox      txtFirstname  = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewFirstname");
            TextBox      txtMiddlename = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewMiddlename");
            TextBox      txtSurname    = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewSurname");
            DropDownList ddlGender     = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewGender");

            TextBox txtName = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewName");
            TextBox txtABN  = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewABN");
            TextBox txtACN  = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewACN");

            TextBox      txtProviderNumber     = (TextBox)GrdReferrer.FooterRow.FindControl("txtNewProviderNumber");
            DropDownList ddlIsClinic           = (DropDownList)GrdReferrer.FooterRow.FindControl("ddlNewIsClinic");
            CheckBox     chkIsReportEveryVisit = (CheckBox)GrdReferrer.FooterRow.FindControl("chkNewIsReportEveryVisit");
            CheckBox     chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdReferrer.FooterRow.FindControl("chkNewIsBatchSendAllPatientsTreatmentNotes");


            int person_id            = -1;
            int referrer_id          = -1;
            int organisation_id      = 0;
            int register_referrer_id = -1;

            try
            {
                Staff loggedInStaff = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"]));
                person_id            = PersonDB.Insert(loggedInStaff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), "", ddlGender.SelectedValue, new DateTime(1900, 1, 1));
                referrer_id          = ReferrerDB.Insert(person_id);
                organisation_id      = OrganisationDB.InsertExtOrg(191, txtName.Text, txtACN.Text, txtABN.Text, false, false, "", "");
                register_referrer_id = RegisterReferrerDB.Insert(organisation_id, referrer_id, txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked);

                FillGrid();
            }
            catch (Exception)
            {
                // roll back - backwards of creation order
                RegisterReferrerDB.Delete(register_referrer_id);
                OrganisationDB.Delete(organisation_id);
                ReferrerDB.Delete(referrer_id);
                PersonDB.Delete(person_id);
            }
        }

        if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete"))
        {
            int register_referrer_id = Convert.ToInt32(e.CommandArgument);

            try
            {
                if (e.CommandName.Equals("_Delete"))
                {
                    RegisterReferrerDB.UpdateInactive(register_referrer_id);
                }
                else
                {
                    RegisterReferrerDB.UpdateActive(register_referrer_id);
                }
            }
            catch (ForeignKeyConstraintException fkcEx)
            {
                if (Utilities.IsDev())
                {
                    SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
                }
                else
                {
                    SetErrorMessage("Can not delete because other records depend on this");
                }
            }

            FillGrid();
        }
    }