Ejemplo n.º 1
0
        private static Tab_magazine ToModel(DataRow row)
        {
            Tab_magazine model = new Tab_magazine();

            model.Idx           = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.MagazineQiKan = row.IsNull("MagazineQiKan")?null:(System.String)row["MagazineQiKan"];
            model.MagazineImg   = row.IsNull("MagazineImg")?null:(System.String)row["MagazineImg"];
            model.MagazineRar   = row.IsNull("MagazineRar")?null:(System.String)row["MagazineRar"];
            model.DateCreated   = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"];
            return(model);
        }
Ejemplo n.º 2
0
        public int AddNew(Tab_magazine model)
        {
            string sql = "insert into Tab_magazine(MagazineQiKan,MagazineImg,MagazineRar,DateCreated)  values(@MagazineQiKan,@MagazineImg,@MagazineRar,@DateCreated); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@MagazineQiKan", model.MagazineQiKan)
                                                                 , new SqlParameter("@MagazineImg", model.MagazineImg)
                                                                 , new SqlParameter("@MagazineRar", model.MagazineRar)
                                                                 , new SqlParameter("@DateCreated", model.DateCreated)
                                                                 ));

            return(Idx);
        }
Ejemplo n.º 3
0
        public bool Update(Tab_magazine model)
        {
            string sql  = "update Tab_magazine set MagazineQiKan=@MagazineQiKan,MagazineImg=@MagazineImg,MagazineRar=@MagazineRar,DateCreated=@DateCreated where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@MagazineQiKan", model.MagazineQiKan)
                                                    , new SqlParameter("@MagazineImg", model.MagazineImg)
                                                    , new SqlParameter("@MagazineRar", model.MagazineRar)
                                                    , new SqlParameter("@DateCreated", model.DateCreated)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Ejemplo n.º 4
0
        public Tab_magazine Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_magazine  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow      row   = dt.Rows[0];
            Tab_magazine model = ToModel(row);

            return(model);
        }