示例#1
0
        private static Tab_Y_Product ToModel(DataRow row)
        {
            Tab_Y_Product model = new Tab_Y_Product();

            model.Idx            = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.ProductTypeIdx = row.IsNull("ProductTypeIdx")?null:(System.Int32?)row["ProductTypeIdx"];
            model.ProductNo      = row.IsNull("ProductNo")?null:(System.String)row["ProductNo"];
            model.Title          = row.IsNull("Title")?null:(System.String)row["Title"];
            model.ImagePath1     = row.IsNull("ImagePath1")?null:(System.String)row["ImagePath1"];
            model.ImagePath2     = row.IsNull("ImagePath2")?null:(System.String)row["ImagePath2"];
            model.ImagePath3     = row.IsNull("ImagePath3")?null:(System.String)row["ImagePath3"];
            model.Descript       = row.IsNull("Descript")?null:(System.String)row["Descript"];
            return(model);
        }
示例#2
0
        public int AddNew(Tab_Y_Product model)
        {
            string sql = "insert into Tab_Y_Product(ProductTypeIdx,ProductNo,Title,ImagePath1,ImagePath2,ImagePath3,Descript)  values(@ProductTypeIdx,@ProductNo,@Title,@ImagePath1,@ImagePath2,@ImagePath3,@Descript); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@ProductTypeIdx", model.ProductTypeIdx)
                                                                 , new SqlParameter("@ProductNo", model.ProductNo)
                                                                 , new SqlParameter("@Title", model.Title)
                                                                 , new SqlParameter("@ImagePath1", model.ImagePath1)
                                                                 , new SqlParameter("@ImagePath2", model.ImagePath2)
                                                                 , new SqlParameter("@ImagePath3", model.ImagePath3)
                                                                 , new SqlParameter("@Descript", model.Descript)
                                                                 ));

            return(Idx);
        }
示例#3
0
        public bool Update(Tab_Y_Product model)
        {
            string sql  = "update Tab_Y_Product set ProductTypeIdx=@ProductTypeIdx,ProductNo=@ProductNo,Title=@Title,ImagePath1=@ImagePath1,ImagePath2=@ImagePath2,ImagePath3=@ImagePath3,Descript=@Descript where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@ProductTypeIdx", model.ProductTypeIdx)
                                                    , new SqlParameter("@ProductNo", model.ProductNo)
                                                    , new SqlParameter("@Title", model.Title)
                                                    , new SqlParameter("@ImagePath1", model.ImagePath1)
                                                    , new SqlParameter("@ImagePath2", model.ImagePath2)
                                                    , new SqlParameter("@ImagePath3", model.ImagePath3)
                                                    , new SqlParameter("@Descript", model.Descript)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
示例#4
0
        public Tab_Y_Product Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_Y_Product  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_Y_Product model = ToModel(row);

            return(model);
        }