예제 #1
0
파일: StockDB.cs 프로젝트: chinayinhui/LYLQ
        public void Create(Stock stock)
        {
            using (var ctx = new LYLQEntities())
            {
                string sql = @"INSERT INTO Stock(Code,CreatedBy,CreatedDate,Department,Id,InstoreId,Number,TotalPrice,Type,UnitPrice,UpdatedBy,UpdatedDate)VALUES(
                                                @Code,@CreatedBy,@CreatedDate,@Department,@Id,@InstoreId,@Number,@TotalPrice,@Type,@UnitPrice,@UpdatedBy,@UpdatedDate)";

                List<SQLiteParameter> sqlParams = new List<SQLiteParameter>();
                sqlParams.Add(new SQLiteParameter("@Code", stock.Code));
                sqlParams.Add(new SQLiteParameter("@CreatedBy", stock.CreatedBy));
                sqlParams.Add(new SQLiteParameter("@CreatedDate", stock.CreatedDate));
                sqlParams.Add(new SQLiteParameter("@Department", stock.Department));
                sqlParams.Add(new SQLiteParameter("@Id", stock.Id));
                sqlParams.Add(new SQLiteParameter("@InstoreId", stock.InstoreId));
                sqlParams.Add(new SQLiteParameter("@Number", stock.Number));
                sqlParams.Add(new SQLiteParameter("@TotalPrice", stock.TotalPrice));
                sqlParams.Add(new SQLiteParameter("@Type", stock.Type));
                sqlParams.Add(new SQLiteParameter("@UnitPrice", stock.UnitPrice));
                sqlParams.Add(new SQLiteParameter("@UpdatedBy", stock.UpdatedBy));
                sqlParams.Add(new SQLiteParameter("@UpdatedDate", stock.UpdatedDate));

                ctx.Database.ExecuteSqlCommand(sql, sqlParams.ToArray());
            }
        }
예제 #2
0
파일: StockDB.cs 프로젝트: chinayinhui/LYLQ
        public void Update(Stock stock)
        {
            using (var ctx = new LYLQEntities())
            {
                string sql = @"UPDATE Stock SET Number = @Number,
                                                TotalPrice = @TotalPrice,
                                                UpdatedBy = @UpdatedBy,
                                                UpdatedDate = @UpdatedDate
                                            WHERE Id = '" + stock.Id + "'";

                List<SQLiteParameter> sqlParams = new List<SQLiteParameter>();
                sqlParams.Add(new SQLiteParameter("@Number", stock.Number));
                sqlParams.Add(new SQLiteParameter("@TotalPrice", stock.TotalPrice));
                sqlParams.Add(new SQLiteParameter("@UpdatedBy", stock.UpdatedBy));
                sqlParams.Add(new SQLiteParameter("@UpdatedDate", stock.UpdatedDate));

                ctx.Database.ExecuteSqlCommand(sql, sqlParams.ToArray());
            }
        }
예제 #3
0
파일: Stock.cs 프로젝트: chinayinhui/LYLQ
 public DBLayer.Stock GetDBModel(Stock stock)
 {
     DBLayer.Stock dbStock = null;
     if (stock != null)
     {
         dbStock = new DBLayer.Stock();
         dbStock.Code = stock.Code;
         dbStock.Id = stock.Id;
         dbStock.InstoreId = stock.InstoreId;
         dbStock.Number = stock.Number;
         dbStock.UnitPrice = stock.UnitPrice;
         dbStock.TotalPrice = stock.TotalPrice;
         dbStock.Department = stock.Department;
         dbStock.Type = stock.Type;
         dbStock.CreatedBy = stock.CreatedBy;
         dbStock.CreatedDate = stock.CreatedDate;
         dbStock.UpdatedBy = stock.UpdatedBy;
         dbStock.UpdatedDate = stock.UpdatedDate;
     }
     return dbStock;
 }