Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
 private void importSurcharges(int utilRateId)
 {
     surcharges = new List<CommonTools.Surcharge>();
     String[] fields = { "Description", "RateType", "ChargeType", "Usage", "Rate" };
     String condition = "UtilityRateID=@value0";
     List<Object[]> surchargeItems = DatabaseControl.getMultipleRecord(fields, DatabaseControl.utilSurchargeTable, condition, new Object[] { utilRateId });
     foreach (Object[] item in surchargeItems) {
         CommonTools.Surcharge temp = new CommonTools.Surcharge(item[0].ToString(), item[1].ToString(), Convert.ToChar(item[2]), (int)item[3], Convert.ToDecimal(item[4]));
         surcharges.Add(temp);
         descSurcharge.Items.Add(item[0].ToString());
         if (!statusSurcharge.Items.Contains(item[1].ToString())) { statusSurcharge.Items.Add(item[1].ToString()); }
         if (!statusCustCharge.Items.Contains(item[1].ToString()) && item[1].ToString() != "All") { statusCustCharge.Items.Add(item[1].ToString()); }
         if (!tierStatus.Items.Contains(item[1].ToString()) && item[1].ToString() != "All") { tierStatus.Items.Add(item[1].ToString()); }
     }
 }
Ejemplo n.º 3
0
        private void saveSurBtn_Click(object sender, EventArgs e)
        {
            if (descSurcharge.Text == "") { MessageBox.Show("Please enter a label for surcharge."); return; }
            if (statusSurcharge.Text == "") { MessageBox.Show("Please enter a status for surcharge."); return; }
            if (usageSurcharge.Text == "") { MessageBox.Show("Please select a usage for surcharge."); return; }

            try {
                CommonTools.Surcharge surcharge = new CommonTools.Surcharge(descSurcharge.Text, statusSurcharge.Text, 'G',((CommonTools.Item)usageSurcharge.SelectedItem).Value, Convert.ToDecimal(rateSurcharge.Text));
                surcharges.RemoveAll(item => item.Equals(surcharge));
                surcharges.Add(surcharge);
                if (!descSurcharge.Items.Contains(descSurcharge.Text)) { descSurcharge.Items.Add(descSurcharge.Text); }
                statusBox();
            } catch {
                MessageBox.Show("Enter a valid rate.");
                return;
            }
        }
Ejemplo n.º 4
0
        private void saveSurBtn_Click(object sender, EventArgs e)
        {
            if (descSurcharge.Text == "") { MessageBox.Show("Please enter a label for surcharge."); return; }
            if (statusSurcharge.Text == "") { MessageBox.Show("Please enter a status for surcharge."); return; }
            if (usageSurcharge.Text == "") { MessageBox.Show("Please select a usage for surcharge."); return; }
            if (chargeSurcharge.Text == "") { chargeSurcharge.Text = " "; }
            CommonTools.Surcharge surcharge;
            try {
                surcharge = new CommonTools.Surcharge(descSurcharge.Text, statusSurcharge.Text, Convert.ToChar(chargeSurcharge.Text), ((CommonTools.Item)usageSurcharge.SelectedItem).Value, Convert.ToDecimal(rateSurcharge.Text));
            } catch {
                storeremoveS.Text = "Fail! Try again.";
                return;
            }

            surcharges.RemoveAll(item => item.Equals(surcharge));
            surcharges.Add(surcharge);
            if (!descSurcharge.Items.Contains(descSurcharge.Text)) { descSurcharge.Items.Add(descSurcharge.Text); }
            statusBox();
            storeremoveS.Text = String.Format("{0}:{1}:{2} stored", descSurcharge.Text, statusSurcharge.Text, usageSurcharge.Text);
        }