private void btnOk_Click(object sender, EventArgs e) { TariffBase tf = null; if (this.rdTariffPerTime.Checked && CheckInputOfTariffPerTime()) { tf = GetTariffPerTimeFromInput(); } else if (this.rdTariffPerDay.Checked && CheckInputOfTariffPerDay()) { tf = GetTariffPerDayFromInput(); } else if (this.rdTariffOfTurning.Checked && CheckInputOfTariffOfMidNight()) { tf = GetTariffOfTurningFromInput(); } else if (this.rdTariffOfLimitation.Checked && CheckInputOfTariffOfLimitation()) { tf = GetTariffOfLimitationFromInput(); } else if (this.rdTariffOfGuanZhou.Checked && CheckInputOfTariffOfGuanZhou()) { tf = GetTariffOfGuanZhouFromInput(); } else if (this.rdTimezoneLimitation.Checked && CheckInputOfTariffOfTimezoneLimitation()) { tf = GetTariffOfTimezoneLimitationFromInput(); } if (tf != null) { this.SelectedTariff = tf; this.DialogResult = DialogResult.OK; this.Close(); } }
private void ShowTariff(TariffBase info) { if (info is TariffPerTime) { ShowTariff(info as TariffPerTime); } else if (info is TariffPerDay) { ShowTariff(info as TariffPerDay); } else if (info is TariffOfTurning) { ShowTariff(info as TariffOfTurning); } else if (info is TariffOfTurningLimited) { ShowTariff(info as TariffOfTurningLimited); } else if (info is TariffOfLimitation) { ShowTariff(info as TariffOfLimitation); } else if (info is TariffOfGuanZhou) { ShowTariff(info as TariffOfGuanZhou); } else if (info is TariffOfDixiakongjian) { ShowTariff(info as TariffOfDixiakongjian); } else if (info is TariffOfThreeTimeZone) { ShowTariff(info as TariffOfThreeTimeZone); } }
private void InitTariffGridRow(DataGridViewRow row, CardType cardType, CarType carType, TariffSetting ts) { TariffBase tariff = null; row.Cells["colCardType"].Value = cardType.Name; row.Cells["colCardType"].Tag = cardType.ID; row.Cells["colCarType"].Value = carType.Description; row.Cells["colCarType"].Tag = carType.ID; tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.Normal); row.Cells["colGeneral"].Value = (tariff != null) ? tariff.ToString() : "N/A"; row.Cells["colGeneral"].Tag = (tariff != null) ? tariff : null; tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.Holiday); row.Cells["colHoliday"].Value = (tariff != null) ? tariff.ToString() : "N/A"; row.Cells["colHoliday"].Tag = (tariff != null) ? tariff : null; tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.InnerRoom); row.Cells["colInnerRoom"].Value = (tariff != null) ? tariff.ToString() : "N/A"; row.Cells["colInnerRoom"].Tag = (tariff != null) ? tariff : null; tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.HolidayAndInnerRoom); row.Cells["colHolidayAndInnerRoom"].Value = (tariff != null) ? tariff.ToString() : "N/A"; row.Cells["colHolidayAndInnerRoom"].Tag = (tariff != null) ? tariff : null; }
private TariffSetting GetTariffSettingFromInput() { TariffSetting ts = TariffSetting.Current; if (ts.ParkTariffDictionary == null) { ts.ParkTariffDictionary = new Dictionary <int, List <TariffBase> >(); } if (!ts.ParkTariffDictionary.ContainsKey(ParkID)) { ts.ParkTariffDictionary.Add(ParkID, new List <TariffBase>()); } else { ts.ParkTariffDictionary[ParkID] = new List <TariffBase>(); } foreach (DataGridViewRow row in tariffGrid.Rows) { for (int i = 1; i < tariffGrid.Columns.Count; i++) { TariffBase tariff = row.Cells[i].Tag as TariffBase; if (tariff != null) { ts.ParkTariffDictionary[ParkID].Add(tariff); } } } return(ts); }
public List <Packet> CreateDownloadTariffSettingPacket(byte address, TariffSetting ts) { byte index = 19; List <Packet> packets = new List <Packet>(); Packet packet = FormatTariffOptions(ts.TariffOption); packets.Add(packet); for (int tariffType = 0; tariffType < 4; tariffType++) { for (int carType = 0; carType < 4; carType++) { index += (byte)(tariffType * 4 + carType); //普通收费 TariffBase tariff = ts.GetTariff(carType, (TariffType)tariffType); if (tariff != null) { packet = FormatTariff(tariff, index, ts.TariffOption); if (packet != null) { packets.Add(packet); } } } } return(packets); }
private Packet FormatTariff(TariffBase tariff, int index, TollOptionSetting tos) { if (tariff is TariffPerDay) { return(FormatTariffPerDay(tariff as TariffPerDay, index, tos)); } else if (tariff is TariffPerTime) { return(FormatTariffPerTime(tariff as TariffPerTime, index, tos)); } else if (tariff is TariffOfLimitation) { return(FormatTariffOfLimitation(tariff as TariffOfLimitation, index, tos)); } return(null); }
private void tariffGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex > 1) { FrmTariffSelection frm = new FrmTariffSelection(); if (tariffGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag != null) { frm.SelectedTariff = tariffGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag as TariffBase; } if (frm.ShowDialog() == DialogResult.OK) { TariffBase info = frm.SelectedTariff; info.CardType = Convert.ToByte(tariffGrid.Rows[e.RowIndex].Cells["colCardType"].Tag); info.CarType = Convert.ToByte(tariffGrid.Rows[e.RowIndex].Cells["colCarType"].Tag); if (tariffGrid.Columns[e.ColumnIndex].Tag is TariffType) { info.TariffType = (TariffType)tariffGrid.Columns[e.ColumnIndex].Tag; } tariffGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = info.ToString(); tariffGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag = info; } } }
private bool CheckTariffInput() { bool result = true; TariffBase defaultTariff = null; foreach (DataGridViewRow row in this.tariffGrid.Rows) { defaultTariff = null; TariffBase tempTariff = row.Cells["colGeneral"].Tag as TariffBase; if (tempTariff != null) { defaultTariff = tempTariff; } tempTariff = row.Cells["colHoliday"].Tag as TariffBase; if (tempTariff != null) { if (defaultTariff == null) { defaultTariff = tempTariff; } else if (tempTariff.GetType() != defaultTariff.GetType()) { result = false; row.Selected = true; break; } } tempTariff = row.Cells["colInnerRoom"].Tag as TariffBase; if (tempTariff != null) { if (defaultTariff == null) { defaultTariff = tempTariff; } else if (tempTariff.GetType() != defaultTariff.GetType()) { result = false; row.Selected = true; break; } } tempTariff = row.Cells["colHolidayAndInnerRoom"].Tag as TariffBase; if (tempTariff != null) { if (defaultTariff == null) { defaultTariff = tempTariff; } else if (tempTariff.GetType() != defaultTariff.GetType()) { result = false; row.Selected = true; break; } } } if (!result) { this.tariffGrid.Focus(); MessageBox.Show(Resources.Resource1.FrmSystemOption_SameTariff); } return(result); }