示例#1
0
 public it_log GetById(int id)
 {
     using (ittransactionlogEntities db = new ittransactionlogEntities())
     {
         return(db.it_log.Find(id));
     }
 }
示例#2
0
        public List <it_log_all> SearchByPersonnel(int id)
        {
            using (ittransactionlogEntities db = new ittransactionlogEntities())
            {
                /*var result = db.Database.SqlQuery<IList>("SELECT l.it_log_id, l.name, " +
                 *  "l.office, l.date, l.time, l.service_request, p.it_personnel_name " +
                 *  "FROM it_log AS l INNER JOIN it_personnel AS p ON l.it_personnel_id = p.it_personnel_id" +
                 *  "WHERE l.date BETWEEN DATE(@from) AND DATE(@to)",
                 *  new SqlParameter("@from", from),
                 *  new SqlParameter("@to", to)).ToList();
                 */

                var result = (from l in db.it_log
                              join p in db.it_personnel
                              on l.it_personnel_id equals p.it_personnel_id
                              where l.it_personnel_id == id
                              select new it_log_all
                {
                    id = l.it_log_id,
                    Name = l.name,
                    Office = l.office,
                    Date = l.date,
                    Time = l.time,
                    Service_Request = l.service_request,
                    IT_Personnel = p.it_personnel_name
                }).ToList();

                return(result);
            }
        }
示例#3
0
 public void Update(it_log obj)
 {
     using (ittransactionlogEntities db = new ittransactionlogEntities())
     {
         db.it_log.Attach(obj);
         db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#4
0
 public it_log Insert(it_log obj)
 {
     using (ittransactionlogEntities db = new ittransactionlogEntities())
     {
         db.it_log.Add(obj);
         db.SaveChanges();
         return(obj);
     }
 }
示例#5
0
        public void Delete(int id)
        {
            using (ittransactionlogEntities db = new ittransactionlogEntities())
            {
                //using (dbemployeeEntities db = new dbemployeeEntities())
                //{
                //    db.Database.ExecuteSqlCommand("UPDATE employee_info SET lastname = 'SQLTEST' WHERE empID = 19");
                //}

                var delete = (from l in db.it_log
                              where l.it_log_id.Equals(id)
                              select l).FirstOrDefault();

                db.it_log.Attach(delete);
                db.it_log.Remove(delete);
                db.SaveChanges();
            }
        }
示例#6
0
        public List <it_log_all> GetAll()
        {
            using (ittransactionlogEntities db = new ittransactionlogEntities())
            {
                var itlog = (from l in db.it_log
                             join p in db.it_personnel
                             on l.it_personnel_id equals p.it_personnel_id
                             select new it_log_all
                {
                    id = l.it_log_id,
                    Name = l.name,
                    Office = l.office,
                    Date = l.date,
                    Time = l.time,
                    Service_Request = l.service_request,
                    IT_Personnel = p.it_personnel_name
                }).ToList();

                return(itlog);
            }
        }
示例#7
0
        public List <it_log_all> Search(string text)
        {
            using (ittransactionlogEntities db = new ittransactionlogEntities())
            {
                var result = (from l in db.it_log
                              join p in db.it_personnel
                              on l.it_personnel_id equals p.it_personnel_id
                              where (l.name.Contains(text) || l.office.Contains(text) ||
                                     l.service_request.Contains(text) || p.it_personnel_name.Contains(text))
                              select new it_log_all
                {
                    id = l.it_log_id,
                    Name = l.name,
                    Office = l.office,
                    Date = l.date,
                    Time = l.time,
                    Service_Request = l.service_request,
                    IT_Personnel = p.it_personnel_name
                }).ToList();

                return(result);
            }
        }