Exemplo n.º 1
0
    protected void FillGrid()
    {
        DataTable dt = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "BookingUnavailabilityReason", "", "booking_unavailability_reason_type_id, descr", "booking_unavailability_reason_id", "booking_unavailability_reason_type_id", "descr");

        Session["bookingunavailabilityreason_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            GrdBookingUnavailabilityReason.DataSource = dt;
            try
            {
                GrdBookingUnavailabilityReason.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdBookingUnavailabilityReason.DataSource = dt;
            GrdBookingUnavailabilityReason.DataBind();

            int TotalColumns = GrdBookingUnavailabilityReason.Rows[0].Cells.Count;
            GrdBookingUnavailabilityReason.Rows[0].Cells.Clear();
            GrdBookingUnavailabilityReason.Rows[0].Cells.Add(new TableCell());
            GrdBookingUnavailabilityReason.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdBookingUnavailabilityReason.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemplo n.º 2
0
    protected void FillGrid()
    {
        DataTable dt = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "OrganisationCustomerType", "organisation_customer_type_id NOT IN (0,139,275)", "descr", "organisation_customer_type_id", "descr");

        Session["organisationcustomertype_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            GrdOrganisationCustomerType.DataSource = dt;
            try
            {
                GrdOrganisationCustomerType.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdOrganisationCustomerType.DataSource = dt;
            GrdOrganisationCustomerType.DataBind();

            int TotalColumns = GrdOrganisationCustomerType.Rows[0].Cells.Count;
            GrdOrganisationCustomerType.Rows[0].Cells.Clear();
            GrdOrganisationCustomerType.Rows[0].Cells.Add(new TableCell());
            GrdOrganisationCustomerType.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdOrganisationCustomerType.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                Utilities.SetNoCache(Response);
            }
            HideErrorMessage();
            Utilities.UpdatePageHeaderV2(Page.Master, true);

            if (!IsPostBack)
            {
                Session.Remove("suburb_sortExpression");
                Session.Remove("suburb_data");


                ddlState.Items.Add(new ListItem("All", "All"));
                DataTable states = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Suburb", "", "state", "distinct state");
                foreach (DataRow row in states.Rows)
                {
                    ddlState.Items.Add(new ListItem(row["state"].ToString(), row["state"].ToString()));
                }

                SystemVariable sysVariable = SystemVariableDB.GetByDescr("DefaultState");
                if (sysVariable != null && sysVariable.Value.Trim() != "")
                {
                    ddlState.SelectedValue = sysVariable.Value.Trim();
                }

                FillSuburbGrid();
            }

            this.GrdSuburb.EnableViewState = true;
        }
        catch (CustomMessageException ex)
        {
            if (IsPostBack)
            {
                SetErrorMessage(ex.Message);
            }
            else
            {
                HideTableAndSetErrorMessage(ex.Message);
            }
        }
        catch (Exception ex)
        {
            if (IsPostBack)
            {
                SetErrorMessage("", ex.ToString());
            }
            else
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
    }
Exemplo n.º 4
0
    protected void btnUpdateStreetAndSuburb_Click(object sender, EventArgs e)
    {
        DataTable addrChannelTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "AddressChannelType", "", "descr", "address_channel_type_id", "descr");

        ddlAddressChannelType.Items.Clear();
        ddlAddressChannelType.Items.Add(new ListItem("--", "-1"));
        foreach (DataRow row in addrChannelTypes.Rows)
        {
            ddlAddressChannelType.Items.Add(new ListItem(row["descr"].ToString(), row["address_channel_type_id"].ToString()));
        }
    }
    public void SetupGUI()
    {
        UrlParamType urlParamType = GetUrlParamType();

        DataTable paymentTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "ReceiptPaymentType", "", "descr", "receipt_payment_type_id,descr");

        ddlPaymentType.DataSource = paymentTypes;
        ddlPaymentType.DataBind();

        bool editable = GetUrlParamType() == UrlParamType.Add || GetUrlParamType() == UrlParamType.Edit || GetUrlParamType() == UrlParamType.Reconcile;

        Utilities.SetEditControlBackColour(ddlPaymentType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtTotal, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtAmountReconciled, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
    }
    private IDandDescr GetFormInvType()
    {
        if (!IsValidFormInvType())
        {
            throw new Exception("Invalid url inv type");
        }

        DataTable invTypesByUrlParam = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "OfferingInvoiceType", "offering_invoice_type_id=" + Request.QueryString["inv_type"], "", "offering_invoice_type_id", "descr");

        if (invTypesByUrlParam.Rows.Count == 0)
        {
            throw new Exception("Invalid url inv type");
        }

        return(IDandDescrDB.Load(invTypesByUrlParam.Rows[0], "offering_invoice_type_id", "descr"));
    }
Exemplo n.º 7
0
    public void SetupGUI()
    {
        string allFeaturesType = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no";
        string jsType          = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType + "');document.getElementById('btnUpdateType').click();return false;";

        string allFeatures = "dialogWidth:1100px;dialogHeight:600px;center:yes;resizable:no; scroll:no";
        string js          = "javascript:window.showModalDialog('" + "StreetAndSuburbInfo.aspx', '', '" + allFeatures + "');document.getElementById('btnUpdateStreetAndSuburb').click();return false;";

        lnkUpdateType.NavigateUrl = "  ";
        lnkUpdateType.Text        = "Add/Edit";
        lnkUpdateType.Attributes.Add("onclick", jsType);

        if (Utilities.IsMobileDevice(Request))
        {
            hiddenIsMobileDevice.Value = "1";
            lnkUpdateType.Visible      = false;
        }

        DataTable addrChannelTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "AddressChannelType", "", "descr", "address_channel_type_id", "descr");

        ddlAddressChannelType.Items.Add(new ListItem("--", "-1"));
        foreach (DataRow row in addrChannelTypes.Rows)
        {
            ddlAddressChannelType.Items.Add(new ListItem(row["descr"].ToString(), row["address_channel_type_id"].ToString()));
        }

        DataTable countries = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Country", "", "descr", "country_id", "descr");

        ddlCountry.Items.Add(new ListItem("--", "-1"));
        foreach (DataRow row in countries.Rows)
        {
            ddlCountry.Items.Add(new ListItem(row["descr"].ToString(), row["country_id"].ToString()));
        }
        ddlCountry.SelectedIndex = Utilities.IndexOf(ddlCountry, "australia");


        bool editable = GetUrlParamType() == UrlParamType.Add || GetUrlParamType() == UrlParamType.Edit;

        Utilities.SetEditControlBackColour(ddlContactType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtFreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtAddrLine1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtAddrLine2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtStreet, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlAddressChannelType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlCountry, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
    }
Exemplo n.º 8
0
    private void FillEmptyAddForm()
    {
        Page.Title      = ((SystemVariables)Session["SystemVariables"])["Site"].Value + " - " + "Add Staff";
        lblHeading.Text = "Add Staff";

        txtFirstname.Focus();

        this.lnkThisStaff.Visible = false;


        txtPwd.TextMode = TextBoxMode.SingleLine;

        ddlTitle.DataSource = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr");
        ddlTitle.DataBind();
        ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "mr", "mr.");

        DataTable fields = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id <> 0", "descr", "field_id", "descr");

        ddlField.DataSource = fields;
        ddlField.DataBind();
        //DataTable costcentres = CostCentreDB.GetDataTable();
        //ddlCostCentre.DataSource = costcentres;
        //ddlCostCentre.DataBind();

        idRow.Visible                 = false;
        lblAddedByText.Visible        = false;
        lblAddedBy.Visible            = false;
        lblStaffDateAddedText.Visible = false;
        lblStaffDateAdded.Visible     = false;
        lblPwd.Visible                = false;

        existingStaffInfoSpace.Visible = false;
        existingStaffInfo.Visible      = false;


        chkIsCommission.Checked   = true;
        txtCommissionPercent.Text = "0.00";

        btnSubmit.Text = "Add Staff Member";
    }
    private IDandDescr GetFormMedicalSserviceType()
    {
        string mst = Request.QueryString["mst"];

        if (mst == null)
        {
            return(null);
        }
        if (!Regex.IsMatch(mst, @"^\d+$"))
        {
            throw new CustomMessageException("Invalid mst");
        }

        DataTable dt = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "MedicalServiceType", "medical_service_type_id=" + mst, "", "medical_service_type_id", "descr");

        if (dt.Rows.Count == 0)
        {
            throw new CustomMessageException("Invalid mst");
        }

        return(IDandDescrDB.Load(dt.Rows[0], "medical_service_type_id", "descr"));
    }
Exemplo n.º 10
0
    private void FillEmptyAddForm()
    {
        Page.Title      = ((SystemVariables)Session["SystemVariables"])["Site"].Value + " - " + "Add External Staff";
        lblHeading.Text = "Add External Staff";

        this.lnkThisStaff.Visible = false;

        ddlTitle.DataSource = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr");
        ddlTitle.DataBind();
        ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "mr", "mr.");

        idRow.Visible                 = false;
        lblAddedByText.Visible        = false;
        lblAddedBy.Visible            = false;
        lblStaffDateAddedText.Visible = false;
        lblStaffDateAdded.Visible     = false;
        lblPwd.Visible                = false;

        existingStaffInfoSpace.Visible = false;
        existingStaffInfo.Visible      = false;


        btnSubmit.Text = "Add External Staff Member";
    }
