Esempio n. 1
0
    protected void btnUpdateNotificationInfo_Click(object sender, EventArgs e)
    {
        string amountREGEX = @"^\d+(\.\d{1,2})?$";

        txtSMSCreditNotificationEmailAddress.Text = txtSMSCreditNotificationEmailAddress.Text.Trim();

        if ((chkSMSCreditOutOfBalance_SendEmail.Checked || chkSMSCreditLowBalance_SendEmail.Checked) && !Utilities.IsValidEmailAddress(txtSMSCreditNotificationEmailAddress.Text))
        {
            SetErrorMessage("Invalid email address");
            return;
        }

        txtSMSCreditLowBalance_Threshold.Text = txtSMSCreditLowBalance_Threshold.Text.Trim();
        if (txtSMSCreditLowBalance_Threshold.Text.Length == 0)
        {
            txtSMSCreditLowBalance_Threshold.Text = "0";
        }
        if (!Regex.IsMatch(txtSMSCreditLowBalance_Threshold.Text, amountREGEX))
        {
            SetErrorMessage("Low Balance Warning Threshold can only be numbers and optional decimal place with 1 or 2 digits following.");
            return;
        }

        SystemVariableDB.Update("SMSCreditNotificationEmailAddress", txtSMSCreditNotificationEmailAddress.Text);
        SystemVariableDB.Update("SMSCreditLowBalance_Threshold", Convert.ToDouble(txtSMSCreditLowBalance_Threshold.Text).ToString("0.00"));
        SystemVariableDB.Update("SMSCreditOutOfBalance_SendEmail", chkSMSCreditOutOfBalance_SendEmail.Checked ? "1" : "0");
        SystemVariableDB.Update("SMSCreditLowBalance_SendEmail", chkSMSCreditLowBalance_SendEmail.Checked ? "1" : "0");
    }
    protected void SetLastDateBatchSendTreatmentNotesAllReferrers(DateTime dateTime)
    {
        string val = dateTime == DateTime.MinValue ? "" : dateTime.ToString("HH:mm:ss dd-MM-yyyy");

        SystemVariableDB.Update("LastDateBatchSendTreatmentNotesAllReferrers", val);
        GUI_SetBatchSendElements();
    }
Esempio n. 3
0
    protected void btnMaxNbrProvidersUpdate_Click(object sender, EventArgs e)
    {
        if (!txtValidateMaxNbrProvidersRequired.IsValid || !txtValidateMaxNbrProvidersRegex.IsValid)
        {
            return;
        }

        SystemVariableDB.Update("MaxNbrProviders", txtMaxNbrProviders.Text);
        SetMaxNbrProvidersTextBox(false);
    }
Esempio n. 4
0
    protected void btnSMSPriceUpdate_Click(object sender, EventArgs e)
    {
        if (!txtValidateSMSPriceRequired.IsValid || !txtValidateSMSPriceRegex.IsValid)
        {
            return;
        }

        SystemVariableDB.Update("SMSPrice", txtSMSPrice.Text);
        SetSMSPriceTextBox(false);
    }
    protected void btnUpdateNotificationInfo_Click(object sender, EventArgs e)
    {
        txtStockWarningLevelNotificationEmailAddress.Text = txtStockWarningLevelNotificationEmailAddress.Text.Trim();

        if (txtStockWarningLevelNotificationEmailAddress.Text.Length > 0 && !Utilities.IsValidEmailAddress(txtStockWarningLevelNotificationEmailAddress.Text))
        {
            SetErrorMessage("Invalid email address. It must be blank or a valid email address.");
            return;
        }

        SystemVariableDB.Update("StockWarningNotificationEmailAddress", txtStockWarningLevelNotificationEmailAddress.Text);
    }
    protected void btnUpdateNotificationInfo_Click(object sender, EventArgs e)
    {
        txtEmailAddress.Text = txtEmailAddress.Text.Trim();

        try
        {
            if (txtEmailAddress.Text.Length > 0 && !Utilities.IsValidEmailAddress(txtEmailAddress.Text))
            {
                throw new CustomMessageException("Invalid email address");
            }
        }
        catch (CustomMessageException ex)
        {
            SetErrorMessage(ex.Message);
            return;
        }

        SystemVariableDB.Update("ServiceSpecificBookingReminderLettersToBatch_EmailAddress", txtEmailAddress.Text);

        SetNotificationInfo(); // re-set to show it was update in the db
    }
