protected void GrdStaffOfferings_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { CustomValidator txtValidateNewActiveDate = (CustomValidator)GrdStaffOfferings.FooterRow.FindControl("txtValidateNewActiveDate"); if (!txtValidateNewActiveDate.IsValid) { return; } DropDownList ddlStaff = (DropDownList)GrdStaffOfferings.FooterRow.FindControl("ddlNewStaff"); DropDownList ddlOffering = (DropDownList)GrdStaffOfferings.FooterRow.FindControl("ddlNewOffering"); CheckBox chkIsCommission = (CheckBox)GrdStaffOfferings.FooterRow.FindControl("chkNewIsCommission"); TextBox txtCommissionPercent = (TextBox)GrdStaffOfferings.FooterRow.FindControl("txtNewCommissionPercent"); CheckBox chkIsFixedRate = (CheckBox)GrdStaffOfferings.FooterRow.FindControl("chkNewIsFixedRate"); TextBox txtFixedRate = (TextBox)GrdStaffOfferings.FooterRow.FindControl("txtNewFixedRate"); TextBox txtActiveDate = (TextBox)GrdStaffOfferings.FooterRow.FindControl("txtNewActiveDate"); if (chkIsCommission.Checked && chkIsFixedRate.Checked) { SetErrorMessage("Can not be both comission and fixed rate. Please select only one."); return; } int staff_id = IsValidFormStaffID() ? GetFormStaffID() : Convert.ToInt32(ddlStaff.SelectedValue); StaffOfferingsDB.Insert(staff_id, Convert.ToInt32(ddlOffering.SelectedValue), chkIsCommission.Checked, Convert.ToDecimal(txtCommissionPercent.Text), chkIsFixedRate.Checked, Convert.ToDecimal(txtFixedRate.Text), GetDate(txtActiveDate.Text)); FillGrid(); } }
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(); }
protected void FillGrid() { //DataTable dt = IsValidFormStaffID() ? StaffOfferingsDB.GetDataTableByStaffID(GetFormStaffID(), false) : StaffOfferingsDB.GetDataTable(false); DataTable dt = StaffOfferingsDB.GetDataTable(false, IsValidFormStaffID() ? GetFormStaffID() : -1, IsValidFormOfferingID() ? GetFormOfferingID() : -1); dt.Columns.Add("is_active", typeof(bool)); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["is_active"] = dt.Rows[i]["so_date_active"] == DBNull.Value || Convert.ToDateTime(dt.Rows[i]["so_date_active"]).Date > DateTime.Today ? false : true; } Session["staff_offerings_data"] = dt; this.GrdStaffOfferings.AllowPaging = dt.Rows.Count > 50; if (dt.Rows.Count > 0) { if (IsPostBack && Session["staff_offerngs_sortexpression"] != null && Session["staff_offerngs_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["staff_offerngs_sortexpression"].ToString(); GrdStaffOfferings.DataSource = dataView; } else { GrdStaffOfferings.DataSource = dt; } try { GrdStaffOfferings.DataBind(); GrdStaffOfferings.PagerSettings.FirstPageText = "1"; GrdStaffOfferings.PagerSettings.LastPageText = GrdStaffOfferings.PageCount.ToString(); GrdStaffOfferings.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdStaffOfferings.DataSource = dt; GrdStaffOfferings.DataBind(); int TotalColumns = GrdStaffOfferings.Rows[0].Cells.Count; GrdStaffOfferings.Rows[0].Cells.Clear(); GrdStaffOfferings.Rows[0].Cells.Add(new TableCell()); GrdStaffOfferings.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdStaffOfferings.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (chkNewIsCommission.Checked && chkNewIsFixedRate.Checked) { SetErrorMessage("Can not be both comission and fixed rate. Please select only one."); return; } StaffOfferingsDB.UpdateBulk(Convert.ToInt32(ddlNewStaff.SelectedValue), Convert.ToInt32(ddlNewOffering.SelectedValue), chkNewIsCommission.Checked, Convert.ToDecimal(txtNewCommissionPercent.Text), chkNewIsFixedRate.Checked, Convert.ToDecimal(txtNewFixedRate.Text), GetDate(txtNewActiveDate.Text)); SetErrorMessage("Updated."); }
public static int Insert(int offering_type_id, int field_id, int aged_care_patient_type_id, int num_clinic_visits_allowed_per_year, int offering_invoice_type_id, string name, string short_name, string descr, bool is_gst_exempt, decimal default_price, int service_time_minutes, int max_nbr_claimable, int max_nbr_claimable_months, string medicare_company_code, string dva_company_code, string tac_company_code, decimal medicare_charge, decimal dva_charge, decimal tac_charge, string popup_message, int reminder_letter_months_later_to_send, int reminder_letter_id, bool use_custom_color, string custom_color) { name = name.Replace("'", "''"); short_name = short_name.Replace("'", "''"); descr = descr.Replace("'", "''"); medicare_company_code = medicare_company_code.Replace("'", "''"); dva_company_code = dva_company_code.Replace("'", "''"); tac_company_code = tac_company_code.Replace("'", "''"); popup_message = popup_message.Replace("'", "''"); custom_color = custom_color.Replace("'", "''"); string sql = "INSERT INTO Offering (offering_type_id,field_id,aged_care_patient_type_id,num_clinic_visits_allowed_per_year,offering_invoice_type_id,name,short_name,descr,is_gst_exempt,default_price,service_time_minutes,max_nbr_claimable,max_nbr_claimable_months,medicare_company_code,dva_company_code,tac_company_code,medicare_charge,dva_charge,tac_charge,popup_message,reminder_letter_months_later_to_send,reminder_letter_id, use_custom_color,custom_color) VALUES (" + "" + offering_type_id + "," + "" + field_id + "," + "" + aged_care_patient_type_id + "," + "" + num_clinic_visits_allowed_per_year + "," + "" + offering_invoice_type_id + "," + "'" + name + "'," + "'" + short_name + "'," + "'" + descr + "'," + (is_gst_exempt ? "1," : "0,") + "" + default_price + "," + "" + service_time_minutes + "," + max_nbr_claimable + "," + max_nbr_claimable_months + ",'" + medicare_company_code + "'," + "'" + dva_company_code + "'," + "'" + tac_company_code + "'," + "" + medicare_charge + "," + "" + dva_charge + "," + "" + tac_charge + "," + "'" + popup_message + "'" + "," + reminder_letter_months_later_to_send + "," + (reminder_letter_id == -1 ? "NULL" : reminder_letter_id.ToString()) + "," + (use_custom_color ? "1" : "0") + ",'" + custom_color + "');SELECT SCOPE_IDENTITY();"; int offering_id = Convert.ToInt32(DBBase.ExecuteSingleResult(sql)); StaffOfferingsDB.InsertBulkByOfferingID(offering_id, false, 0, false, 0, DateTime.Today); return(offering_id); }
public static int Insert(int person_id, string login, string pwd, int staff_position_id, int field_id, int costcentre_id, bool is_contractor, string tfn, string provider_number, bool is_fired, bool is_commission, decimal commission_percent, bool is_stakeholder, bool is_master_admin, bool is_admin, bool is_principal, bool is_provider, bool is_external, DateTime start_date, DateTime end_date, string comment, bool enable_daily_reminder_sms, bool enable_daily_reminder_email, bool hide_booking_notes) { login = login.Replace("'", "''"); pwd = pwd.Replace("'", "''"); tfn = tfn.Replace("'", "''"); provider_number = provider_number.Replace("'", "''"); comment = comment.Replace("'", "''"); if (LoginExists(login)) { throw new UniqueConstraintException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name); } string sql = "INSERT INTO Staff (person_id,login,pwd,staff_position_id,field_id,costcentre_id,is_contractor,tfn,provider_number,is_fired,is_commission,commission_percent,is_stakeholder,is_master_admin,is_admin,is_principal,is_provider,is_external,start_date,end_date,comment,enable_daily_reminder_sms,enable_daily_reminder_email,hide_booking_notes) VALUES (" + "" + person_id + "," + "'" + login + "'," + "'" + pwd + "'," + "" + staff_position_id + "," + "" + field_id + "," + "" + costcentre_id + "," + (is_contractor ? "1," : "0,") + "'" + tfn + "'," + "UPPER('" + provider_number + "')," + (is_fired ? "1," : "0,") + (is_commission ? "1," : "0,") + "" + commission_percent + "," + (is_stakeholder ? "1," : "0,") + (is_master_admin ? "1," : "0,") + (is_admin ? "1," : "0,") + (is_principal ? "1," : "0,") + (is_provider ? "1," : "0,") + (is_external ? "1," : "0,") + (start_date == DateTime.MinValue ? "null" : "'" + start_date.ToString("yyyy-MM-dd HH:mm:ss") + "'") + "," + (end_date == DateTime.MinValue ? "null" : "'" + end_date.ToString("yyyy-MM-dd HH:mm:ss") + "'") + "," + "'" + comment + "'," + (enable_daily_reminder_sms ? "1" : "0") + "," + (enable_daily_reminder_email ? "1" : "0") + "," + (hide_booking_notes ? "1" : "0") + ");SELECT SCOPE_IDENTITY();"; int staff_id = Convert.ToInt32(DBBase.ExecuteSingleResult(sql)); StaffOfferingsDB.InsertBulkByStaffID(staff_id, false, 0, false, 0, DateTime.Today); return(staff_id); }
protected void GrdStaffOfferings_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblId = (Label)GrdStaffOfferings.Rows[e.RowIndex].FindControl("lblId"); int staff_offering_id = Convert.ToInt32(lblId.Text); try { StaffOfferingsDB.Delete(staff_offering_id); } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { SetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); }
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"; } }