Exemplo n.º 11
0
    protected void GrdOrganisation_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable types = null;

        switch (GetUrlParamType())
        {
        case UrlParamType.Clinic:
            types = OrganisationTypeDB.GetDataTable_Clinics();
            break;

        case UrlParamType.AgedCare:
            types = OrganisationTypeDB.GetDataTable_AgedCareFacs();
            break;

        case UrlParamType.External:
            if (IsValidFormOrgTypeIDs())
            {
                types = OrganisationTypeDB.GetDataTable_External(GetFormOrgTypeIDs().ToString());
            }
            else
            {
                types = OrganisationTypeDB.GetDataTable_External();
            }
            break;

        default:
            types = OrganisationTypeDB.GetDataTable();
            break;
        }

        //DataTable custTypes2 = DBBase.GetGenericDataTable(null, "OrganisationCustomerType", "organisation_customer_type_id", "descr");
        DataTable custTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "OrganisationCustomerType", "organisation_customer_type_id NOT IN (139,275)", "", "organisation_customer_type_id", "descr");
        DataTable dt        = Session["organisationinfo_data"] as DataTable;
        bool      tblEmpty  = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            bool      hasData   = dt.Rows[0][0].ToString() != string.Empty;
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("organisation_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];


            HyperLink lnkRegistraterReferrers = (HyperLink)e.Row.FindControl("lnkRegistraterReferrers");
            if (lnkRegistraterReferrers != null)
            {
                lnkRegistraterReferrers.Visible = (dt.Rows[e.Row.RowIndex]["organisation_type_id"].ToString() == "191");
            }


            ImageButton lnkFullEdit = (ImageButton)e.Row.FindControl("lnkFullEdit");
            if (lnkFullEdit != null)
            {
                if (Request.QueryString["type"] == null || !hasData)
                {
                    lnkFullEdit.Visible = false;
                }
                else
                {
                    lnkFullEdit.PostBackUrl = "~/OrganisationDetailV2.aspx?type=view&id=" + Convert.ToInt32(lblId.Text) + "&orgtype=" + Request.QueryString["type"];
                }
            }

            DropDownList ddlParent = (DropDownList)e.Row.FindControl("ddlParent");
            if (ddlParent != null)
            {
                /*
                 * Organisation[] thisOrg = new Organisation[] { OrganisationDB.GetByID(Convert.ToInt32(lblId.Text)) };
                 *
                 * bool exclClinics      = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.Clinic;
                 * bool exclAgedCareFacs = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.AgedCare;
                 * bool exclExternal     = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.External;
                 * bool exclIns          = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.Insurance;
                 * DataTable parentList = OrganisationDB.GetDataTable_AllNotInc(thisOrg, false, exclClinics, exclAgedCareFacs, exclIns, exclExternal);
                 *
                 * ddlParent.Items.Add(new ListItem("--","0"));
                 * foreach (DataRow row in parentList.Rows)
                 *  ddlParent.Items.Add(new ListItem(row["name"].ToString(), row["organisation_id"].ToString()));
                 * ddlParent.SelectedValue = thisRow["parent_organisation_id"].ToString();
                 */

                ddlParent.Items.Clear();
                ddlParent.Items.Add(new ListItem("--", "0"));
                foreach (DataRow row in GetOrgsDaTatable(GetUrlParamType(), true).Rows)
                {
                    bool isThisOrg   = Convert.ToInt32(row["organisation_id"]) == Convert.ToInt32(thisRow["organisation_id"]);
                    bool isDeleted   = Convert.ToBoolean(row["is_deleted"]);
                    bool isParentOrg = thisRow["parent_organisation_id"] != DBNull.Value && Convert.ToInt32(row["organisation_id"]) == Convert.ToInt32(thisRow["parent_organisation_id"]);
                    if (!isThisOrg && (!isDeleted || isParentOrg))
                    {
                        ddlParent.Items.Add(new ListItem(row["name"].ToString(), row["organisation_id"].ToString()));
                    }
                }
                ddlParent.SelectedValue = thisRow["parent_organisation_id"].ToString();
            }
            DropDownList ddlType = (DropDownList)e.Row.FindControl("ddlType");
            if (ddlType != null)
            {
                foreach (DataRow row in types.Rows)
                {
                    string prefix = Convert.ToInt32(row["organisation_type_group_id"]) == 4 ? "Ext. " : "";
                    ddlType.Items.Add(new ListItem(prefix + row["descr"].ToString(), row["organisation_type_id"].ToString()));
                }
                ddlType.SelectedValue = thisRow["organisation_type_id"].ToString();
            }
            DropDownList ddlCustType = (DropDownList)e.Row.FindControl("ddlCustType");
            if (ddlCustType != null)
            {
                ddlCustType.DataSource     = custTypes;
                ddlCustType.DataTextField  = "descr";
                ddlCustType.DataValueField = "organisation_customer_type_id";
                ddlCustType.DataBind();

                if (ddlCustType.Items.FindByValue(thisRow["ct_organisation_customer_type_id"].ToString()) == null)
                {
                    ddlCustType.Items.Add(new ListItem(thisRow["ct_descr"].ToString(), thisRow["ct_organisation_customer_type_id"].ToString()));
                }

                ddlCustType.SelectedValue = thisRow["ct_organisation_customer_type_id"].ToString();
            }
            DropDownList ddlServiceCycle = (DropDownList)e.Row.FindControl("ddlServiceCycle");
            if (ddlServiceCycle != null)
            {
                for (int i = 0; i <= 52; i++)
                {
                    ddlServiceCycle.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                ddlServiceCycle.SelectedValue = thisRow["weeks_per_service_cycle"].ToString();
            }
            DropDownList ddlFreeServices = (DropDownList)e.Row.FindControl("ddlFreeServices");
            if (ddlFreeServices != null)
            {
                for (int i = 0; i <= 5; i++)
                {
                    ddlFreeServices.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                ddlFreeServices.SelectedValue = thisRow["free_services"].ToString();
            }


            HyperLink lnkBookings    = (HyperLink)e.Row.FindControl("lnkBookings");
            HyperLink lnkBookingList = (HyperLink)e.Row.FindControl("lnkBookingList");

            if (lnkBookings != null && lnkBookingList != null && hasData &&
                (Convert.ToInt32(dt.Rows[e.Row.RowIndex]["type_organisation_type_group_id"]) == 5 ||
                 Convert.ToInt32(dt.Rows[e.Row.RowIndex]["type_organisation_type_group_id"]) == 6))
            {
                int organisation_type_id = Convert.ToInt32(thisRow["organisation_type_id"]);
                int organisation_id      = Convert.ToInt32(thisRow["organisation_id"]);

                if (organisation_type_id == 367 || organisation_type_id == 372 || organisation_type_id == 139)
                {
                    lnkBookings.NavigateUrl    = String.Format("~/BookingsV2.aspx?orgs={0}", organisation_id);
                    lnkBookingList.NavigateUrl = String.Format("~/BookingsListV2.aspx?org={0}", organisation_id);
                }
                else if (organisation_type_id == 218)
                {
                    lnkBookings.NavigateUrl    = String.Format("~/BookingsV2.aspx?orgs={0}", organisation_id);
                    lnkBookingList.NavigateUrl = String.Format("~/BookingsListV2.aspx?org={0}", organisation_id);
                }
                else
                {
                    lnkBookings.Visible    = false;
                    lnkBookingList.Visible = false;
                }
            }

            ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
            if (btnDelete != null)
            {
                bool is_deleted = Convert.ToBoolean(thisRow["is_deleted"]);
                if (is_deleted)
                {
                    btnDelete.CommandName   = "_UnDelete";
                    btnDelete.ImageUrl      = "~/images/tick-24.png";
                    btnDelete.AlternateText = "UnDelete";
                    btnDelete.ToolTip       = "UnDelete";
                }
            }

            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DropDownList ddlParent = (DropDownList)e.Row.FindControl("ddlNewParent");
            if (ddlParent != null)
            {
                /*
                 * bool exclClinics      = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.Clinic;
                 * bool exclAgedCareFacs = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.AgedCare;
                 * bool exclExternal     = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.External;
                 * bool exclIns          = GetUrlParamType() != UrlParamType.None && GetUrlParamType() != UrlParamType.Insurance;
                 * DataTable parentList = OrganisationDB.GetDataTable(false, exclClinics, exclAgedCareFacs, exclIns, exclExternal);
                 * ddlParent.Items.Clear();
                 * ddlParent.Items.Add(new ListItem("--", "-1"));
                 * foreach (DataRow row in parentList.Rows)
                 *  ddlParent.Items.Add(new ListItem(row["name"].ToString(), row["organisation_id"].ToString()));
                 */

                ddlParent.Items.Clear();
                ddlParent.Items.Add(new ListItem("--", "0"));
                foreach (DataRow row in GetOrgsDaTatable(GetUrlParamType(), false).Rows)
                {
                    ddlParent.Items.Add(new ListItem(row["name"].ToString(), row["organisation_id"].ToString()));
                }
            }

            DropDownList ddlNewType = (DropDownList)e.Row.FindControl("ddlNewType");
            foreach (DataRow row in types.Rows)
            {
                string prefix = Convert.ToInt32(row["organisation_type_group_id"]) == 5 || Convert.ToInt32(row["organisation_type_group_id"]) == 6 || GetUrlParamType() == UrlParamType.External ? "" : "Ext. ";
                if (Convert.ToInt32(row["organisation_type_group_id"]) == 1)
                {
                    prefix = "";
                }
                ddlNewType.Items.Add(new ListItem(prefix + row["descr"].ToString(), row["organisation_type_id"].ToString()));
            }

            DropDownList ddlCustType = (DropDownList)e.Row.FindControl("ddlNewCustType");
            ddlCustType.DataSource     = custTypes;
            ddlCustType.DataTextField  = "descr";
            ddlCustType.DataValueField = "organisation_customer_type_id";
            ddlCustType.DataBind();

            DropDownList ddlServiceCycle = (DropDownList)e.Row.FindControl("ddlNewServiceCycle");
            for (int i = 0; i <= 52; i++)
            {
                ddlServiceCycle.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            DropDownList ddlFreeServices = (DropDownList)e.Row.FindControl("ddlNewFreeServices");
            for (int i = 0; i <= 5; i++)
            {
                ddlFreeServices.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
        }
    }
    protected void GrdOffering_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable offeringTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "OfferingType", "offering_type_id <> 90", "", "offering_type_id", "descr");
        DataTable fields        = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "has_offerings = 1", "descr", "field_id", "descr");
        DataTable offeringPatientSubcategories = DBBase.GetGenericDataTable(null, "AgedCarePatientType", "aged_care_patient_type_id", "descr");
        DataTable offeringInvoiceTypes         = DBBase.GetGenericDataTable(null, "OfferingInvoiceType", "offering_invoice_type_id", "descr");
        DataTable letters = LetterDB.GetDataTable_ByLetterType(391);

        int BookingScreenDefaultServiceID = Convert.ToInt32(SystemVariableDB.GetByDescr("BookingScreenDefaultServiceID").Value);

        // move 'None' item to the top
        for (int i = 0; i < fields.Rows.Count; i++)
        {
            if (fields.Rows[i]["descr"].ToString() != "None")
            {
                continue;
            }

            DataRow newRow = fields.NewRow();
            newRow.ItemArray = fields.Rows[i].ItemArray;
            fields.Rows.RemoveAt(i);
            fields.Rows.InsertAt(newRow, 0);
            break;
        }


        DataTable dt       = Session["offeringinfo_data"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("o_offering_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];


            int offering_id = Convert.ToInt32(thisRow["o_offering_id"]);


            TextBox txtName = (TextBox)e.Row.FindControl("txtName");
            if (txtName != null)
            {
                if (Session["DB"] != null && Session["DB"].ToString() == "Mediclinic_0040")
                {
                    txtName.MaxLength = 2000;
                    txtName.TextMode  = TextBoxMode.MultiLine;
                }
                else if (thisRow["o_name"].ToString().Contains(Environment.NewLine))
                {
                    txtName.TextMode = TextBoxMode.MultiLine;
                }
            }


            DropDownList ddlOfferingType = (DropDownList)e.Row.FindControl("ddlOfferingType");
            if (ddlOfferingType != null)
            {
                ddlOfferingType.DataSource     = offeringTypes;
                ddlOfferingType.DataTextField  = "descr";
                ddlOfferingType.DataValueField = "offering_type_id";
                ddlOfferingType.DataBind();
                ddlOfferingType.SelectedValue = thisRow["o_offering_type_id"].ToString();
            }

            DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlField");
            if (ddlField != null)
            {
                ddlField.DataSource     = fields;
                ddlField.DataTextField  = "descr";
                ddlField.DataValueField = "field_id";
                ddlField.DataBind();
                ddlField.SelectedValue = thisRow["o_field_id"].ToString();
            }

            DropDownList ddlOfferingPatientSubcategory = (DropDownList)e.Row.FindControl("ddlOfferingPatientSubcategory");
            if (ddlOfferingPatientSubcategory != null)
            {
                ddlOfferingPatientSubcategory.DataSource     = offeringPatientSubcategories;
                ddlOfferingPatientSubcategory.DataTextField  = "descr";
                ddlOfferingPatientSubcategory.DataValueField = "aged_care_patient_type_id";
                ddlOfferingPatientSubcategory.DataBind();
                ddlOfferingPatientSubcategory.SelectedValue = thisRow["o_aged_care_patient_type_id"].ToString();
            }

            DropDownList ddlOfferingInvoiceType = (DropDownList)e.Row.FindControl("ddlOfferingInvoiceType");
            if (ddlOfferingInvoiceType != null)
            {
                if (IsValidFormInvType())
                {
                    IDandDescr invType = GetFormInvType();
                    ddlOfferingInvoiceType.Items.Add(new ListItem(invType.Descr, invType.ID.ToString()));
                }
                else
                {
                    string v = thisRow["o_offering_invoice_type_id"].ToString();

                    ddlOfferingInvoiceType.DataSource     = offeringInvoiceTypes;
                    ddlOfferingInvoiceType.DataTextField  = "descr";
                    ddlOfferingInvoiceType.DataValueField = "offering_invoice_type_id";
                    ddlOfferingInvoiceType.DataBind();
                    ddlOfferingInvoiceType.SelectedValue = thisRow["o_offering_invoice_type_id"].ToString();
                }
            }

            DropDownList ddlServiceTimeMinutes = (DropDownList)e.Row.FindControl("ddlServiceTimeMinutes");
            if (ddlServiceTimeMinutes != null)
            {
                ddlServiceTimeMinutes.Items.AddRange(GetListOfTimes());
                int valueToSelect = Convert.ToInt32(dt.Rows[e.Row.RowIndex]["o_service_time_minutes"]);
                if (ddlServiceTimeMinutes.Items.FindByValue(valueToSelect.ToString()) != null)
                {
                    ddlServiceTimeMinutes.SelectedValue = valueToSelect.ToString();
                }
                else
                {
                    ddlServiceTimeMinutes.Items.Clear();
                    ddlServiceTimeMinutes.Items.AddRange(GetListOfTimes(valueToSelect));
                    ddlServiceTimeMinutes.SelectedValue = valueToSelect.ToString();
                }
            }

            DropDownList ddlNumClinicVisitsAllowedPerYear = (DropDownList)e.Row.FindControl("ddlNumClinicVisitsAllowedPerYear");
            if (ddlNumClinicVisitsAllowedPerYear != null)
            {
                for (int i = 0; i < 6; i++)
                {
                    ddlNumClinicVisitsAllowedPerYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                ddlNumClinicVisitsAllowedPerYear.SelectedValue = thisRow["o_num_clinic_visits_allowed_per_year"].ToString();
            }

            DropDownList ddlMaxNbrClaimable = (DropDownList)e.Row.FindControl("ddlMaxNbrClaimable");
            if (ddlMaxNbrClaimable != null)
            {
                for (int i = 0; i < 10; i++)
                {
                    ddlMaxNbrClaimable.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                ddlMaxNbrClaimable.SelectedValue = thisRow["o_max_nbr_claimable"].ToString();
            }

            DropDownList ddlMaxNbrClaimableMonths = (DropDownList)e.Row.FindControl("ddlMaxNbrClaimableMonths");
            if (ddlMaxNbrClaimableMonths != null)
            {
                for (int i = 0; i <= 24; i++)
                {
                    ddlMaxNbrClaimableMonths.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                ddlMaxNbrClaimableMonths.SelectedValue = thisRow["o_max_nbr_claimable_months"].ToString();
            }

            DropDownList ddlReminderLetterMonthsLaterToSend = (DropDownList)e.Row.FindControl("ddlReminderLetterMonthsLaterToSend");
            if (ddlReminderLetterMonthsLaterToSend != null)
            {
                for (int i = 0; i <= 24; i++)
                {
                    ddlReminderLetterMonthsLaterToSend.Items.Add(new ListItem((i == 0 ? "Disabled" : i.ToString()), i.ToString()));
                }
                ddlReminderLetterMonthsLaterToSend.SelectedValue = thisRow["o_reminder_letter_months_later_to_send"].ToString();
            }

            DropDownList ddlReminderLetter = (DropDownList)e.Row.FindControl("ddlReminderLetter");
            if (ddlReminderLetter != null)
            {
                ddlReminderLetter.Items.Add(new ListItem("--", "-1"));
                for (int i = 0; i < letters.Rows.Count; i++)
                {
                    ddlReminderLetter.Items.Add(new ListItem(letters.Rows[i]["letter_docname"].ToString(), letters.Rows[i]["letter_letter_id"].ToString()));
                }
                if (thisRow["o_reminder_letter_id"] != DBNull.Value)
                {
                    ddlReminderLetter.SelectedValue = thisRow["o_reminder_letter_id"].ToString();
                }
            }

            Label lblReminderLetter = (Label)e.Row.FindControl("lblReminderLetter");
            if (lblReminderLetter != null)
            {
                if (thisRow["o_reminder_letter_id"] == DBNull.Value)
                {
                    lblReminderLetter.Text = string.Empty;
                }

                else
                {
                    for (int i = 0; i < letters.Rows.Count; i++)
                    {
                        if (Convert.ToInt32(letters.Rows[i]["letter_letter_id"]) == Convert.ToInt32(thisRow["o_reminder_letter_id"]))
                        {
                            lblReminderLetter.Text = letters.Rows[i]["letter_docname"].ToString();
                            break;
                        }
                    }
                }
            }



            ImageButton lnkPopupMessage = (ImageButton)e.Row.FindControl("lnkPopupMessage");
            if (lnkPopupMessage != null)
            {
                string allFeatures = "dialogWidth:550px;dialogHeight:400px;center:yes;resizable:no; scroll:no";
                string js          = "javascript:window.showModalDialog('OfferingPopupMessageDetailV2.aspx?type=edit&id=" + offering_id.ToString() + "', '', '" + allFeatures + "');return false;";

                lnkPopupMessage.Visible     = true;
                lnkPopupMessage.PostBackUrl = "  ";
                lnkPopupMessage.Attributes.Add("onclick", js);
            }


            ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
            if (btnDelete != null)
            {
                bool is_deleted = Convert.ToBoolean(thisRow["o_is_deleted"]);
                if (is_deleted)
                {
                    btnDelete.CommandName   = "_UnDelete";
                    btnDelete.ImageUrl      = "~/images/tick-24.png";
                    btnDelete.AlternateText = "UnDelete";
                    btnDelete.ToolTip       = "UnDelete";
                }
            }


            LinkButton lnkUpdate = (LinkButton)e.Row.FindControl("lnkUpdate");
            if (lnkUpdate != null)
            {
                TextBox txtMedicareCharge = (TextBox)e.Row.FindControl("txtMedicareCharge");
                TextBox txtDvaCharge      = (TextBox)e.Row.FindControl("txtDvaCharge");
                TextBox txtTacCharge      = (TextBox)e.Row.FindControl("txtTacCharge");

                lnkUpdate.OnClientClick = "set_if_empty_price(document.getElementById('" + txtMedicareCharge.ClientID + "'),document.getElementById('" + txtDvaCharge.ClientID + "'),document.getElementById('" + txtTacCharge.ClientID + "'));";
            }

            Image imgBookingScreenDefaultService = (Image)e.Row.FindControl("imgBookingScreenDefaultService");
            imgBookingScreenDefaultService.Visible = offering_id == BookingScreenDefaultServiceID;

            LinkButton btnSetAsBookingScreenDefaultService = (LinkButton)e.Row.FindControl("btnSetAsBookingScreenDefaultService");
            btnSetAsBookingScreenDefaultService.Visible = offering_id != BookingScreenDefaultServiceID;


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DropDownList ddlOfferingType = (DropDownList)e.Row.FindControl("ddlNewOfferingType");
            ddlOfferingType.DataSource = offeringTypes;
            ddlOfferingType.DataBind();

            DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlNewField");
            ddlField.DataSource = fields;
            ddlField.DataBind();

            DropDownList ddlOfferingPatientSubcategory = (DropDownList)e.Row.FindControl("ddlNewOfferingPatientSubcategory");
            ddlOfferingPatientSubcategory.DataSource = offeringPatientSubcategories;
            ddlOfferingPatientSubcategory.DataBind();

            bool isAgedCareResidentTypes = IsValidIsAgedCareResidentTypes() ? GetFormIsAgedCareResidentTypes() : false;
            if (isAgedCareResidentTypes)
            {
                ddlOfferingPatientSubcategory.Items.RemoveAt(0);
            }

            DropDownList ddlOfferingInvoiceType = (DropDownList)e.Row.FindControl("ddlNewOfferingInvoiceType");
            if (IsValidFormInvType())
            {
                IDandDescr invType = GetFormInvType();
                ddlOfferingInvoiceType.Items.Add(new ListItem(invType.Descr, invType.ID.ToString()));
            }
            else
            {
                //ddlOfferingInvoiceType.DataSource = offeringInvoiceTypes;
                //ddlOfferingInvoiceType.DataBind();
                foreach (DataRow row in offeringInvoiceTypes.Rows)
                {
                    if (row["offering_invoice_type_id"].ToString() != "0")
                    {
                        ddlOfferingInvoiceType.Items.Add(new ListItem(row["descr"].ToString(), row["offering_invoice_type_id"].ToString()));
                    }
                }

                ddlOfferingInvoiceType.SelectedValue = UserView.GetInstance().IsClinicView ? "1" : "4"; // 1 = clinics, 4 = aged care
            }

            DropDownList ddlServiceTimeMinutes = (DropDownList)e.Row.FindControl("ddlNewServiceTimeMinutes");
            for (int i = 0; i < 20; i++)
            {
                ddlServiceTimeMinutes.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            for (int i = 20; i <= 90; i++)
            {
                if (i % 5 == 0)
                {
                    ddlServiceTimeMinutes.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
            }
            for (int i = 91; i <= 480; i++)
            {
                if (i % 30 == 0)
                {
                    ddlServiceTimeMinutes.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
            }


            DropDownList ddlNumClinicVisitsAllowedPerYear = (DropDownList)e.Row.FindControl("ddlNewNumClinicVisitsAllowedPerYear");
            if (ddlNumClinicVisitsAllowedPerYear != null)
            {
                for (int i = 0; i < 6; i++)
                {
                    ddlNumClinicVisitsAllowedPerYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
            }

            DropDownList ddlMaxNbrClaimable = (DropDownList)e.Row.FindControl("ddlNewMaxNbrClaimable");
            for (int i = 0; i < 10; i++)
            {
                ddlMaxNbrClaimable.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            DropDownList ddlMaxNbrClaimableMonths = (DropDownList)e.Row.FindControl("ddlNewMaxNbrClaimableMonths");
            for (int i = 0; i <= 24; i++)
            {
                ddlMaxNbrClaimableMonths.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            DropDownList ddlReminderLetterMonthsLaterToSend = (DropDownList)e.Row.FindControl("ddlNewReminderLetterMonthsLaterToSend");
            for (int i = 0; i <= 24; i++)
            {
                ddlReminderLetterMonthsLaterToSend.Items.Add(new ListItem((i == 0 ? "Disabled" : i.ToString()), i.ToString()));
            }

            DropDownList ddlReminderLetter = (DropDownList)e.Row.FindControl("ddlNewReminderLetter");
            ddlReminderLetter.Items.Add(new ListItem("--", "-1"));
            for (int i = 0; i < letters.Rows.Count; i++)
            {
                ddlReminderLetter.Items.Add(new ListItem(letters.Rows[i]["letter_docname"].ToString(), letters.Rows[i]["letter_letter_id"].ToString()));
            }


            LinkButton lnkAdd            = (LinkButton)e.Row.FindControl("lnkAdd");
            TextBox    txtMedicareCharge = (TextBox)e.Row.FindControl("txtNewMedicareCharge");
            TextBox    txtDvaCharge      = (TextBox)e.Row.FindControl("txtNewDvaCharge");
            TextBox    txtTacCharge      = (TextBox)e.Row.FindControl("txtNewTacCharge");
            lnkAdd.OnClientClick = "set_if_empty_price(document.getElementById('" + txtMedicareCharge.ClientID + "'),document.getElementById('" + txtDvaCharge.ClientID + "'),document.getElementById('" + txtTacCharge.ClientID + "'));";
        }
    }
Exemplo n.º 13
0
    protected void SetupGUI()
    {
        chkIncMedicare.Checked   = IsValidFormIncMedicare()   ? GetFormIncMedicare(false)   : false;
        chkIncDVA.Checked        = IsValidFormIncDVA()        ? GetFormIncDVA(false)        : false;
        chkIncPrivate.Checked    = IsValidFormIncPrivate()    ? GetFormIncPrivate(false)    : true;
        chkIncReconciled.Checked = IsValidFormIncReconciled() ? GetFormIncReconciled(false) : true;


        UserView userView = UserView.GetInstance();

        ddlOrgs.Style["width"] = "300px";
        ddlOrgs.Items.Clear();
        ddlOrgs.Items.Add(new ListItem("All " + (userView.IsAgedCareView ? "Facilities" : "Clinics"), (-1).ToString()));
        foreach (Organisation curOrg in OrganisationDB.GetAll(false, true, !userView.IsClinicView && !userView.IsGPView, !userView.IsAgedCareView, true, true))
        {
            ddlOrgs.Items.Add(new ListItem(curOrg.Name, curOrg.OrganisationID.ToString()));
        }

        ddlProviders.Style["width"] = "300px";
        ddlProviders.Items.Clear();
        ddlProviders.Items.Add(new ListItem("All Staff", (-1).ToString()));
        foreach (Staff curProv in StaffDB.GetAll())
        {
            ddlProviders.Items.Add(new ListItem(curProv.Person.FullnameWithoutMiddlename, curProv.StaffID.ToString()));
        }

        if (IsValidFormOrgID())
        {
            Organisation org = OrganisationDB.GetByID(GetFormOrgID());
            if (org != null)
            {
                ddlOrgs.SelectedValue = org.OrganisationID.ToString();
            }
        }

        if (!UserView.GetInstance().IsAdminView)
        {
            providerRow.Visible = false;

            Staff provider = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"]));
            if (provider != null)
            {
                ddlProviders.SelectedValue = provider.StaffID.ToString();
            }
        }
        else
        {
            if (IsValidFormProviderID())
            {
                Staff provider = StaffDB.GetByID(GetFormProviderID());
                if (provider != null)
                {
                    ddlProviders.SelectedValue = provider.StaffID.ToString();
                }
            }
        }

        ddlReceiptPaymentType.Style["width"] = "300px";
        DataTable paymentTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "ReceiptPaymentType", "", "descr", "receipt_payment_type_id,descr");

        ddlReceiptPaymentType.Items.Add(new ListItem("All Payment Types", "-1"));
        for (int i = 0; i < paymentTypes.Rows.Count; i++)
        {
            ddlReceiptPaymentType.Items.Add(new ListItem(paymentTypes.Rows[i]["descr"].ToString(), paymentTypes.Rows[i]["receipt_payment_type_id"].ToString()));
        }

        if (IsValidFormPaymentType())
        {
            ddlReceiptPaymentType.SelectedValue = GetFormPaymentType(false).ToString();
        }


        txtStartDate.Text = IsValidFormStartDate() ? (GetFormStartDate(false) == DateTime.MinValue ? "" : GetFormStartDate(false).ToString("dd-MM-yyyy")) : DateTime.Today.ToString("dd-MM-yyyy");
        txtEndDate.Text   = IsValidFormEndDate()   ? (GetFormEndDate(false) == DateTime.MinValue ? "" : GetFormEndDate(false).ToString("dd-MM-yyyy"))   : DateTime.Today.ToString("dd-MM-yyyy");

        txtStartDate_Picker.OnClientClick = "displayDatePicker('txtStartDate', this, 'dmy', '-'); return false;";
        txtEndDate_Picker.OnClientClick   = "displayDatePicker('txtEndDate',   this, 'dmy', '-'); return false;";
    }
Exemplo n.º 14
0
    protected void GrdStaff_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId         = (Label)GrdStaff.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlTitle      = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlTitle");
        TextBox      txtFirstname  = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtFirstname");
        TextBox      txtMiddlename = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtMiddlename");
        TextBox      txtSurname    = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtSurname");
        DropDownList ddlGender     = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlGender");
        DropDownList ddlDOB_Day    = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlDOB_Day");
        DropDownList ddlDOB_Month  = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlDOB_Month");
        DropDownList ddlDOB_Year   = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlDOB_Year");

        TextBox txtLogin = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtLogin");
        TextBox txtPwd   = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtPwd");
        //DropDownList ddlStaffPosition     = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlStaffPosition");
        DropDownList ddlField             = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlField");
        CheckBox     chkContractor        = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkContractor");
        TextBox      txtTFN               = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtTFN");
        DropDownList ddlStatus            = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlStatus");
        DropDownList ddlCostCentre        = (DropDownList)GrdStaff.Rows[e.RowIndex].FindControl("ddlCostCentre");
        TextBox      txtProviderNumber    = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtProviderNumber");
        CheckBox     chkIsCommission      = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkIsCommission");
        TextBox      txtCommissionPercent = (TextBox)GrdStaff.Rows[e.RowIndex].FindControl("txtCommissionPercent");
        CheckBox     chkIsStakeholder     = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkIsStakeholder");
        CheckBox     chkIsAdmin           = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkIsAdmin");
        CheckBox     chkIsMasterAdmin     = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkIsMasterAdmin");
        CheckBox     chkIsPrincipal       = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkIsPrincipal");
        CheckBox     chkIsProvider        = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkIsProvider");
        CheckBox     chkSMSBKs            = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkSMSBKs");
        CheckBox     chkEmailBKs          = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkEmailBKs");
        CheckBox     chkHideBKNotes       = (CheckBox)GrdStaff.Rows[e.RowIndex].FindControl("chkHideBKNotes");



        int staff_id  = Convert.ToInt32(lblId.Text);
        int person_id = GetPersonID(Convert.ToInt32(lblId.Text));

        if (person_id == -1) // happens when back button hit after update .. with option to update again ... but no selected row exists within page data
        {
            GrdStaff.EditIndex = -1;
            FillGrid();
            return;
        }


        Staff staff = StaffDB.GetByID(staff_id);

        if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && staff.Login != txtLogin.Text && UserDatabaseMapperDB.UsernameExists(txtLogin.Text))
        {
            SetErrorMessage("Login name already in use by another user");
            return;
        }
        if (staff.Login != txtLogin.Text && StaffDB.LoginExists(txtLogin.Text, staff_id))
        {
            SetErrorMessage("Login name already in use by another user");
            return;
        }
        if (staff.Pwd != txtPwd.Text && txtPwd.Text.Length < 6)
        {
            SetErrorMessage(staff.Pwd.Length >= 6 ? "Password must be at least 6 characters" : "New passwords must be at least 6 characters");
            return;
        }

        DataTable dt = Session["staffinfo_data"] as DataTable;

        DataRow[] foundRows = dt.Select("person_id=" + person_id.ToString());
        DataRow   row       = foundRows[0]; // Convert.ToInt32(row["person_id"])



        if (!Convert.ToBoolean(row["is_provider"]) && chkIsProvider.Checked && (StaffDB.GetCountOfProviders() >= Convert.ToInt32(SystemVariableDB.GetByDescr("MaxNbrProviders").Value)))
        {
            SetErrorMessage("You have reached your maximum allowable providers. Please uncheck their status as a provider to update them or hit cancel. Contact Mediclinic if you would like to upgrade your account.");
            return;
        }


        if (chkIsProvider.Checked)
        {
            System.Data.DataTable tbl = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "has_offerings=1 AND field_id <> 0", "", "field_id", "descr");

            bool         roleSetAsProvider = false;
            IDandDescr[] fields            = new IDandDescr[tbl.Rows.Count];
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                fields[i] = new IDandDescr(Convert.ToInt32(tbl.Rows[i]["field_id"]), tbl.Rows[i]["descr"].ToString());
                if (Convert.ToInt32(ddlField.SelectedValue) == Convert.ToInt32(tbl.Rows[i]["field_id"]))
                {
                    roleSetAsProvider = true;
                }
            }

            if (!roleSetAsProvider)
            {
                if (fields.Length == 1)
                {
                    SetErrorMessage("When setting a staff member as a provider, you need to set their Role as '" + fields[0].Descr + "'.");
                    return;
                }
                else if (fields.Length == 2)
                {
                    SetErrorMessage("When setting a staff member as a provider, you need to set their Role as '" + fields[0].Descr + "' or '" + fields[1].Descr + "'.");
                    return;
                }
                else
                {
                    string providerFields = string.Empty;
                    for (int i = 0; i < fields.Length; i++)
                    {
                        providerFields += (providerFields.Length == 0 ? "" : ", ") + (fields.Length >= 2 && i == (fields.Length - 2) ? "or " : "") + fields[i].Descr;
                    }

                    SetErrorMessage("When setting a staff member as a provider, you need to set their Role as one of the following: " + providerFields);
                    return;
                }
            }
        }



        if (chkIsMasterAdmin.Checked)
        {
            chkIsAdmin.Checked = true;
        }

        PersonDB.Update(person_id, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), row["nickname"].ToString(), ddlGender.SelectedValue, GetDate(ddlDOB_Day.SelectedValue, ddlDOB_Month.SelectedValue, ddlDOB_Year.SelectedValue), DateTime.Now);
        StaffDB.Update(staff_id, person_id, txtLogin.Text, txtPwd.Text, Convert.ToInt32(row["staff_position_id"]), Convert.ToInt32(ddlField.SelectedValue), Convert.ToInt32(ddlCostCentre.SelectedValue),
                       chkContractor.Checked, txtTFN.Text, txtProviderNumber.Text.ToUpper(),
                       ddlStatus.SelectedValue == "Inactive", chkIsCommission.Checked, Convert.ToDecimal(txtCommissionPercent.Text),
                       chkIsStakeholder.Checked, chkIsMasterAdmin.Checked, chkIsAdmin.Checked, chkIsPrincipal.Checked, chkIsProvider.Checked, staff.IsExternal,
                       row["start_date"] == DBNull.Value ? DateTime.MinValue : (DateTime)row["start_date"], row["end_date"] == DBNull.Value ? DateTime.MinValue : (DateTime)row["end_date"], row["comment"].ToString(), chkSMSBKs.Checked, chkEmailBKs.Checked, chkHideBKNotes.Checked);

        if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && staff.Login != txtLogin.Text)
        {
            UserDatabaseMapper curDBMapper = UserDatabaseMapperDB.GetByLogin(staff.Login, Session["DB"].ToString());
            if (curDBMapper == null)
            {
                UserDatabaseMapperDB.Insert(txtLogin.Text, Session["DB"].ToString());
            }
            else
            {
                UserDatabaseMapperDB.Update(curDBMapper.ID, txtLogin.Text, Session["DB"].ToString());
            }
        }


        GrdStaff.EditIndex = -1;
        FillGrid();
    }
    protected void GrdStaff_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable fields      = DBBase.GetGenericDataTable(null, "Field", "field_id", "descr");
        DataTable costcentres = CostCentreDB.GetDataTable();
        DataTable positions   = StaffPositionDB.GetDataTable();
        DataTable dt          = Session["externalstaffinfo_data"] as DataTable;
        bool      tblEmpty    = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("staff_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];


            DropDownList ddlTitle = (DropDownList)e.Row.FindControl("ddlTitle");
            if (ddlTitle != null)
            {
                DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", Convert.ToInt32(thisRow["title_id"]) == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
                ddlTitle.DataSource     = titles;
                ddlTitle.DataTextField  = "descr";
                ddlTitle.DataValueField = "title_id";
                ddlTitle.DataBind();
                ddlTitle.SelectedValue = thisRow["title_id"].ToString();
            }
            DropDownList ddlGender = (DropDownList)e.Row.FindControl("ddlGender");
            if (ddlGender != null)
            {
                if (thisRow["gender"].ToString() != "")
                {
                    for (int i = ddlGender.Items.Count - 1; i >= 0; i--)
                    {
                        if (ddlGender.Items[i].Value == "")
                        {
                            ddlGender.Items.RemoveAt(i);
                        }
                    }
                }
            }

            if (ddlTitle != null && ddlGender != null)
            {
                ddlTitle.Attributes["onchange"] = "title_changed_reset_gender('" + ddlTitle.ClientID + "','" + ddlGender.ClientID + "');";
            }


            DropDownList ddlDOB_Day   = (DropDownList)e.Row.FindControl("ddlDOB_Day");
            DropDownList ddlDOB_Month = (DropDownList)e.Row.FindControl("ddlDOB_Month");
            DropDownList ddlDOB_Year  = (DropDownList)e.Row.FindControl("ddlDOB_Year");
            if (ddlDOB_Day != null && ddlDOB_Month != null && ddlDOB_Year != null)
            {
                ddlDOB_Day.Items.Add(new ListItem("--", "-1"));
                ddlDOB_Month.Items.Add(new ListItem("--", "-1"));
                ddlDOB_Year.Items.Add(new ListItem("----", "-1"));

                for (int i = 1; i <= 31; i++)
                {
                    ddlDOB_Day.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                for (int i = 1; i <= 12; i++)
                {
                    ddlDOB_Month.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                for (int i = 1915; i <= DateTime.Today.Year; i++)
                {
                    ddlDOB_Year.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }

                if (thisRow["dob"] != DBNull.Value)
                {
                    DateTime dob = Convert.ToDateTime(thisRow["dob"]);

                    ddlDOB_Day.SelectedValue   = dob.Day.ToString();
                    ddlDOB_Month.SelectedValue = dob.Month.ToString();

                    int firstYearSelectable = Convert.ToInt32(ddlDOB_Year.Items[1].Value);
                    int lastYearSelectable  = Convert.ToInt32(ddlDOB_Year.Items[ddlDOB_Year.Items.Count - 1].Value);
                    if (dob.Year < firstYearSelectable)
                    {
                        ddlDOB_Year.Items.Insert(1, new ListItem(dob.Year.ToString(), dob.Year.ToString()));
                    }
                    if (dob.Year > lastYearSelectable)
                    {
                        ddlDOB_Year.Items.Add(new ListItem(dob.Year.ToString(), dob.Year.ToString()));
                    }

                    ddlDOB_Year.SelectedValue = dob.Year.ToString();
                }
            }

            TextBox txtPwd = (TextBox)e.Row.FindControl("txtPwd");
            if (txtPwd != null)
            {
                txtPwd.Attributes["value"] = thisRow["pwd"].ToString();
            }

            DropDownList ddlPosition = (DropDownList)e.Row.FindControl("ddlStaffPosition");
            if (ddlPosition != null)
            {
                ddlPosition.DataSource     = positions;
                ddlPosition.DataTextField  = "descr";
                ddlPosition.DataValueField = "staff_position_id";
                ddlPosition.DataBind();
                ddlPosition.SelectedValue = thisRow["staff_position_id"].ToString();
            }
            DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlField");
            if (ddlField != null)
            {
                ddlField.DataSource     = fields;
                ddlField.DataTextField  = "descr";
                ddlField.DataValueField = "field_id";
                ddlField.DataBind();
                ddlField.SelectedValue = thisRow["field_id"].ToString();
            }
            DropDownList ddlCostCentre = (DropDownList)e.Row.FindControl("ddlCostCentre");
            if (ddlCostCentre != null)
            {
                ddlCostCentre.DataSource     = costcentres;
                ddlCostCentre.DataTextField  = "descr";
                ddlCostCentre.DataValueField = "costcentre_id";
                ddlCostCentre.DataBind();
                ddlCostCentre.SelectedValue = thisRow["costcentre_id"].ToString();
            }

            bool is_fired = Convert.ToBoolean(thisRow["is_fired"]);

            DropDownList ddlStatus = (DropDownList)e.Row.FindControl("ddlStatus");
            if (ddlStatus != null)
            {
                if (is_fired)
                {
                    ddlStatus.SelectedValue = "Inactive";
                }
                else
                {
                    ddlStatus.SelectedValue = "Active";
                }
            }
            Label lblIsFired = (Label)e.Row.FindControl("lblIsFired");
            if (is_fired)
            {
                e.Row.ForeColor = System.Drawing.Color.Gray;
                if (lblIsFired != null)
                {
                    lblIsFired.ForeColor = System.Drawing.Color.Red;
                }
            }

            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DataTable    titles   = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr");
            DropDownList ddlTitle = (DropDownList)e.Row.FindControl("ddlNewTitle");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();
            ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "mr", "mr.");
        }
    }
Exemplo n.º 16
0
    protected void SetupAddressGUI()
    {
        string allFeaturesType = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no";
        string jsType          = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType + "');document.getElementById('btnUpdateAddressType').click();return false;";

        string allFeatures = "dialogWidth:1100px;dialogHeight:600px;center:yes;resizable:no; scroll:no";
        string js          = "javascript:window.showModalDialog('" + "StreetAndSuburbInfo.aspx', '', '" + allFeatures + "');document.getElementById('btnUpdateAddressStreetAndSuburb').click();return false;";

        lnkAddressUpdateType.NavigateUrl = "  ";
        lnkAddressUpdateType.Text        = "Add/Edit";
        lnkAddressUpdateType.Attributes.Add("onclick", jsType);

        lnkAddressUpdateChannel.NavigateUrl = "  ";
        lnkAddressUpdateChannel.Text        = "Add/Edit";
        lnkAddressUpdateChannel.Attributes.Add("onclick", js);

        string allFeaturesType2 = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no";
        string jsType2          = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType2 + "');document.getElementById('btnUpdatePhoneType').click();return false;";

        string allFeaturesType3 = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no";
        string jsType3          = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType3 + "');document.getElementById('btnUpdateEmailType').click();return false;";

        lnkEmailUpdateType.NavigateUrl = "  ";
        lnkEmailUpdateType.Text        = "Add/Edit";
        lnkEmailUpdateType.Attributes.Add("onclick", jsType3);


        ddlAddressContactType.DataSource = ContactTypeDB.GetDataTable(1);
        ddlAddressContactType.DataBind();
        ddlAddressContactType.SelectedValue = "36"; // set default as business address

        DataTable dt_PhoneNumbers = ContactTypeDB.GetDataTable(2);

        ddlPhoneNumber1.DataSource = dt_PhoneNumbers.Copy();
        ddlPhoneNumber2.DataSource = dt_PhoneNumbers.Copy();
        ddlPhoneNumber1.DataBind();
        ddlPhoneNumber2.DataBind();
        ddlPhoneNumber1.SelectedValue   = "30"; // mobile
        ddlPhoneNumber2.SelectedValue   = "34"; // office
        lnkPhone1UpdateType.NavigateUrl = "  ";
        lnkPhone1UpdateType.Text        = "Add/Edit";
        lnkPhone1UpdateType.Attributes.Add("onclick", jsType2);
        lnkPhone2UpdateType.NavigateUrl = "  ";
        lnkPhone2UpdateType.Text        = "Add/Edit";
        lnkPhone2UpdateType.Attributes.Add("onclick", jsType2);


        DataTable emailWeb = ContactTypeDB.GetDataTable(4);
        DataView  dv       = emailWeb.DefaultView;

        dv.RowFilter = string.Format("at_contact_type_id={0}", 27);
        DataTable emailOnly = dv.ToTable();

        ddlEmailContactType.DataSource = emailOnly;

        //ddlEmailContactType.DataSource = ContactTypeDB.GetDataTable(4);
        ddlEmailContactType.DataBind();

        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            // newOrgAddressRow5.Visible = true;
            DataTable addrChannels = AddressChannelDB.GetDataTable();
            ddlAddressAddressChannel.Items.Add(new ListItem("--", "-1"));
            foreach (DataRow row in addrChannels.Rows)
            {
                ddlAddressAddressChannel.Items.Add(new ListItem(row["ac_descr"] + " " + row["act_descr"], row["ac_address_channel_id"].ToString()));
            }
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            //newOrgAddressRow6.Visible = true;
            DataTable addrChannelTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "AddressChannelType", "", "descr", "address_channel_type_id", "descr");
            ddlAddressAddressChannelType.Items.Add(new ListItem("--", "-1"));
            foreach (DataRow row in addrChannelTypes.Rows)
            {
                ddlAddressAddressChannelType.Items.Add(new ListItem(row["descr"].ToString(), row["address_channel_type_id"].ToString()));
            }
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        DataTable countries = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Country", "", "descr", "country_id", "descr");

        ddlAddressCountry.Items.Add(new ListItem("--", "-1"));
        foreach (DataRow row in countries.Rows)
        {
            ddlAddressCountry.Items.Add(new ListItem(row["descr"].ToString(), row["country_id"].ToString()));
        }
        ddlAddressCountry.SelectedIndex = Utilities.IndexOf(ddlAddressCountry, "australia");


        bool editable = true;

        Utilities.SetEditControlBackColour(ddlAddressContactType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtAddressAddrLine1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtAddressAddrLine2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlAddressAddressChannel, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtStreet, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlAddressAddressChannelType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlAddressCountry, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtAddressFreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);

        Utilities.SetEditControlBackColour(ddlPhoneNumber1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlPhoneNumber2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtPhoneNumber1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtPhoneNumber2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtPhoneNumber1FreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtPhoneNumber2FreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);

        Utilities.SetEditControlBackColour(ddlEmailContactType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtEmailAddrLine1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
    }
    protected void SetInvoiceInfo(Invoice invoice)
    {
        bool isDebug          = Request["debug"] != null && Request["debug"] == "1";
        bool useOnlyTestItems = false;

        SaveType saveType = Request.QueryString["reftag"] != null ? SaveType.Cancellation : SaveType.Claim;

        string receiptString = string.Empty;

        foreach (Receipt receipt in ReceiptDB.GetByInvoice(invoice.InvoiceID, false))
        {
            receiptString += (receiptString.Length == 0 ? "" : ", ") + "$" + receipt.Total.ToString();
        }

        string invoiceViewURL = "/Invoice_ViewV2.aspx?invoice_id=" + invoice.InvoiceID;

        lblInvoiceID.Text      = "<a href=\"" + invoiceViewURL + "\" onclick=\"open_new_tab('" + invoiceViewURL + "');return false;\">" + invoice.InvoiceID + "</a>";
        lblInvoiceTotal.Text   = "$" + invoice.Total.ToString();
        lblInvoiceOwing.Text   = "$" + invoice.TotalDue.ToString();
        lblReceiptedTotal.Text = "$" + invoice.ReceiptsTotal.ToString() + (invoice.CreditNotesTotal == 0 ? "" : " &nbsp;&nbsp;($" + invoice.CreditNotesTotal.ToString() + " Credit Noted)") + (invoice.RefundsTotal == 0 ? "" : " &nbsp;&nbsp;($" + invoice.RefundsTotal.ToString() + " Refunds)");
        lblDebtor.Text         = invoice.GetDebtor(true);
        lblBkDate.Text         = invoice.Booking.DateStart.ToString("d MMM, yyyy");
        lblBkOrgText.Text      = invoice.Booking.Organisation.IsAgedCare? "Facility" : "Clinic";
        lblBkOrg.Text          = invoice.Booking.Organisation.Name;

        System.Data.DataTable tbl = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id=" + invoice.Booking.Provider.Field.ID, "", "field_id", "descr");
        invoice.Booking.Provider.Field = IDandDescrDB.Load(tbl.Rows[0], "field_id", "descr");

        RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(invoice.Booking.Provider.StaffID, invoice.Booking.Organisation.OrganisationID);

        if (regStaff == null)
        {
            throw new CustomMessageException("Staff Member Not Set To This Clinic/Fac.");
        }

        InvoiceLine[] invLines = InvoiceLineDB.GetByInvoiceID(invoice.InvoiceID);
        Hashtable     patientHealthCardCache = PatientsHealthCardsCacheDB.GetBullkActive(invLines.Select(x => x.Patient.PatientID).ToArray());

        List <TyroHealthPointClaimIten> claimItems = new List <TyroHealthPointClaimIten>();

        for (int i = 0; i < invLines.Length; i++)
        {
            HealthCard hc = GetHealthCardFromCache(patientHealthCardCache, invLines[i].Patient.PatientID);

            string ptURL  = "PatientDetailV2.aspx?type=view&id=" + invLines[i].Patient.PatientID;
            string ptLink = "<a href=\"" + ptURL + "\" onclick=\"open_new_tab('" + ptURL + "');return false;\">" + invLines[i].Patient.Person.FullnameWithoutMiddlename + "</a>";

            if (hc == null)
            {
                throw new CustomMessageException("No healthcard found for " + ptLink + " (PT-ID:" + invLines[i].Patient.PatientID + ")");
            }
            if (hc.Organisation.OrganisationType.OrganisationTypeID != 150)
            {
                throw new CustomMessageException("Healthcard found for " + ptLink + " (PT-ID:" + invLines[i].Patient.PatientID + ") Is Not An Insurance Card");
            }

            /*
             * claim-amount:      claim amount in cents                    - max 10 digits
             * service-code:      item number service code                 - max 5  characters
             * description:       description of item to appear on receipt - max 32 characters
             * service-reference: body part or tooth number suffix         - max 3  characters
             * patient-id:        patient ID on card                       - exactly 2 digits
             * service-date:      claim date in YYYYMMDD format
             */

            isDebug = true;

            claimItems.Add(new TyroHealthPointClaimIten(
                               ((int)(invLines[i].Price * 100)).ToString(),
                               isDebug ? "F1234" : invLines[i].Offering.TacCompanyCode,
                               isDebug ? "Face"  : invLines[i].AreaTreated,
                               invLines[i].ServiceReference,
                               "",      // family number on card -- legally they have to enter it themselves
                               isDebug ? DateTime.Today.ToString("yyyyMMdd") : invoice.Booking.DateStart.ToString("yyyyMMdd")));
        }


        //useOnlyTestItems = true;

        // save variables & JSON array on the page accessable to JS to send to Tyro
        if (useOnlyTestItems)
        {
            claimItems = new List <TyroHealthPointClaimIten>();

            claimItems.Add(new TyroHealthPointClaimIten(
                               "10000",
                               "00001",
                               "SKULL XRAY",
                               "01",
                               "02",
                               DateTime.Today.ToString("yyyyMMdd")));

            claimItems.Add(new TyroHealthPointClaimIten(
                               "15000",
                               "00001",
                               "SKULL XRAY",
                               "01",
                               "02",
                               DateTime.Today.ToString("yyyyMMdd")));

            Page.ClientScript.RegisterStartupScript(this.GetType(), "invoice_items",
                                                    @"<script language=javascript>
                var _providerId       = '4237955J';
                var _serviceType      = 'D';
                var _claimItemsCount  = '2';
                var _totalClaimAmount = '25000';
                var _allClaimItems    = " + new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(claimItems) + @"; 
             </script>");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "invoice_items",
                                                    @"<script language=javascript>
                    var _providerId       = '" + (isDebug ? "4237955J" : (regStaff.ProviderNumber.Length > 0 ? regStaff.ProviderNumber : invoice.Booking.Provider.ProviderNumber)) + @"';
                    var _serviceType      = '" + GetServiceTypeHashtable()[invoice.Booking.Provider.Field.Descr.ToLower()].ToString() + @"';
                    var _claimItemsCount  = '" + invLines.Length.ToString() + @"';
                    var _totalClaimAmount = '" + ((int)(invLines.Sum(item => item.Price) * 100)).ToString() + @"';
                    var _allClaimItems    = " + new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(claimItems) /* convert to JSON array */ + @"; 
                    " + (saveType == SaveType.Cancellation ? "var _refTag = " + Request.QueryString["reftag"] : string.Empty) + @"
                 </script>");
        }
    }
Exemplo n.º 18
0
    protected void GrdLetter_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable letterTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "LetterType", "", "descr", "letter_type_id", "descr");
        DataTable sites       = SiteDB.GetDataTable();


        DataTable dt = Session["letter_data"] as DataTable;

        bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            bool      hasData   = dt.Rows[0][0].ToString() != string.Empty;
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("letter_letter_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];
            Letter    letter    = LetterDB.LoadAll(thisRow);

            DropDownList ddlLetterType = (DropDownList)e.Row.FindControl("ddlLetterType");
            if (ddlLetterType != null)
            {
                ddlLetterType.DataSource     = letterTypes;
                ddlLetterType.DataTextField  = "descr";
                ddlLetterType.DataValueField = "letter_type_id";
                ddlLetterType.DataBind();
                ddlLetterType.SelectedValue = thisRow["letter_letter_type_id"].ToString();
            }

            DropDownList ddlSite = (DropDownList)e.Row.FindControl("ddlSite");
            if (ddlSite != null)
            {
                ddlSite.DataSource     = sites;
                ddlSite.DataTextField  = "name";
                ddlSite.DataValueField = "site_id";
                ddlSite.DataBind();
                ddlSite.SelectedValue = thisRow["letter_site_id"].ToString();
            }


            Label lblFileExists = (Label)e.Row.FindControl("lblFileExists");
            if (lblFileExists != null)
            {
                lblFileExists.Style.Remove("border-bottom");
                lblFileExists.Font.Bold = false;

                if (letter.FileExists(Convert.ToInt32(Session["SiteID"])))
                {
                    lblFileExists.Text = "Yes";
                }
                else
                {
                    if (letter.LetterType.ID == 234 || letter.LetterType.ID == 235) // medicare/dva rejection codes
                    {
                        if (letter.Docname.Length == 0)
                        {
                            lblFileExists.Text = string.Empty;
                        }
                        if (letter.Docname.Length > 0)
                        {
                            lblFileExists.Text      = "<span style=\"border-bottom:thin dotted black;\" title=\"This won't be in the list of available reject codes.\r\nTo have it in the available list of reject codes, either change the docname to be blank or change the docname to one that exists in the below list.\">No</span>";
                            lblFileExists.Font.Bold = true;
                        }
                    }
                    else
                    {
                        lblFileExists.Text = "No";
                        if (letter.Docname.Length > 0)
                        {
                            lblFileExists.Text      = "<span style=\"border-bottom:thin dotted black;\" title=\"This won't be in the list of available letters.\r\nTo have it in the available list of letters, change the docname to one that exists in the below list.\">No</span>";
                            lblFileExists.Font.Bold = true;
                        }
                    }
                }
            }


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DropDownList ddlLetterType = (DropDownList)e.Row.FindControl("ddlNewLetterType");
            ddlLetterType.DataSource     = letterTypes;
            ddlLetterType.DataTextField  = "descr";
            ddlLetterType.DataValueField = "letter_type_id";
            ddlLetterType.DataBind();

            DropDownList ddlSite = (DropDownList)e.Row.FindControl("ddlNewSite");
            ddlSite.DataSource     = sites;
            ddlSite.DataTextField  = "name";
            ddlSite.DataValueField = "site_id";
            ddlSite.DataBind();
        }
    }
Exemplo n.º 19
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!ddlEndDateValidateAllOrNoneSet.IsValid ||
            !ddlStartDateValidateAllOrNoneSet.IsValid ||
            !ddlDOBValidateAllOrNoneSet.IsValid)
        {
            return;
        }

        txtPwd.Attributes["value"] = txtPwd.Text;  // pwd fields is unset on send back to server, so re-set it

        if (GetUrlParamType() == UrlParamType.View)
        {
            Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "edit"));
        }
        else if (GetUrlParamType() == UrlParamType.Edit)
        {
            Staff staff = StaffDB.GetByID(Convert.ToInt32(this.lblId.Text));

            if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && staff.Login != txtLogin.Text && UserDatabaseMapperDB.UsernameExists(txtLogin.Text))
            {
                SetErrorMessage("Login name already in use by another user");
                return;
            }
            if (StaffDB.LoginExists(txtLogin.Text, staff.StaffID))
            {
                SetErrorMessage("Login name already in use by another user");
                return;
            }
            if (staff.Pwd != txtPwd.Text && txtPwd.Text.Length < 6)
            {
                SetErrorMessage(staff.Pwd.Length >= 6 ? "Password must be at least 6 characters" : "New passwords must be at least 6 characters");
                return;
            }

            bool loggedInUserIsStakeholder = Session["IsStakeholder"] != null && Convert.ToBoolean(Session["IsStakeholder"]);
            bool loggedInUserIsMasterAdmin = Session["IsMasterAdmin"] != null && Convert.ToBoolean(Session["IsMasterAdmin"]);
            bool setIsStakeholder          = loggedInUserIsStakeholder ? chkIsStakeholder.Checked : staff.IsStakeholder;
            bool setIsMasterAdmin          = loggedInUserIsStakeholder || loggedInUserIsMasterAdmin ? chkIsMasterAdmin.Checked : staff.IsMasterAdmin;

            if (!staff.IsProvider && chkIsProvider.Checked && (StaffDB.GetCountOfProviders() >= Convert.ToInt32(SystemVariableDB.GetByDescr("MaxNbrProviders").Value)))
            {
                SetErrorMessage("You have reached your maximum allowable providers. Please uncheck their status as a provider to update them or hit cancel. Contact Mediclinic if you would like to upgrade your account.");
                return;
            }


            if (chkIsProvider.Checked)
            {
                System.Data.DataTable tbl = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "has_offerings=1 AND field_id <> 0", "", "field_id", "descr");

                bool         roleSetAsProvider = false;
                IDandDescr[] fields            = new IDandDescr[tbl.Rows.Count];
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    fields[i] = new IDandDescr(Convert.ToInt32(tbl.Rows[i]["field_id"]), tbl.Rows[i]["descr"].ToString());
                    if (Convert.ToInt32(ddlField.SelectedValue) == Convert.ToInt32(tbl.Rows[i]["field_id"]))
                    {
                        roleSetAsProvider = true;
                    }
                }

                if (!roleSetAsProvider)
                {
                    if (fields.Length == 1)
                    {
                        SetErrorMessage("When setting a staff member as a provider, you need to set their Role as '" + fields[0].Descr + "'.");
                        return;
                    }
                    else if (fields.Length == 2)
                    {
                        SetErrorMessage("When setting a staff member as a provider, you need to set their Role as '" + fields[0].Descr + "' or '" + fields[1].Descr + "'.");
                        return;
                    }
                    else
                    {
                        string providerFields = string.Empty;
                        for (int i = 0; i < fields.Length; i++)
                        {
                            providerFields += (providerFields.Length == 0 ? "" : ", ") + (fields.Length >= 2 && i == (fields.Length - 2) ? "or " : "") + fields[i].Descr;
                        }

                        SetErrorMessage("When setting a staff member as a provider, you need to set their Role as one of the following: " + providerFields);
                        return;
                    }
                }
            }



            if (chkIsMasterAdmin.Checked)
            {
                chkIsAdmin.Checked = true;
            }

            PersonDB.Update(staff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), staff.Person.Nickname, ddlGender.SelectedValue, GetDOBFromForm(), DateTime.Now);
            StaffDB.Update(staff.StaffID, staff.Person.PersonID, txtLogin.Text, txtPwd.Text, staff.StaffPosition.StaffPositionID, Convert.ToInt32(ddlField.SelectedValue), staff.CostCentre.CostCentreID,
                           chkContractor.Checked, txtTFN.Text, txtProviderNumber.Text.ToUpper(),
                           ddlStatus.SelectedValue == "Inactive", chkIsCommission.Checked, Convert.ToDecimal(txtCommissionPercent.Text),
                           setIsStakeholder, setIsMasterAdmin, chkIsAdmin.Checked, chkIsPrincipal.Checked, chkIsProvider.Checked, staff.IsExternal,
                           GetStartDateFromForm(), GetEndDateFromForm(), txtComments.Text, chkSMSBKs.Checked, chkEmailBKs.Checked);

            if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && staff.Login != txtLogin.Text)
            {
                UserDatabaseMapper curDBMapper = UserDatabaseMapperDB.GetByLogin(staff.Login, Session["DB"].ToString());
                if (curDBMapper == null)
                {
                    UserDatabaseMapperDB.Insert(txtLogin.Text, Session["DB"].ToString());
                }
                else
                {
                    UserDatabaseMapperDB.Update(curDBMapper.ID, txtLogin.Text, Session["DB"].ToString());
                }
            }

            Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "view"));
        }
        else if (GetUrlParamType() == UrlParamType.Add)
        {
            if (chkIsProvider.Checked && (StaffDB.GetCountOfProviders() >= Convert.ToInt32(SystemVariableDB.GetByDescr("MaxNbrProviders").Value)))
            {
                SetErrorMessage("You have reached your maximum allowable providers. Please uncheck their status as a provider to add them. Contact Mediclinic if you would like to upgrade your account.");
                return;
            }

            if (chkIsProvider.Checked)
            {
                System.Data.DataTable tbl = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "has_offerings=1 AND field_id <> 0", "", "field_id", "descr");

                bool         roleSetAsProvider = false;
                IDandDescr[] fields            = new IDandDescr[tbl.Rows.Count];
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    fields[i] = new IDandDescr(Convert.ToInt32(tbl.Rows[i]["field_id"]), tbl.Rows[i]["descr"].ToString());
                    if (Convert.ToInt32(ddlField.SelectedValue) == Convert.ToInt32(tbl.Rows[i]["field_id"]))
                    {
                        roleSetAsProvider = true;
                    }
                }

                if (!roleSetAsProvider)
                {
                    if (fields.Length == 1)
                    {
                        SetErrorMessage("When setting a staff member as a provider, you need to set their Role as '" + fields[0].Descr + "'.");
                        return;
                    }
                    else if (fields.Length == 2)
                    {
                        SetErrorMessage("When setting a staff member as a provider, you need to set their Role as '" + fields[0].Descr + "' or '" + fields[1].Descr + "'.");
                        return;
                    }
                    else
                    {
                        string providerFields = string.Empty;
                        for (int i = 0; i < fields.Length; i++)
                        {
                            providerFields += (providerFields.Length == 0 ? "" : ", ") + (fields.Length >= 2 && i == (fields.Length - 2) ? "or " : "") + fields[i].Descr;
                        }

                        SetErrorMessage("When setting a staff member as a provider, you need to set their Role as one of the following: " + providerFields);
                        return;
                    }
                }
            }

            if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]) && UserDatabaseMapperDB.UsernameExists(txtLogin.Text))
            {
                lblErrorMessage.Text    = "Login name already in use by another user";
                lblErrorMessage.Visible = true;
                return;
            }
            if (StaffDB.LoginExists(txtLogin.Text))
            {
                lblErrorMessage.Text    = "Login name already in use by another user";
                lblErrorMessage.Visible = true;
                return;
            }
            if (txtPwd.Text.Length < 6)
            {
                SetErrorMessage("Password must be at least 6 characters");
                return;
            }


            int  person_id    = -1;
            int  staff_id     = -1;
            bool staff_added  = false;
            int  mainDbUserID = -1;

            try
            {
                if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]))
                {
                    mainDbUserID = UserDatabaseMapperDB.Insert(txtLogin.Text, Session["DB"].ToString());
                }

                bool loggedInUserIsStakeholder = Session["IsStakeholder"] != null && Convert.ToBoolean(Session["IsStakeholder"]);
                bool loggedInUserIsMasterAdmin = Session["IsMasterAdmin"] != null && Convert.ToBoolean(Session["IsMasterAdmin"]);
                bool setIsStakeholder          = loggedInUserIsStakeholder ? chkIsStakeholder.Checked : false;
                bool setIsMasterAdmin          = loggedInUserIsStakeholder || loggedInUserIsMasterAdmin ? chkIsMasterAdmin.Checked : false;

                if (chkIsMasterAdmin.Checked)
                {
                    chkIsAdmin.Checked = true;
                }

                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, GetDOBFromForm());
                staff_id  = StaffDB.Insert(person_id, txtLogin.Text, txtPwd.Text, StaffPositionDB.GetByDescr("Unknown").StaffPositionID, Convert.ToInt32(ddlField.SelectedValue), 59,
                                           chkContractor.Checked, txtTFN.Text, txtProviderNumber.Text.ToUpper(),
                                           ddlStatus.SelectedValue == "Inactive", chkIsCommission.Checked, Convert.ToDecimal(txtCommissionPercent.Text),
                                           setIsStakeholder, setIsMasterAdmin, chkIsAdmin.Checked, chkIsPrincipal.Checked, chkIsProvider.Checked, false,
                                           GetStartDateFromForm(), GetEndDateFromForm(), txtComments.Text, chkSMSBKs.Checked, chkEmailBKs.Checked);
                staff_added = true;

                string url = Request.RawUrl;
                url = UrlParamModifier.AddEdit(url, "type", "view");
                url = UrlParamModifier.AddEdit(url, "id", staff_id.ToString());
                Response.Redirect(url);
            }
            catch (Exception)
            {
                if (staff_added)
                {
                    string url = Request.RawUrl;
                    url = UrlParamModifier.AddEdit(url, "type", "view");
                    url = UrlParamModifier.AddEdit(url, "id", staff_id.ToString());
                    Response.Redirect(url);
                    return;
                }

                // roll back - backwards of creation order
                PersonDB.Delete(person_id);
                if (!Convert.ToBoolean(ConfigurationManager.AppSettings["UseConfigDB"]))
                {
                    UserDatabaseMapperDB.Delete(mainDbUserID);
                }

                throw;
            }
        }
        else
        {
            HideTableAndSetErrorMessage();
        }
    }
