// hàm cập nhật loại hàng hoá public void CapNhatNhaCungCap(LoaiHangHoa lhh) { LoaiHangHoa _loaihanghoa = dbContext.LoaiHangHoas.Single <LoaiHangHoa>(x => x.id_loaihang == lhh.id_loaihang); _loaihanghoa.tenloaihang = lhh.tenloaihang; dbContext.SubmitChanges(); }
private void btnFind_Click(object sender, EventArgs e) { if (cmbNhaCCTK.SelectedValue != null) { DTO.NhaCungCap nhaCungCap = (DTO.NhaCungCap)cmbNhaCCTK.SelectedValue; LoaiHangHoa loaiHangHoa = (DTO.LoaiHangHoa)cmbLoaiTK.SelectedValue; pageNumber = 1; txtPageNumber.Text = "1"; totalPage = BUS.SanPhamBUS.DemSanPham(nhaCungCap.MaNCC, int.Parse(loaiHangHoa.Ma), txtTenTK.Text); totalPage = Utility.TinhKichThuocTrang(totalPage, pageSize); txtTotalPage.Text = totalPage.ToString(); dGVDanhSach.DataSource = BUS.SanPhamBUS.XemSanPhamTable(nhaCungCap.MaNCC, int.Parse(loaiHangHoa.Ma), txtTenTK.Text, pageNumber, pageSize); } else { pageNumber = 1; txtPageNumber.Text = "1"; totalPage = BUS.SanPhamBUS.DemSanPham("", 0, txtTenTK.Text); totalPage = Utility.TinhKichThuocTrang(totalPage, pageSize); txtTotalPage.Text = totalPage.ToString(); dGVDanhSach.DataSource = BUS.SanPhamBUS.XemSanPhamTable("", 0, txtTenTK.Text, pageNumber, pageSize); AddGridTableStyle(); } }
public async Task <ActionResult> Edit(int id, LoaiHangHoaViewModel loaiHangHoa) { //Get loại hàng hóa muốn update (find by ID) LoaiHangHoa edit = (LoaiHangHoa)await _loaiHangHoaKhoBus.Find(id); if (edit == null) { return(HttpNotFound()); } else { // Access Update from Business try { await _loaiHangHoaKhoBus.Update(loaiHangHoa, edit); SetAlert("Đã cập nhật loại hàng hóa thành công!!!", "success"); } catch { TempData["loaiHangHoa"] = loaiHangHoa; SetAlert("Đã xảy ra lỗi! Bạn hãy cập nhật lại", "error"); } } return(RedirectToAction("Index")); }
public static LoaiHangHoaDTO MappingLoaiHangHoaDTO(this LoaiHangHoa loaiHangHoa) { return(new LoaiHangHoaDTO { Id = loaiHangHoa.Id, Ten = loaiHangHoa.Ten, }); }
public ActionResult DeleteConfirmed(string id) { LoaiHangHoa loaiHangHoa = db.LoaiHangHoas.Find(id); db.LoaiHangHoas.Remove(loaiHangHoa); db.SaveChanges(); return(RedirectToAction("Index")); }
public virtual void Update(LoaiHangHoa _item) { if (_item == null) { throw new ArgumentNullException("HangHoa"); } _loaihanghoaRepository.Update(_item); }
public ActionResult DeleteConfirmed(int id) { LoaiHangHoa loaiHangHoa = db.LoaiHangHoas.Find(id); loaiHangHoa.IsDeleted = true; db.SaveChanges(); SetAlert("Xóa loại hàng hóa thành công!", "success"); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaLHH,TenLHH,GhiChu,MaGH")] LoaiHangHoa loaiHangHoa) { if (ModelState.IsValid) { db.Entry(loaiHangHoa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiHangHoa)); }
public ActionResult Create(LoaiHangHoa lhh) { if (ModelState.IsValid) { db.LoaiHangHoas.Add(lhh); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public async Task Update(object inputModel, object editModel) { LoaiHangHoa input = (LoaiHangHoa)inputModel; LoaiHangHoa editLoaiHangHoa = (LoaiHangHoa)editModel; editLoaiHangHoa.TenLoaiHangHoa = input.TenLoaiHangHoa; editLoaiHangHoa.PhanTramLoiNhuan = input.PhanTramLoiNhuan; await _loaiHangHoaRepo.EditAsync(editLoaiHangHoa); }
public ActionResult Edit(LoaiHangHoa lhh) { if (ModelState.IsValid) { db.Entry(lhh).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lhh)); }
public async Task Create(object model) { var loaihanghoa = new LoaiHangHoa(); LoaiHangHoa input = (LoaiHangHoa)model; loaihanghoa.TenLoaiHangHoa = input.TenLoaiHangHoa; loaihanghoa.PhanTramLoiNhuan = input.PhanTramLoiNhuan; await _loaiHangHoaRepo.InsertAsync(loaihanghoa); }
public int UpdateData(LoaiHangHoa HH) { SqlParameter[] para = { new SqlParameter("MaLHH", HH.MaLHH), new SqlParameter("TenLHH", HH.TenLHH), new SqlParameter("MaGH", HH.MaGH), new SqlParameter("GhiChu", HH.GhiChu) }; return(_connect.ExcuteSQL("SP_SuaLoaiHangHoa ", para)); }
public ActionResult Create([Bind(Include = "MaLHH,TenLHH,GhiChu,MaGH")] LoaiHangHoa loaiHangHoa) { if (ModelState.IsValid) { db.LoaiHangHoas.Add(loaiHangHoa); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiHangHoa)); }
public ActionResult Edit([Bind(Include = "MaLoaiHangHoa,TenLoaiHangHoa,GioiTinh,IsDeleted")] LoaiHangHoa loaiHangHoa) { if (ModelState.IsValid) { db.Entry(loaiHangHoa).State = EntityState.Modified; db.SaveChanges(); SetAlert("Sửa loại hàng hóa thành công!", "success"); return(RedirectToAction("Index")); } return(View(loaiHangHoa)); }
public async Task <IActionResult> EditConfirmed( int id, [Bind("Id,TenLoaiHangHoa")] LoaiHangHoa LoaiHangHoa, bool?modal, bool?redirect) { AddInfoToViewData(); bool isModal = modal ?? false; bool isRedirect = redirect ?? true; Message message = new Message(); if (id != LoaiHangHoa.Id) { message.Type = MessageType.Error; message.Header = _sharedLocalizer["DefaultErrorHeader"]; message.Content = _sharedLocalizer["Invalid"]; } else if (ModelState.IsValid) { try { await _bookStoreData.UpdateLoaiHangHoa(LoaiHangHoa); message.Type = MessageType.Success; message.Header = _sharedLocalizer["Success"]; message.Content = string.Format( "{0} {1}", _sharedLocalizer[action], _sharedLocalizer[controller].Value.ToLower()); if (isModal) { message.Results["Reload"] = true; } if (isRedirect) { message.Results["RedirectUrl"] = Url.Action( "Details", new { id = LoaiHangHoa.Id }); } } catch (Exception ex) { message.Type = MessageType.Error; message.Header = _sharedLocalizer["DefaultErrorHeader"]; message.Content = _sharedLocalizer[ex.GetType().FullName]; } } return(Json(message)); }
private void loạiHangHóaToolStripMenuItem_Click(object sender, EventArgs e) { panel1.Controls.Clear(); Form form = new LoaiHangHoa(); SetCenter(form); form.TopLevel = false; panel1.Controls.Add(form); form.Show(); }
public ActionResult Create([Bind(Include = "MaLoaiHangHoa,TenLoaiHangHoa,GioiTinh,IsDeleted")] LoaiHangHoa loaiHangHoa) { if (ModelState.IsValid) { db.LoaiHangHoas.Add(loaiHangHoa); db.SaveChanges(); SetAlert("Tạo loại hàng hóa thành công!", "success"); return(RedirectToAction("Index")); } return(View(loaiHangHoa)); }
public string getTenLoai(object MaLoai) { try { QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1(); int maloai = Convert.ToInt32(MaLoai.ToString()); LoaiHangHoa data = db.LoaiHangHoa.FirstOrDefault(x => x.MaLoai == maloai); return(data.TenLoai); } catch { return(""); } }
// GET: LoaiHangHoas/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LoaiHangHoa loaiHangHoa = db.LoaiHangHoas.Find(id); if (loaiHangHoa == null) { return(HttpNotFound()); } return(View(loaiHangHoa)); }
public async Task <ActionResult> Create(LoaiHangHoa loaiHangHoa) { try { await _loaiHangHoaBus.Create(loaiHangHoa); SetAlert("Đã thêm loại sản phẩm thành công!!!", "success"); } catch { TempData["loaiHangHoa"] = loaiHangHoa; SetAlert("Đã xảy ra lỗi! Bạn hãy thêm lại", "error"); } return(RedirectToAction("Index")); }
public List <LoaiHangHoa> LoadListLoaiHH() { List <LoaiHangHoa> listLHH = new List <LoaiHangHoa>(); string query = "Select * from LoaiHH"; DataTable data = DataProvider.Instance.ExcuteQuery(query); foreach (DataRow item in data.Rows) { LoaiHangHoa LoaiHH = new LoaiHangHoa(item); listLHH.Add(LoaiHH); } return(listLHH); }
private void cbLoaiHangHoa_SelectedIndexChanged(object sender, EventArgs e) { LoaiHangHoa selectedItem = cbLoaiHangHoa.SelectedItem as LoaiHangHoa; if (selectedItem == null) { return; } if (selectedItem.Id == 0) { LoadHangHoa(); return; } var dsHangHoa = HangHoaDAO.Instance.GetAllHangHoaByLoaiHangHoa(selectedItem.Id); RenderDanhSachHangHoa(dsHangHoa); }
private void btnAdd_Click(object sender, EventArgs e) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(txtMaLoaiHangHoa.Text, txtTenLoaiHangHoa.Text); if (maintainHangHoa != null) { loaiHangHoa.SaveToDatabase(); maintainHangHoa.AddNewLHH(new KeyValuePair <string, int>(txtTenLoaiHangHoa.Text, Convert.ToInt32(txtMaLoaiHangHoa.Text))); } else { if (btnAdd.Text == "Thêm") { loaiHangHoa.SaveToDatabase(); } else { loaiHangHoa.UpdateLoaiHangHoaToDatabase(); } mainForm.LoadToDataGridView(); } this.Close(); }
private void cbHangHoaTimKiemLoaiHang_SelectedIndexChanged(object sender, EventArgs e) { if (cbHangHoaTimKiemLoaiHang.SelectedIndex < 0) { return; } LoaiHangHoa selectedCategory = cbHangHoaTimKiemLoaiHang.SelectedItem as LoaiHangHoa; string tenLoai = selectedCategory.TenLoai; if (tenLoai.Equals("Tất cả")) { dsHangHoaBinding.DataSource = dsHangHoa; return; } try { dsHangHoaBinding.DataSource = dsHangHoa.Where(item => item.TenLoai.Equals(tenLoai)); } catch { dsHangHoaBinding.DataSource = new List <HangHoaRead>(); } }
public async Task <ActionResult> Edit(int id, LoaiHangHoa loaiHangHoa) { LoaiHangHoa edit = (LoaiHangHoa)await _loaiHangHoaBus.Find(id); if (edit == null) { return(HttpNotFound()); } else { try { await _loaiHangHoaBus.Update(loaiHangHoa, edit); SetAlert("Đã cập nhật loại sản phẩm thành công!!!", "success"); } catch { SetAlert("Đã xảy ra lỗi! Bạn hãy cập nhật lại", "error"); return(RedirectToAction("Edit")); } } return(RedirectToAction("Index")); }
public void XoaLoaiHangHoa(LoaiHangHoa LoaiHangHoa) { _context.LoaiHangHoas.Remove(LoaiHangHoa); _context.SaveChanges(); }
public async Task <int> AddLoaiHangHoa(LoaiHangHoa loaiHangHoa) { await _context.LoaiHangHoa.AddAsync(loaiHangHoa); return(await _context.SaveChangesAsync()); }
public LoaiHangHoa GetDataFromDialog() { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(txtMaLoaiHangHoa.Text, txtTenLoaiHangHoa.Text); return(loaiHangHoa); }
public async Task <int> UpdateLoaiHangHoa(LoaiHangHoa loaiHangHoa) { _context.Entry(loaiHangHoa).State = EntityState.Modified; return(await _context.SaveChangesAsync()); }