private void NewRowManual(ref PcDiscountRow ARow) { string DiscountCriteriaCode = "CHILD"; string CostType = "CONFERENCE"; string Validity = "ALWAYS"; int NewAge = 0; // starts at 0 years int i = 0; // if PK already exists, find the next available while (FMainDS.PcDiscount.Rows.Find(new object[] { FPartnerKey, DiscountCriteriaCode, CostType, Validity, NewAge + i }) != null) { if (CostType == "CONFERENCE") { CostType = "ACCOMMODATION"; } else { CostType = "CONFERENCE"; i++; } } NewAge += i; // set default values for new row ARow.DiscountCriteriaCode = DiscountCriteriaCode; ARow.CostTypeCode = CostType; ARow.Validity = Validity; ARow.UpToAge = NewAge; ARow.Percentage = true; ARow.Discount = 0; // set the conference key ARow.ConferenceKey = FPartnerKey; }
// enables or disables the combo box depending on the availability of the two Cost Type Codes for selected UpToAge private void EnableOrDisableCmb(PcDiscountRow ARow) { if (ARow.CostTypeCode == "CONFERENCE") { if (FMainDS.PcDiscount.Rows.Find(new object[] { FPartnerKey, ARow.DiscountCriteriaCode, "ACCOMMODATION", ARow.Validity, ARow.UpToAge }) != null) { cmbDetailCostTypeCode.Enabled = false; } else { cmbDetailCostTypeCode.Enabled = true; } } else if (ARow.CostTypeCode == "ACCOMMODATION") { if (FMainDS.PcDiscount.Rows.Find(new object[] { FPartnerKey, ARow.DiscountCriteriaCode, "CONFERENCE", ARow.Validity, ARow.UpToAge }) != null) { cmbDetailCostTypeCode.Enabled = false; } else { cmbDetailCostTypeCode.Enabled = true; } } }
private void UpdateCostTypeCode(object sender, EventArgs e) { PcDiscountRow ARow = GetSelectedDetailRow(); // if txtDetailUpToDate has just been changed for a row, select available Cost Type Code (if any) // and enable or diable cmb as appropriate if (sender.Equals(txtDetailUpToAge) && (txtDetailUpToAge.NumberValueInt != ARow.UpToAge)) { if (FMainDS.PcDiscount.Rows.Find(new object[] { FPartnerKey, ARow.DiscountCriteriaCode, "ACCOMMODATION", ARow.Validity, txtDetailUpToAge.NumberValueInt }) != null) { cmbDetailCostTypeCode.SelectedItem = "CONFERENCE"; cmbDetailCostTypeCode.Enabled = false; } else if (FMainDS.PcDiscount.Rows.Find(new object[] { FPartnerKey, ARow.DiscountCriteriaCode, "CONFERENCE", ARow.Validity, txtDetailUpToAge.NumberValueInt }) != null) { cmbDetailCostTypeCode.SelectedItem = "ACCOMMODATION"; cmbDetailCostTypeCode.Enabled = false; } else { cmbDetailCostTypeCode.Enabled = true; } } }
private void ShowDetailsManual(PcDiscountRow ARow) { // converts the numeric value in table to int if (ARow != null) { if (ARow.IsDiscountNull()) { txtDetailDiscount.NumberValueInt = null; } else { txtDetailDiscount.NumberValueInt = Convert.ToInt32(ARow.Discount); } EnableOrDisableCmb(ARow); } }
private void ValidateDataDetailsManual(PcDiscountRow ARow) { if (txtDetailDiscount.Text == "") { ARow.Discount = 0; } // check that default data exists in database TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TValidationControlsData ValidationControlsData; TScreenVerificationResult VerificationResult = null; DataColumn ValidationColumn; if (ARow.RowState != DataRowState.Deleted) { if (!TRemote.MConference.Conference.WebConnectors.CheckDiscountCriteriaCodeExists(new string[] { ARow.DiscountCriteriaCode })) { ValidationColumn = ARow.Table.Columns[PcDiscountTable.ColumnDiscountCriteriaCodeId]; // displays a warning message VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo( PetraErrorCodes.ERR_DISCOUNT_CRITERIA_CODE_DOES_NOT_EXIST)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } if (!TRemote.MConference.Conference.WebConnectors.CheckCostTypeExists(ARow.CostTypeCode)) { ValidationColumn = ARow.Table.Columns[PcDiscountTable.ColumnCostTypeCodeId]; // displays a warning message VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo( PetraErrorCodes.ERR_COST_TYPE_CODE_DOES_NOT_EXIST)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } EnableOrDisableCmb(ARow); }
/// <summary> /// Get the child discount for /// </summary> /// <param name="AAge">age of the person</param> /// <param name="AConferenceKey">conference key</param> /// <param name="ACostType">Defines the type of discount (e.g. ACCOMMODATION or CONFERENCE)</param> /// <param name="ADiscount">discount the person gets</param> /// <param name="AInPercent">Type of discaount: True - discount is in percent. False - discount is the amount</param> /// <param name="ASituation">The current report situation</param> /// <returns></returns> public static bool GetChildDiscount(int AAge, long AConferenceKey, String ACostType, out decimal ADiscount, out bool AInPercent, ref TRptSituation ASituation) { ADiscount = 0.0M; AInPercent = false; PcDiscountTable DiscountTable; PcDiscountTable TmpTable = new PcDiscountTable(); PcDiscountRow TemplateRow = TmpTable.NewRowTyped(false); TemplateRow.ConferenceKey = AConferenceKey; TemplateRow.CostTypeCode = ACostType; TemplateRow.DiscountCriteriaCode = "CHILD"; TemplateRow.Validity = "ALWAYS"; StringCollection OrderList = new StringCollection(); OrderList.Add(" ORDER BY " + PcDiscountTable.GetUpToAgeDBName() + " ASC"); DiscountTable = PcDiscountAccess.LoadUsingTemplate(TemplateRow, null, null, ASituation.GetDatabaseConnection().Transaction, OrderList, 0, 0); foreach (PcDiscountRow DiscountRow in DiscountTable.Rows) { if ((!DiscountRow.IsUpToAgeNull()) && (DiscountRow.UpToAge >= AAge)) { ADiscount = DiscountRow.Discount; AInPercent = DiscountRow.Percentage; return(true); } } return(false); }
// get data from screen and ammend/add to dataset private void GetDataFromControlsManual(PcConferenceRow ARow) { PcConferenceRow ConferenceData = (PcConferenceRow)FMainDS.PcConference.Rows[0]; PPartnerLocationRow PartnerLocationData = (PPartnerLocationRow)FMainDS.PPartnerLocation.Rows[0]; PUnitRow UnitData = (PUnitRow)FMainDS.PUnit.Rows[0]; // do not save currency if it is blank but instead change the combo box to display original value if (cmbCurrency.GetSelectedString() != "") { ConferenceData.CurrencyCode = cmbCurrency.GetSelectedString(); UnitData.OutreachCostCurrencyCode = cmbCurrency.GetSelectedString(); } else { cmbCurrency.SetSelectedString(ConferenceData.CurrencyCode); } ConferenceData.Start = dtpStartDate.Date; ConferenceData.End = dtpEndDate.Date; PartnerLocationData.DateEffective = dtpStartDate.Date; PartnerLocationData.DateGoodUntil = dtpEndDate.Date; // get data from radio buttons and check button for PcConferenceOption string[] OptionTypeCodes = { "COST_PER_NIGHT", "COST_PER_DAY", "ADD_ACCOMM_COST_FOR_TOTAL" }; Boolean[] OptionSet = { rbtNight.Checked, rbtDay.Checked, chkAddAccommodationCosts.Checked }; for (int i = 0; i < 3; i++) { DataRow RowExists = FMainDS.PcConferenceOption.Rows.Find(new object[] { FPartnerKey, OptionTypeCodes[i] }); // create new row if needed if ((RowExists == null) && OptionSet[i]) { PcConferenceOptionRow RowToAdd = FMainDS.PcConferenceOption.NewRowTyped(true); RowToAdd.ConferenceKey = FPartnerKey; RowToAdd.OptionTypeCode = OptionTypeCodes[i]; RowToAdd.OptionSet = true; FMainDS.PcConferenceOption.Rows.Add(RowToAdd); } // update existing record else if ((RowExists != null) && OptionSet[i]) { ((PcConferenceOptionRow)RowExists).OptionSet = true; } // delete existing record if discount is 0 else if ((RowExists != null) && !OptionSet[i]) { RowExists.Delete(); } } // reset the Accommodation text boxs to 0 if no longer needed if (!chkAddAccommodationCosts.Checked) { txtSpecialRolePreAccommodation.NumberValueInt = 0; txtVolunteerPreAccommodation.NumberValueInt = 0; txtParticipantPreAccommodation.NumberValueInt = 0; txtSpecialRoleAccommodation.NumberValueInt = 0; txtVolunteerAccommodation.NumberValueInt = 0; txtSpecialRoleCampaignAccommodation.NumberValueInt = 0; } // get data from discount text boxes for PcDiscount string[, ] Discounts = { { "ROLE", "CONFERENCE", "PRE", txtSpecialRolePreAttendance.Text.TrimEnd(new char[] { ' ', '%' }) }, { "VOL", "CONFERENCE", "PRE", txtVolunteerPreAttendance.Text.TrimEnd(new char[] { ' ', '%' }) }, { "OTHER", "CONFERENCE", "PRE", txtParticipantPreAttendance.Text.TrimEnd(new char[] { ' ', '%' }) }, { "ROLE", "CONFERENCE", "CONF", txtSpecialRoleAttendance.Text.TrimEnd(new char[] { ' ', '%' }) }, { "VOL", "CONFERENCE", "CONF", txtVolunteerAttendance.Text.TrimEnd(new char[] { ' ', '%' }) }, { "ROLE", "CONFERENCE", "POST", txtSpecialRoleCampaignAttendance.Text.TrimEnd(new char[] { ' ', '%' }) }, { "ROLE", "ACCOMMODATION", "PRE", txtSpecialRolePreAccommodation.Text.TrimEnd(new char[] { ' ', '%' }) }, { "VOL", "ACCOMMODATION", "PRE", txtVolunteerPreAccommodation.Text.TrimEnd(new char[] { ' ', '%' }) }, { "OTHER", "ACCOMMODATION", "PRE", txtParticipantPreAccommodation.Text.TrimEnd(new char[] { ' ', '%' }) }, { "ROLE", "ACCOMMODATION", "CONF", txtSpecialRoleAccommodation.Text.TrimEnd(new char[] { ' ', '%' }) }, { "VOL", "ACCOMMODATION", "CONF", txtVolunteerAccommodation.Text.TrimEnd(new char[] { ' ', '%' }) }, { "ROLE", "ACCOMMODATION", "POST", txtSpecialRoleCampaignAccommodation.Text.TrimEnd(new char[] { ' ', '%' }) } }; for (int i = 0; i < 12; i++) { DataRow RowExists = FMainDS.PcDiscount.Rows.Find(new object[] { FPartnerKey, Discounts[i, 0], Discounts[i, 1], Discounts[i, 2], -1 }); if (Discounts[i, 3] == "") { Discounts[i, 3] = "0"; } // create new row if needed if ((RowExists == null) && (Convert.ToInt32(Discounts[i, 3]) != 0)) { PcDiscountRow RowToAdd = FMainDS.PcDiscount.NewRowTyped(true); RowToAdd.ConferenceKey = FPartnerKey; RowToAdd.DiscountCriteriaCode = Discounts[i, 0]; RowToAdd.CostTypeCode = Discounts[i, 1]; RowToAdd.Validity = Discounts[i, 2]; RowToAdd.UpToAge = -1; RowToAdd.Percentage = true; RowToAdd.Discount = Convert.ToInt32(Discounts[i, 3]); FMainDS.PcDiscount.Rows.Add(RowToAdd); } // update existing record else if ((RowExists != null) && (Convert.ToInt32(Discounts[i, 3]) != 0)) { ((PcDiscountRow)RowExists).Discount = Convert.ToInt32(Discounts[i, 3]); } // delete existing record if discount is 0 else if ((RowExists != null) && (Convert.ToInt32(Discounts[i, 3]) == 0)) { RowExists.Delete(); } } }