using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace centralController.model
{
public class PaymentScheme
{
public static PaymentScheme ins;
public int paymentSchemeID;
///
/// 策略类型。1按时,2按次,3按时间段
///
public int schemeType;
///
/// 免费时间
///
public int freeTime;
//******************** 按时收费 *******************
///
/// 首段收费时间
///
public int firstChargeTime;
///
/// 首段费用
///
public int firstCharge;
///
/// 间隔收费时间
///
public int chargeInterval;
///
/// 间隔收费单价
///
public int intervalCharge;
///
/// 每日停车收费上限
///
public int upperBound;
//******************** 按天收费 *******************
///
/// 按天收费,每天费用
///
public int eachCharge;
///
/// 按次收费,加收过夜费
///
public int overnightCharge;
//******************** 按时间段收费 *******************
///
/// 按时间段收费,起始时间
///
public string startChargeTime;
///
/// 按时间段收费,终止时间
///
public string endChargeTime;
///
/// 按时间段收费,每小时费用
///
public int chargeStandard;
//******************** VIP卡 *******************
///
/// 月卡办理价格
///
public int monthCardCharge;
///
/// 季卡办理价格
///
public int seasonCardCharge;
///
/// 半年卡办理价格
///
public int halfYearCardCharge;
///
/// 年卡办理价格
///
public int yearCardCharge;
///
/// 预约小时费用
///
public int bookCharge;
public PaymentScheme()
{
this.paymentSchemeID = 0;
this.schemeType = 0;
this.freeTime = 0;
this.firstChargeTime = 0;
this.firstCharge = 0;
this.chargeInterval = 0;
this.intervalCharge = 0;
this.upperBound = 0;
this.eachCharge = 0;
this.overnightCharge = 0;
this.startChargeTime = "";
this.endChargeTime = "";
this.chargeStandard = 0;
this.monthCardCharge = 0;
this.seasonCardCharge = 0;
this.halfYearCardCharge = 0;
this.yearCardCharge = 0;
this.bookCharge = 0;
}
public PaymentScheme(int pID, int type, int freeTime, int firstChargeTime, int firstCharge, int chargeInterval, int intervalCharge,
int upperBound, int eachCharge, int overnightCharge, string startChargeTime, string endChargeTime, int chargeStandard,
int monthCardCharge, int seasonCardCharge, int halfYearCardCharge, int yearCardCharge, int bookCharge)
{
ins = new PaymentScheme();
ins.paymentSchemeID = pID;
ins.schemeType = type;
ins.freeTime = freeTime;
ins.firstChargeTime = firstChargeTime;
ins.firstCharge = firstCharge;
ins.chargeInterval = chargeInterval;
ins.intervalCharge = intervalCharge;
ins.upperBound = upperBound;
ins.eachCharge = eachCharge;
ins.overnightCharge = overnightCharge;
ins.startChargeTime = startChargeTime;
ins.endChargeTime = endChargeTime;
ins.chargeStandard = chargeStandard;
ins.monthCardCharge = monthCardCharge;
ins.seasonCardCharge = seasonCardCharge;
ins.halfYearCardCharge = halfYearCardCharge;
ins.yearCardCharge = yearCardCharge;
ins.bookCharge = bookCharge;
}
public static PaymentScheme GetCurrentPaymentScheme(int index)
{
string currentPaymentSchemeQuerySql = "select * from paymentscheme where paymentSchemeID = " + index + ";";
object[] paramArray = null;
PaymentScheme scheme = null;
MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(currentPaymentSchemeQuerySql);
try
{
if (reader != null && reader.Read())
{
scheme = new PaymentScheme();
paramArray = new object[reader.FieldCount];
reader.GetValues(paramArray);
scheme.paymentSchemeID = index;
scheme.schemeType = (int)((UInt32)paramArray[1]);
scheme.freeTime = (int)paramArray[2];
scheme.firstChargeTime = (int)paramArray[3];
scheme.firstCharge = (int)paramArray[4];
scheme.chargeInterval = (int)paramArray[5];
scheme.intervalCharge = (int)paramArray[6];
scheme.upperBound = (int)paramArray[7];
scheme.eachCharge = (int)paramArray[8];
scheme.overnightCharge = (int)paramArray[9];
scheme.startChargeTime = (string)paramArray[10];
scheme.endChargeTime = (string)paramArray[11];
scheme.chargeStandard = (int)paramArray[12];
scheme.monthCardCharge = (int)paramArray[13];
scheme.seasonCardCharge = (int)paramArray[14];
scheme.halfYearCardCharge = (int)paramArray[15];
scheme.yearCardCharge = (int)paramArray[16];
scheme.bookCharge = (int)paramArray[17];
}
}
catch (Exception e) { Console.WriteLine("读取本地计费策略," + e.Message); }
try
{
if (reader != null)
{
reader.Close();
reader.Dispose();
}
}
catch (Exception e) { Console.WriteLine(e.Message); }
return scheme;
}
public static bool SetPaymentScheme(PaymentScheme ps)
{
DateTime t0 = DateTime.Now;
DateTime t1 = DateTime.Now;
string updateScheme = "UPDATE paymentscheme SET schemeType = '"+ps.schemeType+"',freeTime='" + (ps.freeTime >= 0 ? ps.freeTime : ins.freeTime) + "', firstChargeTime='" + (ps.firstChargeTime >= 0 ? ps.firstChargeTime : ins.firstChargeTime) + "', firstCharge='" + (ps.firstCharge >= 0 ? ps.firstCharge : ins.firstCharge) + "', intervalCharge='" + (ps.intervalCharge >= 0 ? ps.intervalCharge : ins.intervalCharge) + "', upperBound='" + (ps.upperBound >= 0 ? ps.upperBound : ins.upperBound) + "'," +
" eachCharge='" + (ps.eachCharge >= 0 ? ps.eachCharge : ins.eachCharge) + "', overnightCharge='" + (ps.overnightCharge >= 0 ? ps.overnightCharge : ins.overnightCharge) + "', startChargeTime='" + (DateTime.TryParse(ps.startChargeTime, out t0) ? ps.startChargeTime : ins.startChargeTime) + "', endChargeTime='" + (DateTime.TryParse(ps.endChargeTime, out t1) ? ps.endChargeTime : ins.endChargeTime) + "', chargeStandard='" + (ps.chargeStandard >= 0 ? ps.chargeStandard : ins.chargeStandard) + "'," +
" monthCardCharge='" + (ps.monthCardCharge >= 0 ? ps.monthCardCharge : ins.monthCardCharge) + "', seasonCardCharge='" + (ps.seasonCardCharge >= 0 ? ps.seasonCardCharge : ins.seasonCardCharge) + "', halfYearCardCharge='" + (ps.halfYearCardCharge >= 0 ? ps.halfYearCardCharge : ins.halfYearCardCharge) + "', yearCardCharge='" + (ps.yearCardCharge >= 0 ? ps.yearCardCharge : ins.yearCardCharge) + "', bookCharge='" + (ps.bookCharge >= 0 ? ps.bookCharge : ins.bookCharge) + "' WHERE paymentSchemeID='1';";
List sqls = new List();
sqls.Add(updateScheme);
return Monitor.Monitor.localDBOper.UpdateTransaction(sqls);
}
}
}