protected void GrdStaffOfferings_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label    lblId                = (Label)GrdStaffOfferings.Rows[e.RowIndex].FindControl("lblId");
        CheckBox chkIsCommission      = (CheckBox)GrdStaffOfferings.Rows[e.RowIndex].FindControl("chkIsCommission");
        TextBox  txtCommissionPercent = (TextBox)GrdStaffOfferings.Rows[e.RowIndex].FindControl("txtCommissionPercent");
        CheckBox chkIsFixedRate       = (CheckBox)GrdStaffOfferings.Rows[e.RowIndex].FindControl("chkIsFixedRate");
        TextBox  txtFixedRate         = (TextBox)GrdStaffOfferings.Rows[e.RowIndex].FindControl("txtFixedRate");
        TextBox  txtActiveDate        = (TextBox)GrdStaffOfferings.Rows[e.RowIndex].FindControl("txtActiveDate");

        if (chkIsCommission.Checked && chkIsFixedRate.Checked)
        {
            SetErrorMessage("Can not be both comission and fixed rate. Please select only one.");
            return;
        }

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

        DataRow[]      foundRows      = dt.Select("so_staff_offering_id=" + lblId.Text);
        StaffOfferings staffOfferings = StaffOfferingsDB.LoadAll(foundRows[0]);

        StaffOfferingsDB.Update(staffOfferings.StaffOfferingID, staffOfferings.Staff.StaffID, staffOfferings.Offering.OfferingID,
                                chkIsCommission.Checked, Convert.ToDecimal(txtCommissionPercent.Text), chkIsFixedRate.Checked, Convert.ToDecimal(txtFixedRate.Text),
                                GetDate(txtActiveDate.Text));

        GrdStaffOfferings.EditIndex = -1;
        FillGrid();
    }
Exemple #2
0
    public static StaffOfferings[] GetAll(bool only_active)
    {
        DataTable tbl = GetDataTable(only_active);

        StaffOfferings[] staffOfferings = new StaffOfferings[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            staffOfferings[i] = LoadAll(tbl.Rows[i]);
        }
        return(staffOfferings);
    }
Exemple #3
0
    // returns 2d hashtable
    // get by:  hash[new Hashtable2D.Key(staffID, offeringID)]
    public static System.Collections.Hashtable Get2DHash(bool only_active, int staff_id = -1)
    {
        DataTable tbl = staff_id == -1 ? GetDataTable(only_active) : GetDataTableByStaffID(staff_id, only_active);

        System.Collections.Hashtable hash = new System.Collections.Hashtable();
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            StaffOfferings staffOffering = LoadAll(tbl.Rows[i]);
            hash[new Hashtable2D.Key(staffOffering.Staff.StaffID, staffOffering.Offering.OfferingID)] = staffOffering;
        }

        return(hash);
    }
Exemple #4
0
    public static StaffOfferings LoadAll(DataRow row)
    {
        StaffOfferings so = Load(row, "so_");

        so.Offering = OfferingDB.Load(row, "o_");
        so.Offering.OfferingType        = IDandDescrDB.Load(row, "type_offering_type_id", "type_descr");
        so.Offering.Field               = IDandDescrDB.Load(row, "fld_field_id", "fld_descr");
        so.Offering.AgedCarePatientType = IDandDescrDB.Load(row, "acpatientcat_aged_care_patient_type_id", "acpatientcat_descr");
        so.Offering.OfferingInvoiceType = IDandDescrDB.Load(row, "invtype_offering_invoice_type_id", "invtype_descr");

        so.Staff               = StaffDB.Load(row, "staff_");
        so.Staff.Person        = PersonDB.Load(row, "person_");
        so.Staff.Person.Title  = IDandDescrDB.Load(row, "title_title_id", "title_descr");
        so.Staff.Field         = IDandDescrDB.Load(row, "field_field_id", "field_descr");
        so.Staff.StaffPosition = StaffPositionDB.Load(row, "staff_position_");
        so.Staff.CostCentre    = CostCentreDB.Load(row, "cost_centre_");

        return(so);
    }