Exemplo n.º 20
0
    private void FillEditViewForm(Staff staff, bool isEditMode)
    {
        Page.Title = ((SystemVariables)Session["SystemVariables"])["Site"].Value + " - " + staff.Person.FullnameWithoutMiddlename;

        staff.Person = PersonDB.GetByID(staff.Person.PersonID);
        Person addedBy = staff.Person.PersonID < 0 ? null : PersonDB.GetByID(staff.Person.AddedBy);

        if (!Utilities.IsDev())
        {
            idRow.Attributes["class"] = "hiddencol";
        }



        this.lnkThisStaff.Visible     = true;
        this.lnkThisStaff.NavigateUrl = "~/RegisterOrganisationsToStaffV2.aspx?id=" + Request.QueryString["id"].ToString();
        this.lnkThisStaff.Text        = "Edit";


        lblId.Text             = staff.StaffID.ToString();
        lblAddedBy.Text        = addedBy == null ? "" : addedBy.Firstname + " " + addedBy.Surname;
        lblStaffDateAdded.Text = staff.StaffDateAdded.ToString("dd-MM-yyyy");

        txtComments.Text = staff.Comment;


        if (isEditMode)
        {
            DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", staff.Person.Title.ID == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();

            if (staff.StartDate != DateTime.MinValue)
            {
                ddlStartDate_Day.SelectedValue   = staff.StartDate.Day.ToString();
                ddlStartDate_Month.SelectedValue = staff.StartDate.Month.ToString();
                ddlStartDate_Year.SelectedValue  = staff.StartDate.Year.ToString();
            }
            if (staff.EndDate != DateTime.MinValue)
            {
                ddlEndDate_Day.SelectedValue   = staff.EndDate.Day.ToString();
                ddlEndDate_Month.SelectedValue = staff.EndDate.Month.ToString();
                ddlEndDate_Year.SelectedValue  = staff.EndDate.Year.ToString();
            }
            ddlTitle.SelectedValue = staff.Person.Title.ID.ToString();
            txtFirstname.Text      = staff.Person.Firstname;
            txtMiddlename.Text     = staff.Person.Middlename;
            txtSurname.Text        = staff.Person.Surname;
            if (ddlGender.Items.FindByValue(staff.Person.Gender) == null)
            {
                ddlGender.Items.Add(new ListItem(staff.Person.Gender == "" ? "" : staff.Person.Gender, staff.Person.Gender));
            }
            ddlGender.SelectedValue = staff.Person.Gender;

            txtLogin.Text = staff.Login;
            txtPwd.Text   = staff.Pwd;
            txtPwd.Attributes["value"] = staff.Pwd;
            ddlStatus.SelectedValue    = staff.IsFired ? "Inactive" : "Active";

            lblTitle.Visible      = false;
            lblFirstname.Visible  = false;
            lblMiddlename.Visible = false;
            lblSurname.Visible    = false;
            lblGender.Visible     = false;
            lblLogin.Visible      = false;
            lblPwd.Visible        = false;
            lblIsFired.Visible    = false;
        }
        else
        {
            lblTitle.Text      = staff.Person.Title.ID == 0 ? "" : staff.Person.Title.Descr;
            lblFirstname.Text  = staff.Person.Firstname.Length == 0 ? "" : staff.Person.Firstname;
            lblMiddlename.Text = staff.Person.Middlename.Length == 0 ? "" : staff.Person.Middlename;
            lblSurname.Text    = staff.Person.Surname.Length == 0 ? "" : staff.Person.Surname;
            lblGender.Text     = GetGenderText(staff.Person.Gender);
            lblLogin.Text      = staff.Login.Length == 0 ? "" : staff.Login;
            lblIsFired.Text    = staff.IsFired                       ? "<b><font color=\"red\">Inactive</font></b>" : "Active";

            lblStartDate.Text = staff.StartDate == DateTime.MinValue ? "" : staff.StartDate.ToString("dd-MM-yyyy");
            lblEndDate.Text   = staff.EndDate == DateTime.MinValue ? "" : staff.EndDate.ToString("dd-MM-yyyy");

            lblAddedBy.Font.Bold        = true;
            lblStaffDateAdded.Font.Bold = true;

            txtComments.Enabled   = false;
            txtComments.ForeColor = System.Drawing.Color.Black;



            ddlTitle.Visible      = false;
            txtFirstname.Visible  = false;
            txtMiddlename.Visible = false;
            txtSurname.Visible    = false;
            ddlGender.Visible     = false;

            ddlStartDate_Day.Visible   = false;
            ddlStartDate_Month.Visible = false;
            ddlStartDate_Year.Visible  = false;
            ddlEndDate_Day.Visible     = false;
            ddlEndDate_Month.Visible   = false;
            ddlEndDate_Year.Visible    = false;

            txtLogin.Visible  = false;
            txtPwd.Visible    = false;
            ddlStatus.Visible = false;
        }


        DataTable incList = RegisterStaffDB.GetDataTable_OrganisationsOf(staff.StaffID);

        incList.DefaultView.Sort = "name ASC";
        if (incList.Rows.Count == 0)
        {
            lstClinics.Items.Add(new ListItem("No Clinics Allocated Yet"));
        }
        else
        {
            foreach (DataRowView row in incList.DefaultView)
            {
                lstClinics.Items.Add(new ListItem(row["name"].ToString()));
            }
        }

        UpdateSiteRestrictions();
        SetBookingsList(staff);

        btnSubmit.Text    = isEditMode ? "Update Details" : "Edit Details";
        btnCancel.Visible = isEditMode;
    }
