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

            model.Idx             = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.GiftName        = row.IsNull("GiftName")?null:(System.String)row["GiftName"];
            model.GiftImgSmall    = row.IsNull("GiftImgSmall")?null:(System.String)row["GiftImgSmall"];
            model.GiftImgBig      = row.IsNull("GiftImgBig")?null:(System.String)row["GiftImgBig"];
            model.GiftDescription = row.IsNull("GiftDescription")?null:(System.String)row["GiftDescription"];
            model.NeedPoint       = row.IsNull("NeedPoint")?null:(System.Int32?)row["NeedPoint"];
            model.CreatedDate     = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"];
            model.ExpirationDate  = row.IsNull("ExpirationDate")?null:(System.DateTime?)row["ExpirationDate"];
            return(model);
        }
Ejemplo n.º 2
0
        public int AddNew(Tab_Gift model)
        {
            string sql = "insert into Tab_Gift(GiftName,GiftImgSmall,GiftImgBig,GiftDescription,NeedPoint,CreatedDate,ExpirationDate)  values(@GiftName,@GiftImgSmall,@GiftImgBig,@GiftDescription,@NeedPoint,@CreatedDate,@ExpirationDate); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@GiftName", model.GiftName)
                                                                 , new SqlParameter("@GiftImgSmall", model.GiftImgSmall)
                                                                 , new SqlParameter("@GiftImgBig", model.GiftImgBig)
                                                                 , new SqlParameter("@GiftDescription", model.GiftDescription)
                                                                 , new SqlParameter("@NeedPoint", model.NeedPoint)
                                                                 , new SqlParameter("@CreatedDate", model.CreatedDate)
                                                                 , new SqlParameter("@ExpirationDate", model.ExpirationDate)
                                                                 ));

            return(Idx);
        }
Ejemplo n.º 3
0
        public bool Update(Tab_Gift model)
        {
            string sql  = "update Tab_Gift set GiftName=@GiftName,GiftImgSmall=@GiftImgSmall,GiftImgBig=@GiftImgBig,GiftDescription=@GiftDescription,NeedPoint=@NeedPoint,CreatedDate=@CreatedDate,ExpirationDate=@ExpirationDate where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@GiftName", model.GiftName)
                                                    , new SqlParameter("@GiftImgSmall", model.GiftImgSmall)
                                                    , new SqlParameter("@GiftImgBig", model.GiftImgBig)
                                                    , new SqlParameter("@GiftDescription", model.GiftDescription)
                                                    , new SqlParameter("@NeedPoint", model.NeedPoint)
                                                    , new SqlParameter("@CreatedDate", model.CreatedDate)
                                                    , new SqlParameter("@ExpirationDate", model.ExpirationDate)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Ejemplo n.º 4
0
        public Tab_Gift Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_Gift  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_Gift model = ToModel(row);

            return(model);
        }