示例#1
0
        public string Sua(KhuonBeBDO entityBDO)
        {
            KHUON_BE entity = db.KHUON_BE.Where(x => (x.ID == entityBDO.ID)).SingleOrDefault();
            string   kq     = "";

            if (entity != null)
            {
                try
                {
                    kq = KiemTraTrung(entityBDO.Ten, entityBDO.IDMAYBE, 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 bế 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(KhuonBeBDO entityBDO, KHUON_BE 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_MAY_BE = entityBDO.IDMAYBE;
 }
示例#3
0
        public string Them(KhuonBeBDO entityBDO)
        {
            string kq = "";

            try
            {
                kq = KiemTraTrung(entityBDO.Ten, entityBDO.IDMAYBE);
                if (kq != "")
                {
                    return(kq);
                }
                KHUON_BE entity = new KHUON_BE();
                ChuyenBDOThanhDAO(entityBDO, entity);
                db.KHUON_BE.Add(entity);
                db.SaveChanges();
                kq = string.Format("Khuôn bế:{0}", entity.ID);
            }
            catch
            {
                kq = string.Format("Thêm Khuôn bế {0} lỗi!", entityBDO.ID);
            }
            return(kq);
        }
示例#4
0
        public string Xoa(int iD)
        {
            string kq = "";

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

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