Esempio n. 1
0
        public string Sua(MayBeBDO entityBDO)
        {
            MAY_BE entity = db.MAY_BE.Where(x => x.ID == entityBDO.ID).SingleOrDefault();
            var    kq     = "";

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

                    ChuyenBDOThanhDAO(entityBDO, entity);
                    db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    kq = string.Format("Lưu mục tin {0} thành công", entity.ID);//trả về số Id
                }
                catch
                {
                    kq = string.Format("Sửa mục tin {0} không thành công!", entity.ID);
                }
            }
            else
            {
                return(kq = string.Format("Mục tin {0} không tồn tại!", entity.ID));
            }
            return(kq);
        }
Esempio n. 2
0
        private void ChuyenBDOThanhDAO(MayBeBDO entityBDO, MAY_BE entityDAO)
        {
            entityDAO.ID                 = entityBDO.ID;
            entityDAO.ten                = entityBDO.Ten;
            entityDAO.BHR                = entityBDO.BHR;
            entityDAO.toc_do_con         = entityBDO.TocDoTamGio;
            entityDAO.thoi_gian_chuan_bi = entityBDO.ThoiGianChuanBi;
            entityDAO.phi_ngvl_chuan_bi  = entityBDO.PhiNguyenVatLieuChuanBi;
            entityDAO.day_so_luong       = entityBDO.DaySoLuong;
            entityDAO.day_loi_nhuan      = entityBDO.DayLoiNhuan;

            entityDAO.don_vi_tinh           = entityBDO.DonViTinh;
            entityDAO.day_so_luong_niem_yet = entityBDO.DaySoLuongNiemYet;

            entityDAO.thu_tu = entityBDO.ThuTu;
        }
Esempio n. 3
0
        public string Them(MayBeBDO entityBDO)
        {
            string kq = "";

            try
            {
                kq = KiemTraTrung(entityBDO.Ten);
                if (kq != "")
                {
                    return(kq);
                }
                MAY_BE entity = new MAY_BE();
                ChuyenBDOThanhDAO(entityBDO, entity);
                db.MAY_BE.Add(entity);
                db.SaveChanges();
                kq = string.Format("Máy ép kim:{0}", entity.ID);
            }
            catch
            {
                kq = string.Format("Thêm Máy bế {0} lỗi!", entityBDO.ID);
            }
            return(kq);
        }