Exemple #1
0
    protected void GrdReferrer_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId                 = (Label)GrdReferrer.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlRefs               = (DropDownList)GrdReferrer.Rows[e.RowIndex].FindControl("ddlRefs");
        TextBox      txtProviderNumber     = (TextBox)GrdReferrer.Rows[e.RowIndex].FindControl("txtProviderNumber");
        CheckBox     chkIsReportEveryVisit = (CheckBox)GrdReferrer.Rows[e.RowIndex].FindControl("chkIsReportEveryVisit");
        CheckBox     chkIsBatchSendAllPatientsTreatmentNotes = (CheckBox)GrdReferrer.Rows[e.RowIndex].FindControl("chkIsBatchSendAllPatientsTreatmentNotes");


        RegisterReferrer regRef = RegisterReferrerDB.GetByID(Convert.ToInt32(lblId.Text));

        if (RegisterReferrerDB.Exists(regRef.Organisation.OrganisationID, Convert.ToInt32(ddlRefs.SelectedValue), regRef.RegisterReferrerID))
        {
            SetErrorMessage("Clinic is already linked to " + ddlRefs.SelectedItem.Text + ". If it is not visible, use the 'show deleted' checkbox and un-delete it.");
            GrdReferrer.EditIndex = -1;
            FillGrid();
            return;
        }

        RegisterReferrerDB.Update(
            regRef.RegisterReferrerID,
            regRef.Organisation.OrganisationID,
            Convert.ToInt32(ddlRefs.SelectedValue),
            txtProviderNumber.Text.Trim(),
            chkIsReportEveryVisit.Checked,
            chkIsBatchSendAllPatientsTreatmentNotes.Checked,
            regRef.DateLastBatchSendAllPatientsTreatmentNotes);

        GrdReferrer.EditIndex = -1;
        FillGrid();
    }
    protected bool IsValidFormRef()
    {
        string regRefID = Request.QueryString["ref"];

        return(regRefID != null && Regex.IsMatch(regRefID, @"^\d+$") && RegisterReferrerDB.Exists(Convert.ToInt32(regRefID)));
    }
Exemple #3
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);
            }
        }
    }