Example #1
0
        public void Create(OutStore ots)
        {
            using (var ctx = new LYLQEntities())
            {
                //ctx.OutStores.Add(ots);

                //ctx.SaveChanges();

                string sql = @"INSERT INTO OutStore(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", ots.Code));
                sqlParams.Add(new SQLiteParameter("@CreatedBy", ots.CreatedBy));
                sqlParams.Add(new SQLiteParameter("@CreatedDate", ots.CreatedDate));
                sqlParams.Add(new SQLiteParameter("@Department", ots.Department));
                sqlParams.Add(new SQLiteParameter("@Id", ots.Id));
                sqlParams.Add(new SQLiteParameter("@InstoreId", ots.InstoreId));
                sqlParams.Add(new SQLiteParameter("@Number", ots.Number));
                sqlParams.Add(new SQLiteParameter("@TotalPrice", ots.TotalPrice));
                sqlParams.Add(new SQLiteParameter("@Type", ots.Type));
                sqlParams.Add(new SQLiteParameter("@UnitPrice", ots.UnitPrice));
                sqlParams.Add(new SQLiteParameter("@UpdatedBy", ots.UpdatedBy));
                sqlParams.Add(new SQLiteParameter("@UpdatedDate", ots.UpdatedDate));

                ctx.Database.ExecuteSqlCommand(sql, sqlParams.ToArray());
            }
        }
Example #2
0
 public DBLayer.OutStore GetDBModel(OutStore ost)
 {
     DBLayer.OutStore dbOst = null;
     if (ost != null)
     {
         dbOst = new DBLayer.OutStore();
         dbOst.Code = ost.Code;
         dbOst.Id = ost.Id;
         dbOst.InstoreId = ost.InstoreId;
         dbOst.Number = ost.Number;
         dbOst.UnitPrice = ost.UnitPrice;
         dbOst.TotalPrice = ost.TotalPrice;
         dbOst.Department = ost.Department;
         dbOst.Type = ost.Type;
         dbOst.CreatedBy = ost.CreatedBy;
         dbOst.CreatedDate = ost.CreatedDate;
         dbOst.UpdatedBy = ost.UpdatedBy;
         dbOst.UpdatedDate = ost.UpdatedDate;
     }
     return dbOst;
 }
Example #3
0
        public void Update(OutStore outStore)
        {
            using (var ctx = new LYLQEntities())
            {
                //var dbOuts = from dbOut in ctx.OutStores
                //              where dbOut.Id == outStore.Id
                //              select dbOut;

                //var dbModelOut = dbOuts.First();
                //dbModelOut.InstoreId = outStore.InstoreId;
                //dbModelOut.Code = outStore.Code;
                //dbModelOut.UnitPrice = outStore.UnitPrice;
                //dbModelOut.Number = outStore.Number;
                //dbModelOut.TotalPrice = outStore.TotalPrice;
                //dbModelOut.Department = outStore.Department;
                //dbModelOut.Type = outStore.Type;
                //dbModelOut.UpdatedBy = outStore.UpdatedBy;
                //dbModelOut.UpdatedDate = DateTime.Now;

                //ctx.SaveChanges();

                string sql = @"UPDATE OutStore SET InstoreId = @InstoreId,
                                                Code = @Code,
                                                UnitPrice= @UnitPrice,
                                                Number= @Number,
                                                TotalPrice= @TotalPrice,
                                                Department= @Department,
                                                Type= @Type,
                                                UpdatedBy = @UpdatedBy,
                                                UpdatedDate = @UpdatedDate
                                            WHERE Id = '" + outStore.Id + "'";

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

                ctx.Database.ExecuteSqlCommand(sql, sqlParams.ToArray());
            }
        }