Esempio n. 7
0
    protected void btnUpdateNotificationInfo_Click(object sender, EventArgs e)
    {
        txtEmailAddress.Text = txtEmailAddress.Text.Trim();

        try
        {
            if (chkEnableEmails.Checked && txtEmailAddress.Text.Length == 0)
            {
                throw new CustomMessageException("To enable this, please set an email address");
            }

            txtEmailAddress.Text = Utilities.CleanEmailAddresses(txtEmailAddress.Text);
            if (txtEmailAddress.Text.Length > 0 && !Utilities.IsValidEmailAddresses(txtEmailAddress.Text, false))
            {
                throw new CustomMessageException("Invalid email address");
            }

            if (select_sites_row_auto.Attributes["class"] != "hiddencol" && !chkIncAgedCareAuto.Checked && !chkIncClinicsAuto.Checked)
            {
                throw new CustomMessageException("Plese check to generate for Clinics and/or Aged Care");
            }

            if (rdioSendTypeAuto.SelectedValue != "Print" && rdioSendTypeAuto.SelectedValue != "Email")
            {
                throw new ArgumentException("Please select a send method of Email or Print");
            }

            if (chkEnableEmails.Checked &&
                (!chkSendMondays.Checked &&
                 !chkSendTuesdays.Checked &&
                 !chkSendWednesdays.Checked &&
                 !chkSendThursdays.Checked &&
                 !chkSendFridays.Checked &&
                 !chkSendSaturdays.Checked &&
                 !chkSendSundays.Checked))
            {
                throw new CustomMessageException("To enable this, please set at least one day to send");
            }
        }
        catch (CustomMessageException ex)
        {
            SetErrorMessage(ex.Message, "", lblErrorMessageAutoSending);
            return;
        }


        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendEmail", chkEnableEmails.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_EmailAddress", txtEmailAddress.Text);

        if (select_sites_row_auto.Attributes["class"] != "hiddencol")
        {
            SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_IncClinic", chkIncClinicsAuto.Checked ? "1" : "0");
            SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_IncAgedCare", chkIncAgedCareAuto.Checked ? "1" : "0");
        }

        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_IncUnsent", chkIncUnsentAuto.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_IncBatched", chkIncBatchedAuto.Checked ? "1" : "0");

        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendMethod", rdioSendTypeAuto.SelectedValue);

        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendMondays", chkSendMondays.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendTuesdays", chkSendTuesdays.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendWednesdays", chkSendWednesdays.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendThursdays", chkSendThursdays.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendFridays", chkSendFridays.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendSaturdays", chkSendSaturdays.Checked ? "1" : "0");
        SystemVariableDB.Update("ReferrerEPCAutoGenerateLettersEmail_SendSundays", chkSendSundays.Checked ? "1" : "0");

        SetNotificationInfo(); // re-set to show it was update in the db
    }
