protected void GrdOffering_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblId = (Label)GrdOffering.Rows[e.RowIndex].FindControl("lblId"); try { OfferingDB.UpdateInactive(Convert.ToInt32(lblId.Text)); } 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 GrdOffering_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { TextBox txtName = (TextBox)GrdOffering.FooterRow.FindControl("txtNewName"); TextBox txtShortName = (TextBox)GrdOffering.FooterRow.FindControl("txtNewShortName"); TextBox txtDescr = (TextBox)GrdOffering.FooterRow.FindControl("txtNewDescr"); DropDownList ddlOfferingType = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewOfferingType"); DropDownList ddlField = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewField"); DropDownList ddlOfferingPatientSubcategory = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewOfferingPatientSubcategory"); DropDownList ddlNumClinicVisitsAllowedPerYear = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewNumClinicVisitsAllowedPerYear"); DropDownList ddlOfferingInvoiceType = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewOfferingInvoiceType"); CheckBox chkIsGstExempt = (CheckBox)GrdOffering.FooterRow.FindControl("chkNewIsGstExempt"); TextBox txtDefaultPrice = (TextBox)GrdOffering.FooterRow.FindControl("txtNewDefaultPrice"); DropDownList ddlServiceTimeMinutes = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewServiceTimeMinutes"); DropDownList ddlMaxNbrClaimable = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewMaxNbrClaimable"); DropDownList ddlMaxNbrClaimableMonths = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewMaxNbrClaimableMonths"); TextBox txtMedicareCompanyCode = (TextBox)GrdOffering.FooterRow.FindControl("txtNewMedicareCompanyCode"); TextBox txtDvaCompanyCode = (TextBox)GrdOffering.FooterRow.FindControl("txtNewDvaCompanyCode"); TextBox txtTacCompanyCode = (TextBox)GrdOffering.FooterRow.FindControl("txtNewTacCompanyCode"); TextBox txtMedicareCharge = (TextBox)GrdOffering.FooterRow.FindControl("txtNewMedicareCharge"); TextBox txtDvaCharge = (TextBox)GrdOffering.FooterRow.FindControl("txtNewDvaCharge"); TextBox txtTacCharge = (TextBox)GrdOffering.FooterRow.FindControl("txtNewTacCharge"); DropDownList ddlReminderLetterMonthsLaterToSend = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewReminderLetterMonthsLaterToSend"); DropDownList ddlReminderLetter = (DropDownList)GrdOffering.FooterRow.FindControl("ddlNewReminderLetter"); CheckBox chkUseCustomColour = (CheckBox)GrdOffering.FooterRow.FindControl("chkNewUseCustomColour"); System.Web.UI.HtmlControls.HtmlInputText ColorPicker = (System.Web.UI.HtmlControls.HtmlInputText)GrdOffering.FooterRow.FindControl("NewColorPicker"); if (Convert.ToInt32(ddlReminderLetterMonthsLaterToSend.SelectedValue) > 0 && Convert.ToInt32(ddlReminderLetter.SelectedValue) == -1) { SetErrorMessage("For reminder letters - you must either set the number of months as disabled or select a reminder letter."); return; } // if logged not AC system, set AC patient subcat as 1 (--Not Aged Care--) // if logged not Clinic system, set clinic visit type as -1 (--Not Clinic--) // these are hidden in the gui also in method 'GrdOffering_RowCreated' int offeringPatientSubcategoryID = !UserView.GetInstance().IsAgedCareView ? 1 : Convert.ToInt32(ddlOfferingPatientSubcategory.SelectedValue); OfferingDB.Insert(Convert.ToInt32(ddlOfferingType.SelectedValue), Convert.ToInt32(ddlField.SelectedValue), offeringPatientSubcategoryID, Convert.ToInt32(ddlNumClinicVisitsAllowedPerYear.SelectedValue), Convert.ToInt32(ddlOfferingInvoiceType.SelectedValue), txtName.Text, txtShortName.Text, txtDescr.Text, chkIsGstExempt.Checked, Convert.ToDecimal(txtDefaultPrice.Text), Convert.ToInt32(ddlServiceTimeMinutes.Text), Convert.ToInt32(ddlMaxNbrClaimable.SelectedValue), Convert.ToInt32(ddlMaxNbrClaimableMonths.SelectedValue), txtMedicareCompanyCode.Text.Trim(), txtDvaCompanyCode.Text.Trim(), txtTacCompanyCode.Text.Trim(), Convert.ToDecimal(txtMedicareCharge.Text), Convert.ToDecimal(txtDvaCharge.Text), Convert.ToDecimal(txtTacCharge.Text), "", Convert.ToInt32(ddlReminderLetterMonthsLaterToSend.SelectedValue), Convert.ToInt32(ddlReminderLetter.SelectedValue), chkUseCustomColour.Checked, ColorPicker.Value ); Session["OfferingColors"] = OfferingDB.GetColorCodes(); FillGrid(); } if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete")) { int offering_id = Convert.ToInt32(e.CommandArgument); try { if (e.CommandName.Equals("_Delete")) { OfferingDB.UpdateInactive(offering_id); } else { OfferingDB.UpdateActive(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(); } if (e.CommandName.Equals("SetAsBookingScreenDefaultService")) { int offering_id = Convert.ToInt32(e.CommandArgument); SystemVariableDB.Update("BookingScreenDefaultServiceID", offering_id.ToString()); FillGrid(); } }