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 + "'));"; } }