示例#1
0
 public void ThemMau(MauSP obj)
 {
     using (GalaxyMobileEntities db = new GalaxyMobileEntities())
     {
         db.MauSPs.Add(obj);
         db.SaveChanges();
     }
 }
示例#2
0
 public void XaoMau(MauSP obj)
 {
     using (GalaxyMobileEntities db = new GalaxyMobileEntities())
     {
         db.MauSPs.Attach(obj);
         db.MauSPs.Remove(obj);
         db.SaveChanges();
     }
 }
示例#3
0
        private void btnXoaMau_Click(object sender, EventArgs e)
        {
            MauSP mau = new MauSP();

            mau.MaMau = txtboxMaMau.Text;
            mau.Mau   = txtBoxTenMau.Text;
            try
            {
                MauBUS.XoaMauSP(mau);
                MessageBox.Show("Xóa Thành Công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch { MessageBox.Show("Không Thể Thực Hiện Thao Tác", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            txtBoxTenMau.Visible = true;
        }
示例#4
0
        public ActionResult Create(ProductViewModel model, IFormFile[] files)
        {
            if (ModelState.IsValid)
            {
                SanPham sp = new SanPham();
                {
                    sp.MaSanphan  = model.MaSanphan;
                    sp.TenSanpham = model.TenSanpham;
                    sp.GiaSanpham = model.GiaSanpham;
                    sp.GiaKm      = model.GiaKm;
                    sp.Mota       = model.Mota;
                    sp.IdDanhmuc  = model.IdDanhmuc;
                    sp.SoLuong    = model.SoLuong;
                }
                _sanPhamRepository.Insert(sp);
                _unitOfWork.SaveChange();

                MauSP color = new MauSP();
                {
                    color.IdSanpahm = model.MaSanphan;
                    color.color     = model.color;
                }
                _mauRepositoty.Insert(color);
                _unitOfWork.SaveChange();

                SizeSP s = new SizeSP();
                {
                    s.IdSanpahm = model.MaSanphan;
                    s.size      = model.size;
                }
                _sizeRepositoty.Insert(s);
                _unitOfWork.SaveChange();

                AnhSanPham img = new AnhSanPham();
                {
                }
                _imageRepository.Insert(img);
                _unitOfWork.SaveChange();

                if (files != null)
                {
                    AnhSanPham anh = new AnhSanPham();
                    foreach (var photo in files)
                    {
                        var path   = Path.Combine(_environment.WebRootPath, "Images", photo.FileName);
                        var stream = new FileStream(path, FileMode.Create);
                        photo.CopyToAsync(stream);
                        anh.IdSanpahm = model.MaSanphan;
                        anh.Url       = path;
                        _imageRepository.Insert(anh);
                        _unitOfWork.SaveChange();
                    }
                }

                var uploads = Path.Combine(_environment.WebRootPath, "Images");
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
示例#5
0
 public static void XoaMauSP(MauSP obj)
 {
     db.XaoMau(obj);
 }
示例#6
0
 public static void ThemMauSP(MauSP obj)
 {
     db.ThemMau(obj);
 }