Esempio n. 8
0
    protected void Button4_Click(object sender, EventArgs e)
    {
        // need to be able to have them put in their own field instead of physio/podiatry ....


/*
 * select * from UserDatabaseMapper order by id desc
 * delete UserDatabaseMapper where dbname in ('Mediclinic_0002','Mediclinic_0003','Mediclinic_0004','Mediclinic_0005')
 */

        // also need to not import field type phys/pod ....


        try
        {
            decimal decNum;
            int     intNum;

            if (txtInitialStaffFirstname.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Staff Firstname is a required field.");
            }
            if (txtInitialStaffSurname.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Staff Surname is a required field.");
            }
            if (txtInitialStaffLogin.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Staff Login is a required field.");
            }
            if (txtMedicareEclaimsLicenseNbr.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Medicare Eclaims License Nbr is a required field.");
            }
            if (!Decimal.TryParse(txtSMSPrice.Text.Trim(), out decNum))
            {
                throw new CustomMessageException("SMS Price must be a decimal.");
            }
            if (!Int32.TryParse(txtMaxNbrProviders.Text.Trim(), out intNum))
            {
                throw new CustomMessageException("Max Nbr Providers must be a number.");
            }
            if (txtSiteName.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Clinic Site Name is a required field.");
            }
            if (txtEmail_FromName.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Email Sending From Name is a required field.");
            }
            if (!Utilities.IsValidEmailAddress(txtEmail_FromEmail.Text.Trim()))
            {
                throw new CustomMessageException("Email Sending From Email must be a valid email address.");
            }
            if (!Utilities.IsValidEmailAddress(txtAdminAlertEmail_To.Text.Trim()))
            {
                throw new CustomMessageException("Admin Alert Email must be a valid email address.");
            }
            if (txtField1.Text.Trim().Length == 0)
            {
                throw new CustomMessageException("Field 1 is a required field.");
            }
        }
        catch (CustomMessageException ex)
        {
            Label4.Text = "<font color=\"red\"><br>" + ex.Message + "</b></font>";
            return;
        }



        string initialStaffFirstname = txtInitialStaffFirstname.Text.Trim();
        string initialStaffSurname   = txtInitialStaffSurname.Text.Trim();
        string initialStaffLogin     = GetUniqueLogin(txtInitialStaffLogin.Text.Trim().ToLower());


        //
        // clone the DB with new name
        //

        string newDBName = GetNewDBName();

        CloneDB("Mediclinic_StubDB", "Mediclinic_StubDB_log", newDBName);


        //
        // update any config items
        //

        SystemVariableDB.Update("MedicareEclaimsLicenseNbr", txtMedicareEclaimsLicenseNbr.Text.Trim(), newDBName);
        SystemVariableDB.Update("SMSPrice", txtSMSPrice.Text.Trim(), newDBName);
        SystemVariableDB.Update("MaxNbrProviders", txtMaxNbrProviders.Text.Trim(), newDBName);
        SystemVariableDB.Update("AllowAddSiteClinic", ddlAllowAddSiteClinic.SelectedValue, newDBName);
        SystemVariableDB.Update("AllowAddSiteAgedCare", ddlAllowAddSiteAgedCare.SelectedValue, newDBName);
        SystemVariableDB.Update("BannerMessage", txtBannerMessage.Text.Trim(), newDBName);
        SystemVariableDB.Update("ShowBannerMessage", ddlShowBannerMessage.SelectedValue, newDBName);
        SystemVariableDB.Update("Email_FromName", txtEmail_FromName.Text, newDBName);
        SystemVariableDB.Update("Email_FromEmail", txtEmail_FromEmail.Text.Trim(), newDBName);
        SystemVariableDB.Update("AdminAlertEmail_To", txtAdminAlertEmail_To.Text.Trim(), newDBName);



        //
        // update login/pwd for first staff memeber and for support staff
        //

        string sql_update_staff = @"

            UPDATE Person
            SET 
                Person.firstname = '" + initialStaffFirstname + @"'  
               ,Person.surname   = '" + initialStaffSurname + @"'  
            FROM Person
            JOIN Staff ON Person.person_id = Staff.person_id
            WHERE Staff.staff_id = 1;


            UPDATE Staff SET login = '******'         WHERE staff_id = 1;
            UPDATE Staff SET pwd   = '" + initialStaffLogin + @"'         WHERE staff_id = 1;

            UPDATE Staff SET login = '******'   WHERE staff_id = -2;
            UPDATE Staff SET login = '******'   WHERE staff_id = -3;
            UPDATE Staff SET login = '******'   WHERE staff_id = -4;
        ";

        if (txtField1.Text.Trim().Length > 0)
        {
            sql_update_staff += @"INSERT Field (descr, has_offerings) VALUES ('" + txtField1.Text.Trim() + @"' , 1);" + Environment.NewLine;
        }
        if (txtField2.Text.Trim().Length > 0)
        {
            sql_update_staff += @"INSERT Field (descr, has_offerings) VALUES ('" + txtField2.Text.Trim() + @"' , 1);" + Environment.NewLine;
        }

        sql_update_staff += @"UPDATE Site SET name = '" + txtSiteName.Text.Trim() + @"' WHERE site_type_id = 1;" + Environment.NewLine;


        DBBase.ExecuteNonResult(sql_update_staff, newDBName);

        UserDatabaseMapperDB.Insert(initialStaffLogin, newDBName);
        UserDatabaseMapperDB.Insert(newDBName + "_support1", newDBName);
        UserDatabaseMapperDB.Insert(newDBName + "_support2", newDBName);
        UserDatabaseMapperDB.Insert(newDBName + "_support3", newDBName);


        Label4.Text =
            @"Database created successfully.<br />
<table border=""0"" cellpadding=""0"" cellspacing=""0"">
<tr>
    <td>Database : </td>
    <td style=""width:20px;""></td>
    <td><b>" + newDBName + @"</b></td>
</tr>
<tr>
    <td>Staff Username & Password : </td>
    <td></td>
    <td><b>" + initialStaffLogin + @"</b></td>
</tr>
</table>";
    }
