Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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);
 }