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

            if (entity != null)
            {
                try
                {
                    kq = KiemTraTrung(entityBDO.Ten, entityBDO.ID);
                    if (kq != "")
                    {
                        return(kq);
                    }
                    //Vượt thì chuyển
                    ChuyenBDOThanhDAO(entityBDO, entity);
                    //Chú ý
                    db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    kq = string.Format("Sửa Món thành phẩm 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(MonThanhPhamBDO entityBDO, DS_THANH_PHAM entityDAO)
 {
     entityDAO.ID           = entityBDO.ID;
     entityDAO.ten          = entityBDO.Ten;
     entityDAO.ma_01        = entityBDO.Ma_01;
     entityDAO.ma_02        = entityBDO.Ma_02;
     entityDAO.ma_03        = entityBDO.Ma_03;
     entityDAO.day_so_luong = entityBDO.DaySoLuong;
     entityDAO.don_vi_tinh  = entityBDO.DonViTinh;
     entityDAO.thu_tu       = entityBDO.ThuTu;
 }