Esempio n. 9
0
    protected void btnUpdateNotificationInfo_Click(object sender, EventArgs e)
    {
        txtEmailAddress.Text = txtEmailAddress.Text.Trim();


        try
        {
            if (chkEnableEmails.Checked && txtEmailAddress.Text.Length == 0)
            {
                throw new CustomMessageException("To enable this, please set an email address");
            }

            txtEmailAddress.Text = Utilities.CleanEmailAddresses(txtEmailAddress.Text);
            if (txtEmailAddress.Text.Length > 0 && !Utilities.IsValidEmailAddresses(txtEmailAddress.Text, false))
            {
                throw new CustomMessageException("Invalid email address");
            }

            if (Convert.ToInt32(ddlFromDaysAheadMondays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadMondays.SelectedValue))
            {
                throw new CustomMessageException("Monday: From Days Ahead can not be more than Until Days Ahead");
            }
            if (Convert.ToInt32(ddlFromDaysAheadTuesdays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadTuesdays.SelectedValue))
            {
                throw new CustomMessageException("Tuesday: From Days Ahead can not be more than Until Days Ahead");
            }
            if (Convert.ToInt32(ddlFromDaysAheadWednesdays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadWednesdays.SelectedValue))
            {
                throw new CustomMessageException("Wednesday: From Days Ahead can not be more than Until Days Ahead");
            }
            if (Convert.ToInt32(ddlFromDaysAheadThursdays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadThursdays.SelectedValue))
            {
                throw new CustomMessageException("Thursday: From Days Ahead can not be more than Until Days Ahead");
            }
            if (Convert.ToInt32(ddlFromDaysAheadFridays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadFridays.SelectedValue))
            {
                throw new CustomMessageException("Friday: From Days Ahead can not be more than Until Days Ahead");
            }
            if (Convert.ToInt32(ddlFromDaysAheadSaturdays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadSaturdays.SelectedValue))
            {
                throw new CustomMessageException("Saturday: From Days Ahead can not be more than Until Days Ahead");
            }
            if (Convert.ToInt32(ddlFromDaysAheadSundays.SelectedValue) > Convert.ToInt32(ddlUntilDaysAheadSundays.SelectedValue))
            {
                throw new CustomMessageException("Sunday: From Days Ahead can not be more than Until Days Ahead");
            }
        }
        catch (CustomMessageException ex)
        {
            SetErrorMessage(ex.Message);
            return;
        }


        SystemVariableDB.Update("BirthdayNotificationEmail_SendEmail", chkEnableEmails.Checked ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_EmailAddress", txtEmailAddress.Text);

        SystemVariableDB.Update("BirthdayNotificationEmail_IncPatientsWithMobile", chkIncPatientsWithMobile.Checked ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_IncPatientsWithEmail", chkIncPatientsWithEmail.Checked ? "1" : "0");

        SystemVariableDB.Update("BirthdayNotificationEmail_SendMondays", chkSendMondays.Checked    ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_SendTuesdays", chkSendTuesdays.Checked   ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_SendWednesdays", chkSendWednesdays.Checked ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_SendThursdays", chkSendThursdays.Checked  ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFridays", chkSendFridays.Checked    ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_SendSaturdays", chkSendSaturdays.Checked  ? "1" : "0");
        SystemVariableDB.Update("BirthdayNotificationEmail_SendSundays", chkSendSundays.Checked    ? "1" : "0");

        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Mondays", ddlFromDaysAheadMondays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Mondays", ddlUntilDaysAheadMondays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Tuesdays", ddlFromDaysAheadTuesdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Tuesdays", ddlUntilDaysAheadTuesdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Wednesdays", ddlFromDaysAheadWednesdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Wednesdays", ddlUntilDaysAheadWednesdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Thursdays", ddlFromDaysAheadThursdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Thursdays", ddlUntilDaysAheadThursdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Fridays", ddlFromDaysAheadFridays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Fridays", ddlUntilDaysAheadFridays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Saturdays", ddlFromDaysAheadSaturdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Saturdays", ddlUntilDaysAheadSaturdays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendFromDaysAhead_Sundays", ddlFromDaysAheadSundays.SelectedValue);
        SystemVariableDB.Update("BirthdayNotificationEmail_SendUntilDaysAhead_Sundays", ddlUntilDaysAheadSundays.SelectedValue);

        SetNotificationInfo(); // re-set to show it was update in the db
    }
    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();
        }
    }