public TariffPlan SelectTariffPlan(string planName) { string query = string.Format("SELECT callfirstblock, callfirstblockprice, callsubseqblock, callsubseqblockprice, smsfirstblock, smsfirstblockprice, smssubseqblock, smssubseqblockprice, gprsfirstblock, gprsfirstblockprice, gprssubseqblock, gprssubseqblockprice FROM tariffplan WHERE tariffplan_name='{0}'", planName); TariffPlan tariffPlan = new TariffPlan(planName); TariffPlan.Interval firstCall = new TariffPlan.Interval(); TariffPlan.Interval subseqCall = new TariffPlan.Interval(); TariffPlan.Interval firstSMS = new TariffPlan.Interval(); TariffPlan.Interval subseqSMS = new TariffPlan.Interval(); TariffPlan.Interval firstGPRS = new TariffPlan.Interval(); TariffPlan.Interval subseqGPRS = new TariffPlan.Interval(); if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { firstCall.chargeableBlock = (long)dataReader["callfirstblock"]; firstCall.Price = (double)dataReader["callfirstblockprice"]; subseqCall.chargeableBlock = (long)dataReader["callsubseqblock"]; subseqCall.Price = (double)dataReader["callsubseqblockprice"]; firstSMS.chargeableBlock = (long)dataReader["smsfirstblock"]; firstSMS.Price = (double)dataReader["smsfirstblockprice"]; subseqSMS.chargeableBlock = (long)dataReader["smssubseqblock"]; subseqSMS.Price = (double)dataReader["smssubseqblockprice"]; firstGPRS.chargeableBlock = (long)dataReader["gprsfirstblock"]; firstGPRS.Price = (double)dataReader["gprsfirstblockprice"]; subseqGPRS.chargeableBlock = (long)dataReader["gprssubseqblock"]; subseqGPRS.Price = (double)dataReader["gprssubseqblockprice"]; } dataReader.Close(); this.CloseConnection(); } tariffPlan.SetTariffPlanParam("firstCallInterval", firstCall); tariffPlan.SetTariffPlanParam("subseqCallInterval", subseqCall); tariffPlan.SetTariffPlanParam("firstSMSInterval", firstSMS); tariffPlan.SetTariffPlanParam("subseqSMSInterval", subseqSMS); tariffPlan.SetTariffPlanParam("firstGPRSInterval", firstGPRS); tariffPlan.SetTariffPlanParam("subseqGPRSInterval", subseqGPRS); return tariffPlan; }
private void OnAddTariffPlan_Click(object sender, RoutedEventArgs e) { TariffPlan currentPlan = new TariffPlan(this.TariffPlanName.Text); TariffPlan.Interval firstCall = new TariffPlan.Interval(); TariffPlan.Interval subseqCall = new TariffPlan.Interval(); firstCall.chargeableBlock = long.Parse(this.firstCallIntervalBlock.Text); firstCall.Price = double.Parse(this.firstCallIntervalPrice.Text); subseqCall.chargeableBlock = long.Parse(this.subseqCallIntervalBlock.Text); subseqCall.Price = double.Parse(this.subseqCallIntervalPrice.Text); TariffPlan.Interval firstSMS = new TariffPlan.Interval(); TariffPlan.Interval subseqSMS = new TariffPlan.Interval(); firstSMS.chargeableBlock = long.Parse(this.firstSMSIntervalBlock.Text); firstSMS.Price = double.Parse(this.firstSMSIntervalPrice.Text); subseqSMS.chargeableBlock = long.Parse(this.subseqSMSIntervalBlock.Text); subseqSMS.Price = double.Parse(this.subseqSMSIntervalPrice.Text); TariffPlan.Interval firstGPRS = new TariffPlan.Interval(); TariffPlan.Interval subseqGPRS = new TariffPlan.Interval(); firstGPRS.chargeableBlock = long.Parse(this.firstGPRSIntervalBlock.Text); firstGPRS.Price = double.Parse(this.firstGPRSIntervalPrice.Text); subseqGPRS.chargeableBlock = long.Parse(this.subseqGPRSIntervalBlock.Text); subseqGPRS.Price = double.Parse(this.subseqGPRSIntervalPrice.Text); currentPlan.SetTariffPlanParam("firstCallInterval", firstCall); currentPlan.SetTariffPlanParam("subseqCallInterval", subseqCall); currentPlan.SetTariffPlanParam("firstSMSInterval", firstSMS); currentPlan.SetTariffPlanParam("subseqSMSInterval", subseqSMS); currentPlan.SetTariffPlanParam("firstGPRSInterval", firstGPRS); currentPlan.SetTariffPlanParam("subseqGPRSInterval", subseqGPRS); TariffPlan.AddTariffPlan(currentPlan); billingSystemDB.InsertTariffPlan(currentPlan); TariffPlanAllTextBoxInit(sender, e); }