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 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(); } }