Exemple #5
0
    protected void FillGrid()
    {
        UserView userView = UserView.GetInstance();

        DateTime fromDate = IsValidDate(txtStartDate.Text) ? GetDate(txtStartDate.Text)                              : DateTime.MinValue;
        DateTime toDate   = IsValidDate(txtEndDate.Text)   ? GetDate(txtEndDate.Text).Add(new TimeSpan(23, 59, 59))  : DateTime.MinValue;


        int organisation_type_group_id = -1;

        if (userView.IsClinicView)
        {
            organisation_type_group_id = 5;
        }
        if (userView.IsAgedCareView)
        {
            organisation_type_group_id = 6;
        }

        DataTable dt = null;

        if (rblDateType.SelectedValue == "Bookings")
        {
            dt = BookingDB.GetReport_InvoiceLines(fromDate, toDate, DateTime.MinValue, DateTime.MinValue, Convert.ToInt32(ddlOrgs.SelectedValue), Convert.ToInt32(ddlProviders.SelectedValue), Convert.ToInt32(ddlOfferings.SelectedValue), organisation_type_group_id);
        }
        else if (rblDateType.SelectedValue == "Invoices")
        {
            dt = BookingDB.GetReport_InvoiceLines(DateTime.MinValue, DateTime.MinValue, fromDate, toDate, Convert.ToInt32(ddlOrgs.SelectedValue), Convert.ToInt32(ddlProviders.SelectedValue), Convert.ToInt32(ddlOfferings.SelectedValue), organisation_type_group_id);
        }
        else
        {
            SetErrorMessage("Please select date range to be treatment date or invoice date.");
            return;
        }



        dt.Columns.Add("booking_duration_total_minutes", typeof(string));
        dt.Columns.Add("organisation_name", typeof(string));
        dt.Columns.Add("patient_id", typeof(int));
        dt.Columns.Add("patient_firstname", typeof(string));
        dt.Columns.Add("patient_surname", typeof(string));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["booking_id"] == DBNull.Value)
            {
                dt.Rows[i]["booking_duration_total_minutes"] = "";
                dt.Rows[i]["organisation_name"] = dt.Rows[i]["non_booking_organisation_name"];
                dt.Rows[i]["patient_id"]        = dt.Rows[i]["non_booking_patient_id"];
                dt.Rows[i]["patient_firstname"] = dt.Rows[i]["non_booking_patient_firstname"];
                dt.Rows[i]["patient_surname"]   = dt.Rows[i]["non_booking_patient_surname"];
            }
            else
            {
                DateTime bookingStart = Convert.ToDateTime(dt.Rows[i]["booking_date_start"]);
                DateTime bookingEnd   = Convert.ToDateTime(dt.Rows[i]["booking_date_end"]);
                dt.Rows[i]["booking_duration_total_minutes"] = bookingEnd.Subtract(bookingStart).TotalMinutes.ToString();
                dt.Rows[i]["organisation_name"] = dt.Rows[i]["booking_organisation_name"];
                dt.Rows[i]["patient_id"]        = dt.Rows[i]["booking_patient_id"];
                dt.Rows[i]["patient_firstname"] = dt.Rows[i]["booking_patient_firstname"];
                dt.Rows[i]["patient_surname"]   = dt.Rows[i]["booking_patient_surname"];
            }
        }


        Hashtable staffOfferingHash = StaffOfferingsDB.Get2DHash(true, Convert.ToInt32(ddlProviders.SelectedValue));

        dt.Columns.Add("commission_percent_text", typeof(string));
        dt.Columns.Add("fixed_rate_text", typeof(string));
        dt.Columns.Add("commission_percent_amount", typeof(decimal));
        dt.Columns.Add("fixed_rate_amount", typeof(decimal));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["booking_id"] == DBNull.Value)
            {
                dt.Rows[i]["commission_percent_text"]   = "";
                dt.Rows[i]["fixed_rate_text"]           = "";
                dt.Rows[i]["commission_percent_amount"] = 0;
                dt.Rows[i]["fixed_rate_amount"]         = 0;
            }
            else
            {
                StaffOfferings staffOffering = (StaffOfferings)staffOfferingHash[new Hashtable2D.Key(Convert.ToInt32(dt.Rows[i]["provider_staff_id"]), dt.Rows[i]["offering_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["offering_id"]))];
                //dt.Rows[i]["commission_percent_text"]   = staffOffering == null || !staffOffering.IsCommission ? "" : Math.Round(staffOffering.CommissionPercent * Convert.ToDecimal(dt.Rows[i]["invoice_line_price"]) / 100, 2).ToString() + " (" + staffOffering.CommissionPercent + "%)";
                dt.Rows[i]["commission_percent_text"]   = staffOffering == null || !staffOffering.IsCommission ? "" : Math.Round(staffOffering.CommissionPercent * Convert.ToDecimal(dt.Rows[i]["invoice_line_price"]) / 100, 2).ToString();
                dt.Rows[i]["fixed_rate_text"]           = staffOffering == null || !staffOffering.IsFixedRate  ? "" : staffOffering.FixedRate.ToString();
                dt.Rows[i]["commission_percent_amount"] = staffOffering == null || !staffOffering.IsCommission ? Convert.ToDecimal(0.00) : Math.Round(staffOffering.CommissionPercent * Convert.ToDecimal(dt.Rows[i]["invoice_line_price"]) / 100, 2);
                dt.Rows[i]["fixed_rate_amount"]         = staffOffering == null || !staffOffering.IsFixedRate  ? Convert.ToDecimal(0.00) : staffOffering.FixedRate;
            }
        }



        Session["data_summaryReport"] = dt;

        if (!IsPostBack)
        {
            chkUsePaging.Checked = dt.Rows.Count > 50;
        }

        this.GrdSummaryReport.AllowPaging = chkUsePaging.Checked;

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


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

            int TotalColumns = GrdSummaryReport.Rows[0].Cells.Count;
            GrdSummaryReport.Rows[0].Cells.Clear();
            GrdSummaryReport.Rows[0].Cells.Add(new TableCell());
            GrdSummaryReport.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdSummaryReport.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemple #6
0
 public static StaffOfferings[] GetAll(bool only_active)
 {
     DataTable tbl = GetDataTable(only_active);
     StaffOfferings[] staffOfferings = new StaffOfferings[tbl.Rows.Count];
     for (int i = 0; i < tbl.Rows.Count; i++)
          staffOfferings[i] = LoadAll(tbl.Rows[i]);
     return staffOfferings;
 }