public static bool CreateForm(OdbcDataReader reader, PaidGroup paidGroup) { int fCount = reader.FieldCount; for (int i = 0; i < fCount; i++) { string name = reader.GetName(i); // Map to DB field. Need to change if db changed switch (name) { case "paid_group_id": paidGroup._paidGroupID = reader.GetInt32(i); break; case "name": paidGroup._name = reader.GetString(i); break; case "current_round": paidGroup._currentRound = reader.GetInt32(i); break; case "rate_info": paidGroup._rawRateInfo = reader.GetString(i); paidGroup._rateInfo = PaidRateInfo.Parse(paidGroup._rawRateInfo); break; // helper info } } return(reader.HasRows); }
public static PaidRateInfo[] Parse(string rateInfo) { string[] aRate = rateInfo.Split(';'); PaidRateInfo[] pr = new PaidRateInfo[aRate.Length]; for (int i = 0; i < aRate.Length; i++) { string[] pair = aRate[i].Split(':'); PaidRateInfo rinfo = new PaidRateInfo(Int32.Parse(pair[0]), Int32.Parse(pair[1])); pr[i] = rinfo; } return(pr); }
public string BuildRateInfoString(string input) { StringBuilder sb = new StringBuilder(); string[] aRate = input.Split(';'); PaidRateInfo[] pr = new PaidRateInfo[aRate.Length]; for (int i = 0; i < aRate.Length; i++) { string[] pair = aRate[i].Split(':'); if (!String.IsNullOrEmpty(pair[0]) && !String.IsNullOrEmpty(pair[1])) { sb.Append(aRate[i]); sb.Append(";"); } } string ret = sb.ToString(); if (ret.EndsWith(";") && ret.Length > 1) { ret = ret.Remove(ret.Length - 1); } return(ret); }
public static string ToString(PaidRateInfo[] rateInfo) { StringBuilder info = new StringBuilder(); for (int i = 0; i < rateInfo.Length; i++) { info.Append(rateInfo[i].ToString()); if (i < rateInfo.Length-1) { info.Append(";"); } } return info.ToString(); }
public static PaidRateInfo[] Parse(string rateInfo) { string[] aRate = rateInfo.Split(';'); PaidRateInfo[] pr = new PaidRateInfo[aRate.Length]; for (int i = 0; i < aRate.Length; i++) { string[] pair = aRate[i].Split(':'); PaidRateInfo rinfo = new PaidRateInfo(Int32.Parse(pair[0]), Int32.Parse(pair[1])); pr[i] = rinfo; } return pr; }
public string BuildRateInfoString(string input) { StringBuilder sb = new StringBuilder(); string[] aRate = input.Split(';'); PaidRateInfo[] pr = new PaidRateInfo[aRate.Length]; for (int i = 0; i < aRate.Length; i++) { string[] pair = aRate[i].Split(':'); if (!String.IsNullOrEmpty(pair[0]) && !String.IsNullOrEmpty(pair[1])) { sb.Append(aRate[i]); sb.Append(";"); } } string ret = sb.ToString(); if (ret.EndsWith(";") && ret.Length > 1) ret = ret.Remove(ret.Length-1); return ret; }
public override bool UpdateToDB(DBManager db) { if (_paidGroupID <= 0) { return(false); } String[] key = { "paid_group_id", "name", "current_round", "rate_info" }; String[] val = { _paidGroupID.ToString(), _name, _currentRound.ToString(), PaidRateInfo.ToString(_rateInfo) }; return((db.Update("paid_group", key, val, "paid_group_id=" + _paidGroupID) > 0) ? true : false); }
public override bool AddToDB(DBManager db) { String[] key = { "paid_group_id", "name", "current_round", "rate_info" }; String[] val = { _paidGroupID.ToString(), _name, _currentRound.ToString(), PaidRateInfo.ToString(_rateInfo) }; return((db.Insert("paid_group", key, val) > 0) ? true : false); }