Beispiel #1
0
        public void Create(Materiel mat)
        {
            using (var ctx = new LYLQEntities())
            {
                string sql = @"INSERT INTO Materiel(Code,CreatedBy,CreatedDate,Name,Type,UpdatedBy,UpdatedDate)VALUES(
                                                    @Code,@CreatedBy,@CreatedDate,@Name,@Type,@UpdatedBy,@UpdatedDate)";

                List<SQLiteParameter> sqlParams = new List<SQLiteParameter>();
                sqlParams.Add(new SQLiteParameter("@Code", mat.Code));
                sqlParams.Add(new SQLiteParameter("@CreatedBy", mat.CreatedBy));
                sqlParams.Add(new SQLiteParameter("@CreatedDate", mat.CreatedDate));
                sqlParams.Add(new SQLiteParameter("@Name", mat.Name));
                sqlParams.Add(new SQLiteParameter("@Type", mat.Type));
                sqlParams.Add(new SQLiteParameter("@UpdatedBy", mat.UpdatedBy));
                sqlParams.Add(new SQLiteParameter("@UpdatedDate", mat.UpdatedDate));

                ctx.Database.ExecuteSqlCommand(sql, sqlParams.ToArray());
            }
        }
Beispiel #2
0
 public DBLayer.Materiel GetDBModel(Material dpt)
 {
     DBLayer.Materiel dbMat = null;
     if (dpt != null)
     {
         dbMat = new DBLayer.Materiel();
         dbMat.Code = dpt.Code;
         dbMat.Name = dpt.Name;
         dbMat.CreatedBy = dpt.CreatedBy;
         dbMat.CreatedDate = dpt.CreatedDate;
         dbMat.UpdatedBy = dpt.UpdatedBy;
         dbMat.UpdatedDate = dpt.UpdatedDate;
         dbMat.Type = dpt.Type;
     }
     return dbMat;
 }
Beispiel #3
0
        public void Update(Materiel mat)
        {
            using (var ctx = new LYLQEntities())
            {
                //var dbMats = from dbMat in ctx.Materiels
                //             where dbMat.Code == mat.Code
                //             select dbMat;

                //var dbModelDpt = dbMats.First();
                //dbModelDpt.Name = mat.Name;
                //dbModelDpt.UpdatedBy = mat.UpdatedBy;
                //dbModelDpt.UpdatedDate = DateTime.Now;

               //ctx.SaveChanges();

                string sql = @"UPDATE Materiel SET Name = @Name,
                                                UpdatedBy = @UpdatedBy,
                                                UpdatedDate = @UpdatedDate
                                            WHERE Code = '" + mat.Code + "'";

                List<SQLiteParameter> sqlParams = new List<SQLiteParameter>();
                sqlParams.Add(new SQLiteParameter("@Name", mat.Name));
                sqlParams.Add(new SQLiteParameter("@UpdatedBy", mat.UpdatedBy));
                sqlParams.Add(new SQLiteParameter("@UpdatedDate", mat.UpdatedDate));

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

            }
        }