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); }
//work with Hashset public static TariffPlan FindTariffPlan(TariffPlan planToFind) { if (Tariff.Table1.Contains(planToFind)) { foreach (var tariffPlan in Tariff.Table1) { if (tariffPlan == planToFind) return tariffPlan; } } else throw new BillingArgExc(string.Format("You do not have Tariff Plan with data {0}", planToFind)); return new TariffPlan(null); }
//work with Hashset public static void DeleteTariffPlan(TariffPlan planToDelete) { try { if (Tariff.Table1.Contains(planToDelete)) Tariff.Table1.Remove(planToDelete); else throw new BillingArgExc(string.Format("You do not have Tariff Plan with data {0}", planToDelete)); } catch (BillingArgExc exc) { System.Windows.MessageBox.Show(exc.Message); } }
//work with Hashset public static void AddTariffPlan(TariffPlan planToAdd) { try { if (!Tariff.Table1.Contains(planToAdd)) Tariff.Table1.Add(planToAdd); else throw new BillingArgExc(string.Format("You have Tariff Plan with data {0}", planToAdd)); } catch (BillingArgExc exc) { System.Windows.MessageBox.Show(exc.Message); } }
public void UpdateTariffPlan(TariffPlan planToUpdate) { TariffPlan.Interval firstCall = planToUpdate.GetTariffPlanParam("firstCallInterval"); TariffPlan.Interval subseqCall = planToUpdate.GetTariffPlanParam("subseqCallInterval"); long firstCallIntervalBlock = firstCall.chargeableBlock; double firstCallIntervalPrice = firstCall.Price; long subseqCallIntervalBlock = subseqCall.chargeableBlock; double subseqCallIntervalPrice = subseqCall.Price; TariffPlan.Interval firstSMS = planToUpdate.GetTariffPlanParam("firstSMSInterval"); TariffPlan.Interval subseqSMS = planToUpdate.GetTariffPlanParam("subseqSMSInterval"); long firstSMSIntervalBlock = firstSMS.chargeableBlock; double firstSMSIntervalPrice = firstSMS.Price; long subseqSMSIntervalBlock = subseqSMS.chargeableBlock; double subseqSMSIntervalPrice = subseqSMS.Price; TariffPlan.Interval firstGPRS = planToUpdate.GetTariffPlanParam("firstGPRSInterval"); TariffPlan.Interval subseqGPRS = planToUpdate.GetTariffPlanParam("subseqGPRSInterval"); long firstGPRSIntervalBlock = firstGPRS.chargeableBlock; double firstGPRSIntervalPrice = firstGPRS.Price; long subseqGPRSIntervalBlock = subseqGPRS.chargeableBlock; double subseqGPRSIntervalPrice = subseqGPRS.Price; string query = string.Format("UPDATE tariffplan SET callfirstblock='{0}', callfirstblockprice='{1}', callsubseqblock='{2}', callsubseqblockprice='{3}', smsfirstblock='{4}', smsfirstblockprice='{5}', smssubseqblock='{6}', smssubseqblockprice='{7}', gprsfirstblock='{8}', gprsfirstblockprice='{9}', gprssubseqblock='{10}', gprssubseqblockprice='{11}' WHERE tariffplan_name='{12}'", firstCallIntervalBlock, firstCallIntervalPrice, subseqCallIntervalBlock, subseqCallIntervalPrice, firstSMSIntervalBlock, firstSMSIntervalPrice, subseqSMSIntervalBlock, subseqSMSIntervalPrice, firstGPRSIntervalBlock, firstGPRSIntervalPrice, subseqGPRSIntervalBlock, subseqGPRSIntervalPrice, planToUpdate.Name); if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = query; cmd.Connection = connection; cmd.ExecuteNonQuery(); this.CloseConnection(); } }
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; }
public void InsertTariffPlan(TariffPlan planToInsert) { TariffPlan.Interval firstCall = planToInsert.GetTariffPlanParam("firstCallInterval"); TariffPlan.Interval subseqCall = planToInsert.GetTariffPlanParam("subseqCallInterval"); long firstCallIntervalBlock = firstCall.chargeableBlock; double firstCallIntervalPrice = firstCall.Price; long subseqCallIntervalBlock = subseqCall.chargeableBlock; double subseqCallIntervalPrice = subseqCall.Price; TariffPlan.Interval firstSMS = planToInsert.GetTariffPlanParam("firstSMSInterval"); TariffPlan.Interval subseqSMS = planToInsert.GetTariffPlanParam("subseqSMSInterval"); long firstSMSIntervalBlock = firstSMS.chargeableBlock; double firstSMSIntervalPrice = firstSMS.Price; long subseqSMSIntervalBlock = subseqSMS.chargeableBlock; double subseqSMSIntervalPrice = subseqSMS.Price; TariffPlan.Interval firstGPRS = planToInsert.GetTariffPlanParam("firstGPRSInterval"); TariffPlan.Interval subseqGPRS = planToInsert.GetTariffPlanParam("subseqGPRSInterval"); long firstGPRSIntervalBlock = firstGPRS.chargeableBlock; double firstGPRSIntervalPrice = firstGPRS.Price; long subseqGPRSIntervalBlock = subseqGPRS.chargeableBlock; double subseqGPRSIntervalPrice = subseqGPRS.Price; string query = string.Format("INSERT INTO tariffplan (tariffplan_name, callfirstblock, callfirstblockprice, callsubseqblock, callsubseqblockprice, smsfirstblock, smsfirstblockprice, smssubseqblock, smssubseqblockprice, gprsfirstblock, gprsfirstblockprice, gprssubseqblock, gprssubseqblockprice) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", planToInsert.Name, firstCallIntervalBlock, firstCallIntervalPrice, subseqCallIntervalBlock, subseqCallIntervalPrice, firstSMSIntervalBlock, firstSMSIntervalPrice, subseqSMSIntervalBlock, subseqSMSIntervalPrice, firstGPRSIntervalBlock, firstGPRSIntervalPrice, subseqGPRSIntervalBlock, subseqGPRSIntervalPrice); if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); this.CloseConnection(); } }
public void DeleteTariffPlan(TariffPlan planToDelete) { string query = string.Format("DELETE FROM tariffplan WHERE tariffplan_name='{0}'", planToDelete.Name); if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); this.CloseConnection(); } }
private void OnSubscriberTariffPlanLoaded(object sender, EventArgs e) { this.SubscriberTariffPlan.Items.Clear(); this.SubscriberTariffPlan.IsEditable = true; //must be true to display .Text this.SubscriberTariffPlan.Text = "Please choose:"; //List<string> allTariffPlanNames = TariffPlan.GetTariffPlanNames(); List<string> allTariffPlanNames = billingSystemDB.SelectTariffPlanNames(); if (tariffPlanInit) { tariffPlanInit = false; foreach (var tariffPlan in allTariffPlanNames) { this.SubscriberTariffPlan.Items.Add(tariffPlan); TariffPlan currentPlan = new TariffPlan(tariffPlan); TariffPlan.AddTariffPlan(currentPlan); currentPlan = billingSystemDB.SelectTariffPlan(tariffPlan); } } else { foreach (var tariffPlan in allTariffPlanNames) { this.SubscriberTariffPlan.Items.Add(tariffPlan); TariffPlan currentPlan = new TariffPlan(tariffPlan); if (!Tariff.Table1.Contains(currentPlan)) TariffPlan.AddTariffPlan(currentPlan); currentPlan = billingSystemDB.SelectTariffPlan(tariffPlan); } } //init Subscriber Table foreach (var subscriber in billingSystemDB.SelectAllSubscribers()) { Clients.Table1.Add(subscriber); } }
private void OnDeleteTariffPlan_Click(object sender, RoutedEventArgs e) { TariffPlan currentPlan = new TariffPlan(this.TariffPlanName.Text); TariffPlan.DeleteTariffPlan(currentPlan); billingSystemDB.DeleteTariffPlan(currentPlan); TariffPlanAllTextBoxInit(sender, e); }