Exemplo n.º 21
0
    private void FillEmptyForm()
    {
        if (!Utilities.IsDev())
        {
            idRow.Attributes["class"] = "hiddencol";
        }

        DataTable dt_titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", "", " descr ", "title_id", "descr");

        for (int i = dt_titles.Rows.Count - 1; i >= 0; i--)
        {
            if (Convert.ToInt32(dt_titles.Rows[i]["title_id"]) == 0)
            {
                DataRow newRow = dt_titles.NewRow();
                newRow.ItemArray = dt_titles.Rows[i].ItemArray;
                dt_titles.Rows.RemoveAt(i);
                dt_titles.Rows.InsertAt(newRow, 0);
                break;
            }
        }
        ddlTitle.DataSource = dt_titles;
        ddlTitle.DataBind();
        ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "dr", "dr.");

        DataTable orgs = OrganisationDB.GetDataTable_ByType(new int[] { 191 });

        orgs.DefaultView.Sort = "name ASC";
        foreach (DataRowView row in orgs.DefaultView)
        {
            ddlOrgsList.Items.Add(new ListItem(row["name"].ToString(), row["organisation_id"].ToString()));
        }

        //if (orgs.Rows.Count > 0)
        //    UpdateReferrersAtOrgList();


        if (orgs.Rows.Count > 0)
        {
            orgsListRow.Visible = true;

            newOrgTitleRow.Visible            = false;
            newOrgNameRow.Visible             = false;
            newOrgABNRow.Visible              = false;
            newOrgACNRow.Visible              = false;
            newOrgCommentsRow.Visible         = false;
            newOrgSepeatorTrailingRow.Visible = false;
            newOrgAddressRow1.Visible         = false;
            newOrgAddressRow2.Visible         = false;
            newOrgAddressRow3.Visible         = false;
            newOrgAddressRow4.Visible         = false;
            newOrgAddressRow5.Visible         = false;
            newOrgAddressRow6.Visible         = false;
            newOrgAddressRow7.Visible         = false;
            newOrgAddressRow8.Visible         = false;
            newOrgAddressRow9.Visible         = false;
            newOrgAddressRow10.Visible        = false;
            newOrgContactRow1.Visible         = false;
            newOrgContactRow2.Visible         = false;
            newOrgContactRow3.Visible         = false;
            newOrgContactTitleRow.Visible     = false;
        }
        else
        {
            SetAddNewOrgSection();
        }


        btnSubmit.Text = "Add Referrer";

        SetupAddressGUI();
    }
    public void SetModalDropDownList(StartEndTime startEndTime)
    {
        int minBookingDurationMins = 10;

        if (Convert.ToBoolean(Session["SiteIsClinic"]))
        {
            minBookingDurationMins = Convert.ToInt32(((SystemVariables)Session["SystemVariables"])["BookingSheetTimeSlotMins_Clinic"].Value);
        }
        else if (Convert.ToBoolean(Session["SiteIsAgedCare"]))
        {
            minBookingDurationMins = Convert.ToInt32(((SystemVariables)Session["SystemVariables"])["BookingSheetTimeSlotMins_AgedCare"].Value);
        }
        else if (Convert.ToBoolean(Session["SiteIsGP"]))
        {
            minBookingDurationMins = Convert.ToInt32(((SystemVariables)Session["SystemVariables"])["BookingSheetTimeSlotMins_GP"].Value);
        }


        ddlModalStartHour.Items.Clear();
        ddlModalEndHour.Items.Clear();
        ddlModalStartMinute.Items.Clear();
        ddlModalEndMinute.Items.Clear();

        for (int i = startEndTime.StartTime.Hours; i <= startEndTime.EndTime.Hours; i++)
        {
            ddlModalStartHour.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
            ddlModalEndHour.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
        }
        for (int i = 0; i < 60; i += minBookingDurationMins)
        {
            ddlModalStartMinute.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
            ddlModalEndMinute.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
        }


        for (int i = 0; i <= 23; i++)
        {
            ddlModalPopupUnavailableRecurringModalStartHour.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
            ddlModalPopupUnavailableRecurringModalEndHour.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
        }
        for (int i = 0; i < 60; i += minBookingDurationMins)
        {
            ddlModalPopupUnavailableRecurringModalStartMinute.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
            ddlModalPopupUnavailableRecurringModalEndMinute.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
        }


        ddlOrgUnavailabilityReason.Items.Add(new ListItem("[None]", "-1"));
        DataTable tblUnavailabilityReasons = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "BookingUnavailabilityReason", "", "descr", "booking_unavailability_reason_id", "booking_unavailability_reason_type_id", "descr");

        foreach (DataRow row in tblUnavailabilityReasons.Rows)
        {
            if (row["booking_unavailability_reason_type_id"].ToString() == "341")
            {
                ddlProvUnavailabilityReason.Items.Add(new ListItem(row["descr"].ToString(), row["booking_unavailability_reason_id"].ToString()));
            }
            else if (row["booking_unavailability_reason_type_id"].ToString() == "340")
            {
                ddlOrgUnavailabilityReason.Items.Add(new ListItem(row["descr"].ToString(), row["booking_unavailability_reason_id"].ToString()));
            }
        }


        //DataTable tblBookingChangeHistoryReasons = DBBase.GetGenericDataTable_WithWhereOrderClause("BookingChangeHistoryReason", "", "display_order, descr", "booking_change_history_reason_id", "descr", "display_order");
        DataTable tblBookingChangeHistoryReasons = BookingChangeHistoryReasonDB.GetDataTable();

        foreach (DataRow row in tblBookingChangeHistoryReasons.Rows)
        {
            ddlBookingMovementReason.Items.Add(new ListItem(row["descr"].ToString(), row["booking_change_history_reason_id"].ToString()));
        }

        ddlEveryNWeeks.Items.Clear();
        for (int i = 1; i <= 13; i++)
        {
            ddlEveryNWeeks.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }

        ddlOcurrences.Items.Clear();
        for (int i = 1; i <= 13; i++)
        {
            ddlOcurrences.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }

        ddlUnavailableEveryNWeeks.Items.Clear();
        for (int i = 1; i <= 13; i++)
        {
            ddlUnavailableEveryNWeeks.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }
    }
    protected void GrdReferrer_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable dt       = Session["referrerinfoperson_data"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("referrer_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            DropDownList ddlTitle = (DropDownList)e.Row.FindControl("ddlTitle");
            if (ddlTitle != null)
            {
                DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", Convert.ToInt32(thisRow["title_id"]) == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
                ddlTitle.DataSource     = titles;
                ddlTitle.DataTextField  = "descr";
                ddlTitle.DataValueField = "title_id";
                ddlTitle.DataBind();
                ddlTitle.SelectedValue = thisRow["title_id"].ToString();
            }

            DropDownList ddlGender = (DropDownList)e.Row.FindControl("ddlGender");
            if (ddlGender != null)
            {
                if (thisRow["gender"].ToString() != "")
                {
                    for (int i = ddlGender.Items.Count - 1; i >= 0; i--)
                    {
                        if (ddlGender.Items[i].Value == "")
                        {
                            ddlGender.Items.RemoveAt(i);
                        }
                    }
                }
            }

            if (ddlTitle != null && ddlGender != null)
            {
                ddlTitle.Attributes["onchange"] = "title_changed_reset_gender('" + ddlTitle.ClientID + "','" + ddlGender.ClientID + "');";
            }


            ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
            if (btnDelete != null)
            {
                bool is_deleted = Convert.ToBoolean(thisRow["is_deleted"]);
                if (is_deleted)
                {
                    btnDelete.CommandName   = "_UnDelete";
                    btnDelete.ImageUrl      = "~/images/tick-24.png";
                    btnDelete.AlternateText = "UnDelete";
                    btnDelete.ToolTip       = "UnDelete";
                }
            }

            Label lblFirstname = (Label)e.Row.FindControl("lblFirstname");
            if (lblFirstname != null)
            {
                lblFirstname.Visible = (Request.QueryString["org"] != null);
            }

            HyperLink lnkFirstname = (HyperLink)e.Row.FindControl("lnkFirstname");
            if (lnkFirstname != null)
            {
                lnkFirstname.Visible = (Request.QueryString["org"] == null);
            }


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DataTable    titles   = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr");
            DropDownList ddlTitle = (DropDownList)e.Row.FindControl("ddlNewTitle");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();
            ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "dr", "dr.");
        }
    }
    protected void FillGrid()
    {
        int       bulk_letter_sending_queue_batch_id = IsValidFormBatchID() ? GetFormBatchID() : -1;
        DataTable dt = BulkLetterSendingQueueDB.GetDataTable(bulk_letter_sending_queue_batch_id);


        // send method hashtable
        DataTable sendMethodTbl  = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "LetterPrintHistorySendMethod", "", "", "letter_print_history_send_method_id", "descr");
        Hashtable sendMethodHash = new Hashtable();

        for (int i = 0; i < sendMethodTbl.Rows.Count; i++)
        {
            sendMethodHash[Convert.ToInt32(sendMethodTbl.Rows[i]["letter_print_history_send_method_id"])] = (string)sendMethodTbl.Rows[i]["descr"];
        }

        // patient hashtable
        ArrayList ptIDs = new ArrayList();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["patient_id"] != DBNull.Value)
            {
                ptIDs.Add((int)dt.Rows[i]["patient_id"]);
            }
        }
        Hashtable patientHash = PatientDB.GetByIDsInHashtable((int[])ptIDs.ToArray(typeof(int)));

        // staff hashtable
        Hashtable staffHash = StaffDB.GetAllInHashtable(true, true, true, false);

        // referrersHash
        Hashtable referrersHash = ReferrerDB.GetHashtableByReferrer();

        // letters hashtable
        Hashtable letterHash = LetterDB.GetHashTable();


        // add from hashtable
        dt.Columns.Add("letter_print_history_send_method_descr", typeof(String));
        dt.Columns.Add("added_by_name", typeof(String));
        dt.Columns.Add("patient_name", typeof(String));
        dt.Columns.Add("referrer_name", typeof(String));
        dt.Columns.Add("letter_doc_name", typeof(String));

        int SMSSent     = 0;
        int SMSUnSent   = 0;
        int EmailSent   = 0;
        int EmailUnSent = 0;
        int PrintSent   = 0;
        int PrintUnSent = 0;

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int  letter_print_history_send_method_id = Convert.ToInt32(dt.Rows[i]["letter_print_history_send_method_id"]);
            bool sent = dt.Rows[i]["datetime_sent"] != DBNull.Value;

            dt.Rows[i]["letter_print_history_send_method_descr"] = (string)sendMethodHash[letter_print_history_send_method_id];
            dt.Rows[i]["added_by_name"] = dt.Rows[i]["added_by"] == DBNull.Value ? "" : ((Staff)staffHash[Convert.ToInt32(dt.Rows[i]["added_by"])]).Person.FullnameWithoutMiddlename;
            dt.Rows[i]["patient_name"]  = dt.Rows[i]["patient_id"] == DBNull.Value ? "" : ((Patient)patientHash[Convert.ToInt32(dt.Rows[i]["patient_id"])]).Person.FullnameWithoutMiddlename;

            dt.Rows[i]["referrer_name"] = dt.Rows[i]["referrer_id"] == DBNull.Value ? "" : ((Referrer)referrersHash[Convert.ToInt32(dt.Rows[i]["referrer_id"])]).Person.FullnameWithoutMiddlename;

            string source_template_path = dt.Rows[i]["email_letter_source_template_path"].ToString();
            string letter_doc_name      = source_template_path.Length == 0 ? "" : System.IO.Path.GetFileName(source_template_path);
            dt.Rows[i]["letter_doc_name"] = letter_doc_name;

            if (letter_print_history_send_method_id == 3 && sent)
            {
                SMSSent++;
            }
            if (letter_print_history_send_method_id == 3 && !sent)
            {
                SMSUnSent++;
            }
            if (letter_print_history_send_method_id == 2 && sent)
            {
                EmailSent++;
            }
            if (letter_print_history_send_method_id == 2 && !sent)
            {
                EmailUnSent++;
            }
            if (letter_print_history_send_method_id == 1 && sent)
            {
                PrintSent++;
            }
            if (letter_print_history_send_method_id == 1 && !sent)
            {
                PrintUnSent++;
            }
        }

        lblSMSSent.Text     = SMSSent.ToString();
        lblSMSUnSent.Text   = SMSUnSent.ToString();
        lblEmailSent.Text   = EmailSent.ToString();
        lblEmailUnSent.Text = EmailUnSent.ToString();
        lblPrintSent.Text   = PrintSent.ToString();
        lblPrintUnSent.Text = PrintUnSent.ToString();
        lblTotalSent.Text   = (SMSSent + EmailSent + PrintSent).ToString();
        lblTotalUnSent.Text = (SMSUnSent + EmailUnSent + PrintUnSent).ToString();


        DataView dv = new DataView(dt);

        dv.Sort = "letter_print_history_send_method_id";
        dt      = dv.ToTable();


        Session["lettersprintbatchstatus_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["lettersprintbatchstatus_sortexpression"] != null && Session["lettersprintbatchstatus_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort = Session["lettersprintbatchstatus_sortexpression"].ToString();
                GrdBulkLetterSendingQueue.DataSource = dataView;
            }
            else
            {
                GrdBulkLetterSendingQueue.DataSource = dt;
            }

            GrdBulkLetterSendingQueue.AllowPaging = false;

            try
            {
                GrdBulkLetterSendingQueue.DataBind();
                GrdBulkLetterSendingQueue.PagerSettings.FirstPageText = "1";
                GrdBulkLetterSendingQueue.PagerSettings.LastPageText  = GrdBulkLetterSendingQueue.PageCount.ToString();
                GrdBulkLetterSendingQueue.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdBulkLetterSendingQueue.DataSource = dt;
            GrdBulkLetterSendingQueue.DataBind();

            int TotalColumns = GrdBulkLetterSendingQueue.Rows[0].Cells.Count;
            GrdBulkLetterSendingQueue.Rows[0].Cells.Clear();
            GrdBulkLetterSendingQueue.Rows[0].Cells.Add(new TableCell());
            GrdBulkLetterSendingQueue.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdBulkLetterSendingQueue.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemplo n.º 25
0
    private void SetupGUI(string dbID, string orgID)
    {
        ddlClinic.Focus();

        ddlDOB_Day.Items.Add(new ListItem("--", "-1"));
        ddlDOB_Month.Items.Add(new ListItem("--", "-1"));
        ddlDOB_Year.Items.Add(new ListItem("----", "-1"));

        for (int i = 1; i <= 31; i++)
        {
            ddlDOB_Day.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }
        for (int i = 1; i <= 12; i++)
        {
            ddlDOB_Month.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }
        for (int i = 1900; i <= DateTime.Today.Year; i++)
        {
            ddlDOB_Year.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }



        string curDbName = Session == null || Session["DB"] == null ? null : Session["DB"].ToString();

        try
        {
            Session["DB"] = "Mediclinic_" + dbID;
            Session["SystemVariables"] = SystemVariableDB.GetAll();

            bool allowPatientsToCreateOwnRecords = ((SystemVariables)Session["SystemVariables"])["AllowPatientsToCreateOwnRecords"].Value == "1";
            if (!allowPatientsToCreateOwnRecords)
            {
                throw new CustomMessageException("Invalid ID in URL");
            }

            ddlTitle.DataSource = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr");
            ddlTitle.DataBind();
            ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "mr", "mr.");

            DataTable phoneNumberTypes = ContactTypeDB.GetDataTable(2);
            for (int i = phoneNumberTypes.Rows.Count - 1; i >= 0; i--)
            {
                if (Convert.ToInt32(phoneNumberTypes.Rows[i]["at_contact_type_id"]) != 30 && Convert.ToInt32(phoneNumberTypes.Rows[i]["at_contact_type_id"]) != 33)
                {
                    phoneNumberTypes.Rows.RemoveAt(i);
                }
            }
            ddlPhoneNumberType.DataSource = phoneNumberTypes;
            ddlPhoneNumberType.DataBind();
            ddlPhoneNumberType.SelectedValue = "30"; // mobile

            lblSiteName.Text = ((SystemVariables)Session["SystemVariables"])["Site"].Value;

            Site[] sites        = SiteDB.GetAll();
            Site   clinicSite   = null;
            Site   agedCareSite = null;
            for (int i = 0; i < sites.Length; i++)
            {
                if (sites[i].SiteType.ID == 1)
                {
                    clinicSite = sites[i];
                }
                if (sites[i].SiteType.ID == 2)
                {
                    agedCareSite = sites[i];
                }
            }

            List <Tuple <string, Organisation> > clinics = GetClinicList();
            foreach (Tuple <string, Organisation> item in clinics)
            {
                ddlClinic.Items.Add(new ListItem(item.Item2.Name, "Mediclinic_" + dbID + "__" + clinicSite.SiteID + "__" + item.Item2.OrganisationID));
            }

            if (orgID != null && Regex.IsMatch(orgID, @"^\d+$"))
            {
                Organisation org = OrganisationDB.GetByID(Convert.ToInt32(orgID));
                if (org != null && ddlClinic.Items.FindByValue("Mediclinic_" + dbID + "__" + clinicSite.SiteID + "__" + org.OrganisationID) != null)
                {
                    ddlClinic.SelectedValue = "Mediclinic_" + dbID + "__" + clinicSite.SiteID + "__" + org.OrganisationID;
                }
            }
        }
        finally
        {
            Session.Remove("DB");
            Session.Remove("SystemVariables");

            if (curDbName != null)
            {
                Session["DB"] = curDbName;
                Session["SystemVariables"] = SystemVariableDB.GetAll();
            }
        }



        bool editable = true;

        Utilities.SetEditControlBackColour(ddlClinic, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlTitle, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtFirstname, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtSurname, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlGender, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlDOB_Day, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlDOB_Month, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlDOB_Year, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtPhoneNumber, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(ddlPhoneNumberType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtEmailAddr, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtLogin, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
        Utilities.SetEditControlBackColour(txtPwd, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty);
    }
    protected void GrdContactType_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable groups = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "ContactTypeGroup", "", "descr", "contact_type_group_id", "descr");

        DataTable dt_contact_type = Session["contacttype_data"] as DataTable;
        bool      tblEmpty        = (dt_contact_type.Rows.Count == 1 && dt_contact_type.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblContactTypeId");
            DataRow[] foundRows = dt_contact_type.Select("at_contact_type_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];


            DropDownList ddlContactTypeGroup = (DropDownList)e.Row.FindControl("ddlContactTypeGroup");
            if (ddlContactTypeGroup != null)
            {
                foreach (DataRow row in groups.Rows)
                {
                    ddlContactTypeGroup.Items.Add(new ListItem(row["descr"].ToString(), row["contact_type_group_id"].ToString()));
                }
                ddlContactTypeGroup.SelectedValue = Convert.ToString(thisRow["at_contact_type_group_id"]);
            }

            DropDownList ddlDisplayOrder = (DropDownList)e.Row.FindControl("ddlDisplayOrder");
            if (ddlDisplayOrder != null)
            {
                int lowest_display_order  = 0;
                int highest_display_order = 50;

                int display_order = Convert.ToInt32(thisRow["at_display_order"]);
                if (display_order < lowest_display_order)
                {
                    ddlDisplayOrder.Items.Add(new ListItem(display_order.ToString(), display_order.ToString()));
                }
                for (int i = lowest_display_order; i <= highest_display_order; i++)
                {
                    ddlDisplayOrder.Items.Add(new ListItem(i.ToString(), i.ToString()));
                }
                if (display_order > highest_display_order)
                {
                    ddlDisplayOrder.Items.Add(new ListItem(display_order.ToString(), display_order.ToString()));
                }

                ddlDisplayOrder.SelectedValue = display_order.ToString();
            }

            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DropDownList ddlContactTypeGroup = (DropDownList)e.Row.FindControl("ddlNewContactTypeGroup");
            foreach (DataRow row in groups.Rows)
            {
                ddlContactTypeGroup.Items.Add(new ListItem(row["descr"].ToString(), row["contact_type_group_id"].ToString()));
            }

            DropDownList ddlDisplayOrder = (DropDownList)e.Row.FindControl("ddlNewDisplayOrder");
            for (int i = 0; i <= 50; i++)
            {
                ddlDisplayOrder.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
        }
    }
Exemplo n.º 27
0
    private void FillEditViewForm(Staff staff, bool isEditMode)
    {
        Page.Title = ((SystemVariables)Session["SystemVariables"])["Site"].Value + " - " + staff.Person.FullnameWithoutMiddlename;

        staff.Person = PersonDB.GetByID(staff.Person.PersonID);
        Person addedBy = staff.Person.PersonID < 0 ? null : PersonDB.GetByID(staff.Person.AddedBy);

        if (!Utilities.IsDev())
        {
            idRow.Attributes["class"] = "hiddencol";
        }

        this.lnkBookingList.Visible     = true;
        this.lnkBookingList.NavigateUrl = "~/BookingsListV2.aspx?staff=" + Request.QueryString["id"].ToString();
        this.lnkBookingList.Text        = "Bookings List";

        string allFeatures = "dialogWidth:1250px;dialogHeight:835px;center:yes;resizable:no; scroll:no";
        string js          = "javascript:window.showModalDialog('" + "BookingSheetBlockoutV2.aspx?staff=" + staff.StaffID.ToString() + "', '', '" + allFeatures + "');return false;";

        this.lnkUnavailabilities.Attributes.Add("onclick", js);
        lnkUnavailabilities.NavigateUrl = "javascript:void(0)";

        UpdateGenerateSystemLetters();

        this.lnkThisStaff.Visible     = true;
        this.lnkThisStaff.NavigateUrl = "~/RegisterOrganisationsToStaffV2.aspx?id=" + Request.QueryString["id"].ToString();
        this.lnkThisStaff.Text        = "Edit";

        this.lnkStaffOfferings.Visible     = true;
        this.lnkStaffOfferings.NavigateUrl = "~/StaffOfferingsListV2.aspx?staff=" + Request.QueryString["id"].ToString();
        this.lnkStaffOfferings.Text        = "Set Comissions/Fixed Rates";


        lblId.Text             = staff.StaffID.ToString();
        lblAddedBy.Text        = addedBy == null ? "" : addedBy.Firstname + " " + addedBy.Surname;
        lblStaffDateAdded.Text = staff.StaffDateAdded.ToString("dd-MM-yyyy");

        txtComments.Text = staff.Comment;


        if (isEditMode)
        {
            DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", staff.Person.Title.ID == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();
            DataTable fields = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id <> 0", "descr", "field_id", "descr");
            ddlField.DataSource = fields;
            ddlField.DataBind();
            //DataTable costcentres = CostCentreDB.GetDataTable();
            //ddlCostCentre.DataSource = costcentres;
            //ddlCostCentre.DataBind();

            if (staff.StartDate != DateTime.MinValue)
            {
                ddlStartDate_Day.SelectedValue   = staff.StartDate.Day.ToString();
                ddlStartDate_Month.SelectedValue = staff.StartDate.Month.ToString();
                ddlStartDate_Year.SelectedValue  = staff.StartDate.Year.ToString();
            }
            if (staff.EndDate != DateTime.MinValue)
            {
                ddlEndDate_Day.SelectedValue   = staff.EndDate.Day.ToString();
                ddlEndDate_Month.SelectedValue = staff.EndDate.Month.ToString();
                ddlEndDate_Year.SelectedValue  = staff.EndDate.Year.ToString();
            }
            ddlTitle.SelectedValue = staff.Person.Title.ID.ToString();
            txtFirstname.Text      = staff.Person.Firstname;
            txtMiddlename.Text     = staff.Person.Middlename;
            txtSurname.Text        = staff.Person.Surname;
            if (ddlGender.Items.FindByValue(staff.Person.Gender) == null)
            {
                ddlGender.Items.Add(new ListItem(staff.Person.Gender == "" ? "" : staff.Person.Gender, staff.Person.Gender));
            }
            ddlGender.SelectedValue = staff.Person.Gender;
            if (staff.Person.Dob != DateTime.MinValue)
            {
                ddlDOB_Day.SelectedValue   = staff.Person.Dob.Day.ToString();
                ddlDOB_Month.SelectedValue = staff.Person.Dob.Month.ToString();
                ddlDOB_Year.SelectedValue  = staff.Person.Dob.Year.ToString();
            }
            txtLogin.Text = staff.Login;
            txtPwd.Text   = staff.Pwd;
            txtPwd.Attributes["value"] = staff.Pwd;

            if (ddlField.Items.FindByValue(staff.Field.ID.ToString()) == null)
            {
                ddlField.Items.Add(new ListItem(staff.Field.Descr, staff.Field.ID.ToString()));
            }

            ddlField.SelectedValue  = staff.Field.ID.ToString();
            chkContractor.Checked   = staff.IsContractor;
            txtTFN.Text             = staff.Tfn;
            ddlStatus.SelectedValue = staff.IsFired ? "Inactive" : "Active";
            chkSMSBKs.Checked       = staff.EnableDailyReminderSMS;
            chkEmailBKs.Checked     = staff.EnableDailyReminderEmail;
            //ddlCostCentre.SelectedValue    = staff.CostCentre.CostCentreID.ToString();
            txtProviderNumber.Text    = staff.ProviderNumber;
            chkIsCommission.Checked   = staff.IsCommission;
            txtCommissionPercent.Text = staff.CommissionPercent.ToString();
            chkIsProvider.Checked     = staff.IsProvider;
            chkIsPrincipal.Checked    = staff.IsPrincipal;
            chkIsAdmin.Checked        = staff.IsAdmin;
            chkIsMasterAdmin.Checked  = staff.IsMasterAdmin;
            chkIsStakeholder.Checked  = staff.IsStakeholder;

            lblTitle.Visible      = false;
            lblFirstname.Visible  = false;
            lblMiddlename.Visible = false;
            lblSurname.Visible    = false;
            lblGender.Visible     = false;
            lblDOB.Visible        = false;
            lblLogin.Visible      = false;
            lblPwd.Visible        = false;
            lblField.Visible      = false;
            lblContractor.Visible = false;
            lblTFN.Visible        = false;
            //lblCostCentre.Visible         = false;
            lblProviderNumber.Visible    = false;
            lblIsCommission.Visible      = false;
            lblCommissionPercent.Visible = false;
            lblIsFired.Visible           = false;
            lblSMSBKs.Visible            = false;
            lblEmailBKs.Visible          = false;
            lblIsProvider.Visible        = false;
            lblIsPrincipal.Visible       = false;
            lblIsAdmin.Visible           = false;
            lblIsMasterAdmin.Visible     = false;
            lblIsStakeholder.Visible     = false;
        }
        else
        {
            lblTitle.Text      = staff.Person.Title.ID == 0 ? "" : staff.Person.Title.Descr;
            lblFirstname.Text  = staff.Person.Firstname.Length == 0 ? "" : staff.Person.Firstname;
            lblMiddlename.Text = staff.Person.Middlename.Length == 0 ? "" : staff.Person.Middlename;
            lblSurname.Text    = staff.Person.Surname.Length == 0 ? "" : staff.Person.Surname;
            lblGender.Text     = GetGenderText(staff.Person.Gender);
            lblDOB.Text        = staff.Person.Dob == DateTime.MinValue ? "" : staff.Person.Dob.ToString("dd-MM-yyyy");
            lblLogin.Text      = staff.Login.Length == 0 ? "" : staff.Login;
            lblField.Text      = staff.Field.Descr;
            lblContractor.Text = staff.IsContractor  ? "Yes" : "No";
            lblTFN.Text        = staff.Tfn.Length == 0 ? "" : staff.Tfn;
            //lblCostCentre.Text        = staff.CostCentre.Descr.Length  == 0 ? "" : staff.CostCentre.Descr;
            lblProviderNumber.Text    = staff.ProviderNumber.Length == 0 ? "" : staff.ProviderNumber;
            lblIsCommission.Text      = staff.IsCommission  ? "Yes" : "No";
            lblCommissionPercent.Text = staff.CommissionPercent.ToString();
            lblIsFired.Text           = staff.IsFired       ? "<b><font color=\"red\">Inactive</font></b>" : "Active";
            lblSMSBKs.Text            = staff.EnableDailyReminderSMS   ? "Yes" : "No";
            lblEmailBKs.Text          = staff.EnableDailyReminderEmail ? "Yes" : "No";

            lblIsProvider.Text    = staff.IsProvider    ? "Yes" : "No";
            lblIsPrincipal.Text   = staff.IsPrincipal   ? "Yes" : "No";
            lblIsAdmin.Text       = staff.IsAdmin       ? "Yes" : "No";
            lblIsMasterAdmin.Text = staff.IsMasterAdmin ? "Yes" : "No";
            lblIsStakeholder.Text = staff.IsStakeholder ? "Yes" : "No";

            lblStartDate.Text = staff.StartDate == DateTime.MinValue ? "" : staff.StartDate.ToString("dd-MM-yyyy");
            lblEndDate.Text   = staff.EndDate == DateTime.MinValue ? "" : staff.EndDate.ToString("dd-MM-yyyy");

            lblAddedBy.Font.Bold        = true;
            lblStaffDateAdded.Font.Bold = true;

            txtComments.Enabled   = false;
            txtComments.ForeColor = System.Drawing.Color.Black;



            ddlTitle.Visible      = false;
            txtFirstname.Visible  = false;
            txtMiddlename.Visible = false;
            txtSurname.Visible    = false;
            ddlGender.Visible     = false;
            ddlDOB_Day.Visible    = false;
            ddlDOB_Month.Visible  = false;
            ddlDOB_Year.Visible   = false;

            ddlStartDate_Day.Visible   = false;
            ddlStartDate_Month.Visible = false;
            ddlStartDate_Year.Visible  = false;
            ddlEndDate_Day.Visible     = false;
            ddlEndDate_Month.Visible   = false;
            ddlEndDate_Year.Visible    = false;

            txtLogin.Visible      = false;
            txtPwd.Visible        = false;
            ddlField.Visible      = false;
            chkContractor.Visible = false;
            txtTFN.Visible        = false;
            ddlStatus.Visible     = false;
            chkSMSBKs.Visible     = false;
            chkEmailBKs.Visible   = false;
            //ddlCostCentre.Visible        = false;
            txtProviderNumber.Visible    = false;
            chkIsCommission.Visible      = false;
            txtCommissionPercent.Visible = false;
            chkIsProvider.Visible        = false;
            chkIsPrincipal.Visible       = false;
            chkIsAdmin.Visible           = false;
            chkIsMasterAdmin.Visible     = false;
            chkIsStakeholder.Visible     = false;
        }


        DataTable incList = RegisterStaffDB.GetDataTable_OrganisationsOf(staff.StaffID);

        incList.DefaultView.Sort = "name ASC";
        if (incList.Rows.Count == 0)
        {
            lstClinics.Items.Add(new ListItem("No Clinics Allocated Yet"));
        }
        else
        {
            foreach (DataRowView row in incList.DefaultView)
            {
                lstClinics.Items.Add(new ListItem(row["name"].ToString()));
            }
        }

        UpdateSiteRestrictions();


        btnSubmit.Text    = isEditMode ? "Update Details" : "Edit Details";
        btnCancel.Visible = isEditMode;
    }
    protected void GrdReferrer_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable dt       = Session["referrerinfolist_data"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("register_referrer_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            DropDownList ddlTitle = (DropDownList)e.Row.FindControl("ddlTitle");
            if (ddlTitle != null)
            {
                DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", Convert.ToInt32(thisRow["title_id"]) == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
                ddlTitle.DataSource     = titles;
                ddlTitle.DataTextField  = "descr";
                ddlTitle.DataValueField = "title_id";
                ddlTitle.DataBind();
                ddlTitle.SelectedValue = thisRow["title_id"].ToString();
            }

            DropDownList ddlGender = (DropDownList)e.Row.FindControl("ddlGender");
            if (ddlGender != null)
            {
                if (thisRow["gender"].ToString() != "")
                {
                    for (int i = ddlGender.Items.Count - 1; i >= 0; i--)
                    {
                        if (ddlGender.Items[i].Value == "")
                        {
                            ddlGender.Items.RemoveAt(i);
                        }
                    }
                }
            }

            if (ddlTitle != null && ddlGender != null)
            {
                ddlTitle.Attributes["onchange"] = "title_changed_reset_gender('" + ddlTitle.ClientID + "','" + ddlGender.ClientID + "');";
            }


            HyperLink lnkContactInfo = (HyperLink)e.Row.FindControl("lnkContactInfo");
            if (lnkContactInfo != null)
            {
                int entity_id = Convert.ToInt32(thisRow["organisation_entity_id"]);

                string addEditContactListPage;
                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    addEditContactListPage = "AddEditContactList.aspx";
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    addEditContactListPage = "ContactAusListV2.aspx";
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }

                string allFeatures = "dialogWidth:525px;dialogHeight:430px;center:yes;resizable:no; scroll:no";
                string js          = "javascript:window.showModalDialog('" + addEditContactListPage + "?entity_type=referrer&id=" + entity_id.ToString() + "', '', '" + allFeatures + "');return false;";

                lnkContactInfo.Visible     = true;
                lnkContactInfo.NavigateUrl = "  ";
                lnkContactInfo.Text        = "Clinic Contact";
                lnkContactInfo.Attributes.Add("onclick", js);
            }



            ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
            if (btnDelete != null)
            {
                bool is_deleted = Convert.ToBoolean(thisRow["is_deleted"]);
                if (is_deleted)
                {
                    btnDelete.CommandName   = "_UnDelete";
                    btnDelete.ImageUrl      = "~/images/tick-24.png";
                    btnDelete.AlternateText = "UnDelete";
                    btnDelete.ToolTip       = "UnDelete";
                }
            }

            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            DataTable    titles   = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr");
            DropDownList ddlTitle = (DropDownList)e.Row.FindControl("ddlNewTitle");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();
            ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "dr", "dr.");
        }
    }
    public void SetupGUI()
    {
        Staff        staff = null;
        Organisation org   = null;

        if (IsValidFormStaffID())
        {
            staff = StaffDB.GetByID(GetFormStaffID());
            if (staff == null)
            {
                throw new CustomMessageException("Invalid url staff");
            }
            lblProvider.Text = staff.Person.FullnameWithoutMiddlename;
        }
        else
        {
            tr_provider_row.Visible       = false;
            tr_provider_only_row.Visible  = false;
            tr_provider_space_row.Visible = false;
        }

        if (IsValidFormOrgID())
        {
            org = OrganisationDB.GetByID(GetFormOrgID());
            if (org == null)
            {
                throw new CustomMessageException("Invalid url org");
            }
            lblOrganistion.Text = org.Name;
        }
        else
        {
            tr_org_row.Visible = false;
            tr_organisation_only_row.Visible  = false;
            tr_organisation_space_row.Visible = false;
        }


        if (staff != null && org != null)
        {
            lblHeading.Text = "Booking Sheet Blockout For " + staff.Person.FullnameWithoutMiddlename + " at " + org.Name;
        }
        else if (staff != null)
        {
            lblHeading.Text = "Booking Sheet Blockout For " + staff.Person.FullnameWithoutMiddlename;
        }
        else if (org != null)
        {
            lblHeading.Text = "Booking Sheet Blockout For " + org.Name;
        }
        else
        {
            lblHeading.Text = "Booking Sheet Blockout For All Clnics/Facilities";
        }

        tblInfoOnSettingSpecificUnavailabilities.Visible = staff == null || org == null;

        DateTime date = GetFormDate();

        if (date == DateTime.MinValue)
        {
            date = DateTime.Today;
        }

        if (date.DayOfWeek == DayOfWeek.Sunday)
        {
            chkSunday.Checked = true;
        }
        if (date.DayOfWeek == DayOfWeek.Monday)
        {
            chkMonday.Checked = true;
        }
        if (date.DayOfWeek == DayOfWeek.Tuesday)
        {
            chkTuesday.Checked = true;
        }
        if (date.DayOfWeek == DayOfWeek.Wednesday)
        {
            chkWednesday.Checked = true;
        }
        if (date.DayOfWeek == DayOfWeek.Thursday)
        {
            chkThursday.Checked = true;
        }
        if (date.DayOfWeek == DayOfWeek.Friday)
        {
            chkFriday.Checked = true;
        }
        if (date.DayOfWeek == DayOfWeek.Saturday)
        {
            chkSaturday.Checked = true;
        }


        ddlStartHour.Items.Clear();
        ddlEndHour.Items.Clear();
        for (int i = 0; i < 24; i++)
        {
            ddlStartHour.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
            ddlEndHour.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
        }

        ddlStartMinute.Items.Clear();
        ddlEndMinute.Items.Clear();
        for (int i = 0; i < 60; i += 10)
        {
            ddlStartMinute.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
            ddlEndMinute.Items.Add(new ListItem(i.ToString().PadLeft(2, '0'), i.ToString().PadLeft(2, '0')));
        }

        txtStartDate.Text = date == DateTime.MinValue ? DateTime.Now.ToString("dd-MM-yyyy") : date.ToString("dd-MM-yyyy");
        txtEndDate.Text   = date == DateTime.MinValue ? DateTime.Now.ToString("dd-MM-yyyy") : date.ToString("dd-MM-yyyy");

        ddlOrgUnavailabilityReason.Items.Add(new ListItem("[None]", "-1"));
        DataTable tblUnavailabilityReasons = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "BookingUnavailabilityReason", "", "descr", "booking_unavailability_reason_id", "booking_unavailability_reason_type_id", "descr");

        foreach (DataRow row in tblUnavailabilityReasons.Rows)
        {
            if (row["booking_unavailability_reason_type_id"].ToString() == "341")
            {
                ddlProvUnavailabilityReason.Items.Add(new ListItem(row["descr"].ToString(), row["booking_unavailability_reason_id"].ToString()));
            }
            else if (row["booking_unavailability_reason_type_id"].ToString() == "340")
            {
                ddlOrgUnavailabilityReason.Items.Add(new ListItem(row["descr"].ToString(), row["booking_unavailability_reason_id"].ToString()));
            }
        }

        ddlEveryNWeeks.Items.Clear();
        for (int i = 1; i <= 13; i++)
        {
            ddlEveryNWeeks.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }

        if (IsValidFormStaffID())
        {
            ddlOrgUnavailabilityReason.Visible = false;
        }
        else
        {
            ddlProvUnavailabilityReason.Visible = false;
        }

        UpdateList(org, staff);
    }
