예제 #1
0
        public string Sua(KhuonEpKimBDO entityBDO)
        {
            KHUON_EP_KIM entity = db.KHUON_EP_KIM.Where(x => (x.ID == entityBDO.ID)).SingleOrDefault();
            string       kq     = "";

            if (entity != null)
            {
                try
                {
                    kq = KiemTraTrung(entityBDO.Ten, entityBDO.ID);
                    if (kq != "")
                    {
                        return(kq);
                    }

                    ChuyenBDOThanhDAO(entityBDO, entity);
                    //Chú ý
                    db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    kq = string.Format("Sửa Khuôn ép kim ID: {0} thành công", entity.ID);//trả về số Id
                }
                catch
                {
                    kq = string.Format(" Sửa record {0} không thành công!", entity.ID);
                }
            }
            else
            {
                return(kq = string.Format("Thông tin {0} không tồn tại!", entity.ID));
            }
            return(kq);
        }
예제 #2
0
 private void ChuyenBDOThanhDAO(KhuonEpKimBDO entityBDO, KHUON_EP_KIM entityDAO)
 {
     entityDAO.ID        = entityBDO.ID;
     entityDAO.Ten       = entityBDO.Ten;
     entityDAO.Dien_giai = entityBDO.DienGiai;
     entityDAO.Gia_mua   = entityBDO.GiaMua;
     entityDAO.Thu_tu    = entityBDO.ThuTu;
     entityDAO.ID_EP_KIM = entityBDO.IDEPKIM;
 }
예제 #3
0
        public string Them(KhuonEpKimBDO entityBDO)
        {
            string kq = "";

            try
            {
                kq = KiemTraTrung(entityBDO.Ten);
                if (kq != "")
                {
                    return(kq);
                }
                KHUON_EP_KIM entity = new KHUON_EP_KIM();
                ChuyenBDOThanhDAO(entityBDO, entity);
                db.KHUON_EP_KIM.Add(entity);
                db.SaveChanges();
                kq = string.Format("Khuôn Ép kim:{0}", entity.ID);
            }
            catch
            {
                kq = string.Format(" Khuôn Ép kim{0} lỗi!", entityBDO.ID);
            }
            return(kq);
        }
예제 #4
0
        public string Xoa(int iD)
        {
            string kq = "";

            KHUON_EP_KIM entity = db.KHUON_EP_KIM.Find(iD);

            if (entity != null)
            {
                try
                {
                    db.KHUON_EP_KIM.Remove(entity);
                    db.SaveChanges();
                }
                catch
                {
                    kq = string.Format("Xóa Khuôn ép Kim {0} không thành công!", entity.Ten);
                }
            }
            else
            {
                kq = string.Format("Khuôn ép kim ID:{0} không tồn tại!", iD);
            }
            return(kq);;
        }