コード例 #1
0
ファイル: ViewUtilityRate.cs プロジェクト: mchuang/PUB
        private void saveRates()
        {
            basicRates = new List<CommonTools.CustomerCharge>();
            tierRates = new List<CommonTools.Tier>();

            surcharges = new List<CommonTools.Surcharge>();
            foreach (DataGridViewRow row in basicRateDataGridView.Rows) {
                if (row.IsNewRow) continue;
                char serviceType= '1';
                switch (row.Cells["Service Type"].Value.ToString())
                {
                    case "Minimum Rate":
                        serviceType = '0';
                        break;
                    case "All Service Rate":
                        serviceType = '1';
                        break;
                    case "Cooking Only Rate":
                        serviceType = '2';
                        break;
                    case "Space Heater Only Rate":
                        serviceType = '3';
                        break;
                    default:
                        serviceType = 'W';
                        break;
                }
                CommonTools.CustomerCharge rate = new CommonTools.CustomerCharge(row.Cells["Tenant Type"].Value.ToString(), serviceType, Convert.ToDecimal(row.Cells["Rate"].Value));
                basicRates.Add(rate);
            }

            foreach (DataGridViewRow row in surchargeDataGridView1.Rows) {
                if (row.IsNewRow) continue;
                int usage = 1;
                char chargeType = ' ';
                switch (row.Cells["Usage"].Value.ToString())
                {
                    case "Flat Credit/Charge":
                        usage = 1;
                        break;
                    case "By Usage":
                        usage = 2;
                        break;
                    case "By Days":
                        usage = 3;
                        break;
                    case "By Percentage":
                        usage = 4 ;
                        break;
                    default:
                        break;
                }
                switch (row.Cells["Charge Type"].Value.ToString()) {
                    case "Generation":
                        chargeType = 'G';
                        break;
                    case "Delivery":
                        chargeType = 'D';
                        break;
                    default:
                        break;
                }
                CommonTools.Surcharge surcharge = new CommonTools.Surcharge(row.Cells["Surcharge"].Value.ToString(), row.Cells["Tenant Type"].Value.ToString(),
                    chargeType, usage, Convert.ToDecimal(row.Cells["Rate"].Value));
                surcharges.Add(surcharge);
            }

            foreach (DataGridViewRow row in tierRateDataGridView1.Rows) {
                if (row.IsNewRow) continue;
                char chargeType = ' ';
                switch (row.Cells["Charge Type"].Value.ToString()) {
                    case "Generation":
                        chargeType = 'G';
                        break;
                    case "Delivery":
                        chargeType = 'D';
                        break;
                    default:
                        break;
                }
                CommonTools.Tier tier = new CommonTools.Tier(chargeType, row.Cells["Tenant Type"].Value.ToString());
                tier.setTier(1, Convert.ToDecimal(row.Cells["Tier1"].Value));
                tier.setTier(2, Convert.ToDecimal(row.Cells["Tier2"].Value));
                tier.setTier(3, Convert.ToDecimal(row.Cells["Tier3"].Value));
                tier.setTier(4, Convert.ToDecimal(row.Cells["Tier4"].Value));
                tier.setTier(5, Convert.ToDecimal(row.Cells["Tier5"].Value));
                tierRates.Add(tier);
            }

            switch (this.form.Text) {
                case "UtilityElectricity":
                    ((UtilityElectricity0)this.form).custCharges = basicRates;
                    ((UtilityElectricity0)this.form).tiers = tierRates;
                    ((UtilityElectricity0)this.form).surcharges = surcharges;
                    break;
                case "UtilityGas":
                    ((UtilityGas0)this.form).custCharges = basicRates;
                    ((UtilityGas0)this.form).tiers = tierRates;
                    ((UtilityGas0)this.form).surcharges = surcharges;
                    break;
                case "UtilityWater":
                    ((UtilityWater)this.form).custCharges = basicRates;
                    ((UtilityWater)this.form).tiers = tierRates;
                    ((UtilityWater)this.form).surcharges = surcharges;
                    break;
            }
        }
コード例 #2
0
ファイル: UtilityWater.cs プロジェクト: mchuang/PUB
 private void saveTierBtn_Click(object sender, EventArgs e)
 {
     if (tierStatus.Text == "") { MessageBox.Show("Please enter a label for tier set."); return; }
     CommonTools.Tier tierSet = new CommonTools.Tier('G', tierStatus.Text);
     for (int i = 1; i <= 5; i++) {
         try { tierSet.setTier(i, Convert.ToDecimal(tierRatesInput.GetControlFromPosition(i, 0).Text)); } catch { MessageBox.Show("Please enter valid tier rate."); return; }
     }
     tiers.RemoveAll(set => set.Equals(tierSet));
     tiers.Add(tierSet);
     statusBox();
 }
コード例 #3
0
ファイル: UtilityElectricity0.cs プロジェクト: mchuang/PUB
 private void saveGenBtn_Click(object sender, EventArgs e)
 {
     if (generationTierStatus.Text == "") { MessageBox.Show("Please enter a status for tier set."); return; }
     CommonTools.Tier tierSet = new CommonTools.Tier('G', generationTierStatus.Text);
     for (int i = 1; i <= 5; i++) {
         try { tierSet.setTier(i, Convert.ToDecimal(generationRatesInput.GetControlFromPosition(i, 0).Text)); }
         catch { MessageBox.Show("Please enter valid tier rate."); return; }
     }
     tiers.RemoveAll(item => item.Equals(tierSet));
     tiers.Add(tierSet);
     storeremoveG.Text = generationTierStatus.Text + " stored";
     statusBox();
 }
コード例 #4
0
ファイル: UtilityWater.cs プロジェクト: mchuang/PUB
 private void importWaterRates(int utilRateId)
 {
     tiers = new List<CommonTools.Tier>();
     String[] fields = { "RateType", "Rate1", "Rate2", "Rate3" };
     String condition = "UtilityRateID=@value0 AND ChargeType=@value1";
     List<Object[]> tierSets = DatabaseControl.getMultipleRecord(fields, DatabaseControl.utilTierRatesTable, condition, new Object[] { utilRateId, 'G' });
     foreach (Object[] set in tierSets) {
         CommonTools.Tier temp = new CommonTools.Tier('G',  set[0].ToString());
         for (int i = 1; i <= 3; i++) { temp.setTier(i, (decimal)set[i]); }
         tiers.Add(temp);
         if (!tierStatus.Items.Contains(set[0].ToString())) { tierStatus.Items.Add(set[0].ToString()); }
         if (!statusSurcharge.Items.Contains(set[0].ToString())) { statusSurcharge.Items.Add(set[0].ToString()); }
         if (!statusCustCharge.Items.Contains(set[0].ToString())) { statusCustCharge.Items.Add(set[0].ToString()); }
     }
 }
コード例 #5
0
ファイル: UtilityElectricity0.cs プロジェクト: mchuang/PUB
 private void importTiers(int utilRateId)
 {
     tiers = new List<CommonTools.Tier>();
     String[] fields = { "ChargeType", "RateType", "Rate1", "Rate2", "Rate3", "Rate4", "Rate5" };
     String condition = "UtilityRateID=@value0";
     List<Object[]> tierSets = DatabaseControl.getMultipleRecord(fields, DatabaseControl.utilTierRatesTable, condition, new Object[] { utilRateId });
     foreach (Object[] set in tierSets) {
         CommonTools.Tier temp = new CommonTools.Tier(Convert.ToChar(set[0]), set[1].ToString());
         for (int i = 1; i <= 5; i++) { temp.setTier(i, (decimal)set[i + 1]); }
         tiers.Add(temp);
     }
 }