Exemple #1
0
        public GuessParaModel Get(int id)
        {
            DataTable dt = SqlHelper.ExecuteDataTable("select * from GuessPara where id=@id",
                                                      new MySqlParameter("id", id));

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }
            else if (dt.Rows.Count == 1)
            {
                GuessParaModel model = new GuessParaModel();
                DataRow        row   = dt.Rows[0];
                model.id         = (int)row["id"];
                model.GuessValue = (int)row["GuessValue"];
                model.Lun        = (int)row["Lun"];
                model.GuessStyle = (int)row["GuessStyle"];
                model.GuessList  = (string)GetNull(row["GuessList"]);
                return(model);
            }
            else
            {
                throw new Exception("出现多条数据!");
            }
        }
Exemple #2
0
        public int AddNew(GuessParaModel model)
        {
            object obj = SqlHelper.ExecuteScalar("insert into GuessPara(GuessValue,Lun,GuessStyle,GuessList) values(@GuessValue,@Lun,@GuessStyle,@GuessList )",
                                                 new MySqlParameter("GuessValue", model.GuessValue),
                                                 new MySqlParameter("Lun", model.Lun),
                                                 new MySqlParameter("GuessStyle", model.GuessStyle),
                                                 new MySqlParameter("GuessList", PutNull(model.GuessList)));

            return(Convert.ToInt32(obj));
        }
Exemple #3
0
        public int Update(GuessParaModel model)
        {
            object obj = SqlHelper.ExecuteScalar("update GuessPara set GuessValue=@GuessValue,Lun=@Lun,GuessStyle=@GuessStyle,GuessList=@GuessList where id=@id",
                                                 new MySqlParameter("GuessValue", model.GuessValue),
                                                 new MySqlParameter("Lun", model.Lun),
                                                 new MySqlParameter("GuessStyle", model.GuessStyle),
                                                 new MySqlParameter("GuessList", PutNull(model.GuessList)),
                                                 new MySqlParameter("id", model.id));

            return(Convert.ToInt32(obj));
        }
Exemple #4
0
        public IEnumerable <GuessParaModel> GetAll()
        {
            DataTable             dt   = SqlHelper.ExecuteDataTable("select * from GuessPara");
            List <GuessParaModel> list = new List <GuessParaModel>();

            foreach (DataRow row in dt.Rows)
            {
                GuessParaModel model = new GuessParaModel();
                model.id         = (int)row["id"];
                model.GuessValue = (int)row["GuessValue"];
                model.Lun        = (int)row["Lun"];
                model.GuessStyle = (int)row["GuessStyle"];
                model.GuessList  = (string)GetNull(row["GuessList"]);
                list.Add(model);
            }
            return(list);
        }
Exemple #5
0
 public int AddNew(GuessParaModel model)
 {
     return(new GuessParaDAL().AddNew(model));
 }
Exemple #6
0
 public int Update(GuessParaModel model)
 {
     return(new GuessParaDAL().Update(model));
 }