Exemplo n.º 30
0
    protected void GrdTreatmentTemplateLetters_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable fields  = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id <> 0 AND has_offerings = 1", "descr", "field_id", "descr");
        DataTable letters = LetterDB.GetDataTable_ByOrg(0, Convert.ToInt32(Session["SiteID"]));

        DataTable dt = Session["treatment_template_letters_data"] as DataTable;

        bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        // remove offering flds that are used
        if (!tblEmpty)
        {
            foreach (DataRow row in dt.Rows)
            {
                for (int i = 0; i < fields.Rows.Count; i++)
                {
                    if (Convert.ToInt32(fields.Rows[i]["field_id"]) == Convert.ToInt32(row["lettertreatmenttemplate_field_id"]))
                    {
                        fields.Rows.RemoveAt(i);
                    }
                }
            }
        }


        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            bool      hasData   = dt.Rows[0][0].ToString() != string.Empty;
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("lettertreatmenttemplate_letter_treatment_template_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlField");
            if (ddlField != null)
            {
                ddlField.DataSource     = fields;
                ddlField.DataTextField  = "descr";
                ddlField.DataValueField = "field_id";
                ddlField.DataBind();
                ddlField.SelectedValue = thisRow["lettertreatmenttemplate_field_id"].ToString();
            }

            DropDownList ddlFirstLetter = (DropDownList)e.Row.FindControl("ddlFirstLetter");
            if (ddlFirstLetter != null)
            {
                ddlFirstLetter.DataSource     = letters;
                ddlFirstLetter.DataTextField  = "letter_docname";
                ddlFirstLetter.DataValueField = "letter_letter_id";
                ddlFirstLetter.DataBind();
                ddlFirstLetter.SelectedValue = thisRow["lettertreatmenttemplate_first_letter_id"].ToString();
            }

            DropDownList ddlTreatmentNoteLetter = (DropDownList)e.Row.FindControl("ddlTreatmentNoteLetter");
            if (ddlTreatmentNoteLetter != null)
            {
                ddlTreatmentNoteLetter.DataSource     = letters;
                ddlTreatmentNoteLetter.DataTextField  = "letter_docname";
                ddlTreatmentNoteLetter.DataValueField = "letter_letter_id";
                ddlTreatmentNoteLetter.DataBind();
                ddlTreatmentNoteLetter.SelectedValue = thisRow["lettertreatmenttemplate_treatment_notes_letter_id"].ToString();
            }

            DropDownList ddlLastLetter = (DropDownList)e.Row.FindControl("ddlLastLetter");
            if (ddlLastLetter != null)
            {
                ddlLastLetter.DataSource     = letters;
                ddlLastLetter.DataTextField  = "letter_docname";
                ddlLastLetter.DataValueField = "letter_letter_id";
                ddlLastLetter.DataBind();
                ddlLastLetter.SelectedValue = thisRow["lettertreatmenttemplate_last_letter_id"].ToString();
            }

            DropDownList ddlLastLetterPT = (DropDownList)e.Row.FindControl("ddlLastLetterPT");
            if (ddlLastLetterPT != null)
            {
                ddlLastLetterPT.DataSource     = letters;
                ddlLastLetterPT.DataTextField  = "letter_docname";
                ddlLastLetterPT.DataValueField = "letter_letter_id";
                ddlLastLetterPT.DataBind();
                ddlLastLetterPT.SelectedValue = thisRow["lettertreatmenttemplate_last_letter_pt_id"].ToString();
            }

            DropDownList ddlLastLetterWhenReplacingEPC = (DropDownList)e.Row.FindControl("ddlLastLetterWhenReplacingEPC");
            if (ddlLastLetterWhenReplacingEPC != null)
            {
                ddlLastLetterWhenReplacingEPC.DataSource     = letters;
                ddlLastLetterWhenReplacingEPC.DataTextField  = "letter_docname";
                ddlLastLetterWhenReplacingEPC.DataValueField = "letter_letter_id";
                ddlLastLetterWhenReplacingEPC.DataBind();
                ddlLastLetterWhenReplacingEPC.SelectedValue = thisRow["lettertreatmenttemplate_last_letter_when_replacing_epc_id"].ToString();
            }


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            if (fields.Rows.Count == 0)
            {
                if (GrdTreatmentTemplateLetters.FooterRow != null)
                {
                    GrdTreatmentTemplateLetters.FooterRow.Visible = false;
                }
                hideFotter = true;
            }
            else
            {
                DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlNewField");
                ddlField.DataSource     = fields;
                ddlField.DataTextField  = "descr";
                ddlField.DataValueField = "field_id";
                ddlField.DataBind();

                DropDownList ddlFirstLetter = (DropDownList)e.Row.FindControl("ddlNewFirstLetter");
                ddlFirstLetter.DataSource     = letters;
                ddlFirstLetter.DataTextField  = "letter_docname";
                ddlFirstLetter.DataValueField = "letter_letter_id";
                ddlFirstLetter.DataBind();

                DropDownList ddlTreatmentNoteLetter = (DropDownList)e.Row.FindControl("ddlNewTreatmentNoteLetter");
                ddlTreatmentNoteLetter.DataSource     = letters;
                ddlTreatmentNoteLetter.DataTextField  = "letter_docname";
                ddlTreatmentNoteLetter.DataValueField = "letter_letter_id";
                ddlTreatmentNoteLetter.DataBind();

                DropDownList ddlLastLetter = (DropDownList)e.Row.FindControl("ddlNewLastLetter");
                ddlLastLetter.DataSource     = letters;
                ddlLastLetter.DataTextField  = "letter_docname";
                ddlLastLetter.DataValueField = "letter_letter_id";
                ddlLastLetter.DataBind();

                DropDownList ddlLastLetterPT = (DropDownList)e.Row.FindControl("ddlNewLastLetterPT");
                ddlLastLetterPT.DataSource     = letters;
                ddlLastLetterPT.DataTextField  = "letter_docname";
                ddlLastLetterPT.DataValueField = "letter_letter_id";
                ddlLastLetterPT.DataBind();

                DropDownList ddlLastLetterWhenReplacingEPC = (DropDownList)e.Row.FindControl("ddlNewLastLetterWhenReplacingEPC");
                ddlLastLetterWhenReplacingEPC.DataSource     = letters;
                ddlLastLetterWhenReplacingEPC.DataTextField  = "letter_docname";
                ddlLastLetterWhenReplacingEPC.DataValueField = "letter_letter_id";
                ddlLastLetterWhenReplacingEPC.DataBind();
            }
        }
    }