private void HienThiDanhSachSanPham() { try { lvSanPham.Items.Clear(); SanPhamBLL spBLL = new SanPhamBLL(); List <SanPham> dssp = spBLL.LayToanBoSanPham(); foreach (SanPham sp in dssp) { ListViewItem lvi = new ListViewItem(sp.MaSanPham); lvi.SubItems.Add(sp.TenSanPham); lvi.SubItems.Add(sp.DonGia + ""); lvi.SubItems.Add(sp.NgayNhap + ""); if (sp.NgayBan.Year < sp.NgayNhap.Year) { lvi.SubItems.Add("null"); } else { lvi.SubItems.Add(sp.NgayBan + ""); } lvi.SubItems.Add(sp.TonKho + ""); lvi.Tag = sp; lvSanPham.Items.Add(lvi); } } catch (Exception ex) { MessageBox.Show("Lỗi Khi lấy toàn bộ sản phẩm.\nChi tiết lỗi:\n" + ex.Message); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (lvSanPham.SelectedItems.Count == 0) { return; } SanPham curSP = lvSanPham.SelectedItems[0].Tag as SanPham; DialogResult ret = MessageBox.Show( "Bạn muốn xóa sản phẩm này?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ret == DialogResult.No) { return; } SanPhamBLL spBLL = new SanPhamBLL(); spBLL.XoaSanPham(curSP.MaSanPham); MessageBox.Show("Xóa sản phẩm thành công."); HienThiDanhSachSanPham(); } catch (Exception ex) { MessageBox.Show("Lỗi xóa sản phẩm.\nChi tiết lỗi:\n" + ex.Message); } }
public JsonResult LayDS(string ngay) { RMessage message = new RMessage { code = Resources.Global.Message_Error, success = false }; List <ThongTinSanPhamVayModel> rs = new List <ThongTinSanPhamVayModel>(); try { DateTime dtDate = DateTime.MinValue; if (ngay != "") { dtDate = DateTimeFormat.ConvertddMMyyyyToDateTime(ngay); } rs = new SanPhamBLL().LayThongTinSanPhamByID(3, dtDate); if (rs == null) { rs = new List <ThongTinSanPhamVayModel>(); } } catch (BusinessException ex) { message.success = false; message.code = ex.Message; } return(Json(rs, JsonRequestBehavior.AllowGet)); }
private void cboLoaiHang_SelectedIndexChanged(object sender, EventArgs e) { txtMaSanPham.Text = ""; if (cboLoaiHang.SelectedIndex == -1) { return; } try { LoaiHang lh = cboLoaiHang.SelectedItem as LoaiHang; SanPhamBLL spBLL = new SanPhamBLL(); int soLuongSanPhamCuaMaSinh = spBLL.ValidMaSanPhamToAdd(lh.MaSanPhamTuSinh); txtMaSanPham.Text = lh.MaSanPhamTuSinh + soLuongSanPhamCuaMaSinh; txtTenSanPham.Focus(); //current san pham currentSanPham = new SanPham() { MaLoaiHang = lh.MaLoaiHang, MaSanPham = txtMaSanPham.Text }; } catch (Exception ex) { MessageBox.Show("Lỗi sản phẩm Lấy valid mã sinh\n" + ex.Message); } }
private void btnThemSanPham_Click(object sender, EventArgs e) { if (!ShowError()) { return; } try { currentSanPham.TenSanPham = txtTenSanPham.Text; currentSanPham.DonGia = int.Parse(txtDonGia.Text); currentSanPham.TonKho = int.Parse(txtTonKho.Text); currentSanPham.NgayNhap = dtpNgayNhap.Value; currentSanPham.GhiChu = txtGhiChu.Text; //insert new sanpham to database SanPhamBLL spBLL = new SanPhamBLL(); spBLL.ThemSanPham(currentSanPham); MessageBox.Show("Thêm sản phẩm thành công."); HienThiDanhSachSanPham(); } catch (Exception ex) { MessageBox.Show("Lỗi thêm sản phẩm.\nChi tiết lỗi:\n" + ex.Message); } }
public frmNhapHang(Form f) { spbll = new SanPhamBLL(); khbll = new KhoHangBLL(); ds = new DataSet(); this.f = f; InitializeComponent(); }
private void HienThiDGVSP() { _SPBLL = new SanPhamBLL(); dgvSanPham.DataSource = _SPBLL.LayTatCaSanPham(); dgvSanPham.Columns["MaSP"].HeaderText="Mã SP"; dgvSanPham.Columns["TenSP"].HeaderText = "Tên SP"; dgvSanPham.Columns["DacTa"].HeaderText = "Đặc tả"; dgvSanPham.Columns["DonViTinh"].HeaderText = "Đơn vị tính"; dgvSanPham.Columns["SoLuongNhap"].HeaderText = "Tồn kho"; }
public frmXuatHang(Form f) { spbll = new SanPhamBLL(); ds = new DataSet(); dsspid = new DataSet(); dskh = new DataSet(); khachhangbll = new KhachHangBLL(); hoadonBLL = new HoaDonBLL(); this.f = f; InitializeComponent(); }
private void btnSua_Click(object sender, EventArgs e) { if (!ShowError()) { return; } try { if (lvSanPham.SelectedItems.Count == 0) { return; } SanPham curSP = lvSanPham.SelectedItems[0].Tag as SanPham; SanPhamBLL spBLL = new SanPhamBLL(); curSP.TenSanPham = txtTenSanPham.Text; curSP.DonGia = int.Parse(txtDonGia.Text); curSP.TonKho = int.Parse(txtTonKho.Text); curSP.NgayNhap = dtpNgayNhap.Value; curSP.GhiChu = txtGhiChu.Text; // cboLoaiHang_SelectedIndexChanged // current sanpham now exist if (currentSanPham.MaLoaiHang != curSP.MaLoaiHang) { //another elements currentSanPham.TenSanPham = txtTenSanPham.Text; currentSanPham.DonGia = int.Parse(txtDonGia.Text); currentSanPham.TonKho = int.Parse(txtTonKho.Text); currentSanPham.NgayNhap = dtpNgayNhap.Value; currentSanPham.GhiChu = txtGhiChu.Text; //delete the old spBLL.XoaSanPham(curSP.MaSanPham); //insert the new spBLL.ThemSanPham(currentSanPham); } else { spBLL.SuaSanPham(curSP); } MessageBox.Show("Sửa sản phẩm thành công."); HienThiDanhSachSanPham(); } catch (Exception ex) { MessageBox.Show("Lỗi sửa sản phẩm.\nChi tiết lỗi:\n" + ex.Message); } }
public ActionResult Xoa(int id) { try { bool result = false; result = new SanPhamBLL().Xoa(id); return(ToResponse(result)); } catch (BusinessException ex) { return(ToResponse(false, ex.Message)); } }
public void Tim() { Console.Clear(); ISanPhamBLL Sanpham = new SanPhamBLL(); List<Sanpham> list = Sanpham.TimSanPham(new Sanpham()); string masanpham1; Console.Write("Nhap ma san pham can tim:"); masanpham1 = Console.ReadLine(); for (int i = 0; i < list.Count; ++i) { if (masanpham1 == list[i].Masp) Console.WriteLine(list[i].Masp + "\t" + list[i].Tensp + "\t" + list[i].Maloai + "\t" + list[i].Soluong + "\t" + list[i].Giaban + "\t" + list[i].Nhasx); } }
/// <summary> /// hien thi dsSP cua loai hang vua chon len comboboxSanPham /// </summary> /// <param name="lh"></param> private void HienThiSanPham(LoaiHang lh) { cboTenSanPham.Items.Clear(); try { SanPhamBLL spBLL = new SanPhamBLL(); List <SanPham> dsSP = spBLL.LaySanPhamTheoMaLoaiHang(lh.MaLoaiHang); foreach (SanPham sp in dsSP) { cboTenSanPham.Items.Add(sp); } } catch (Exception ex) { MessageBox.Show("Lỗi hiển thị sản phẩm:\n" + ex.Message); } }
public ActionResult ThemMoi(string ma, string ngay) { try { if (new SanPhamBLL().Trung(ma) == true) { return(ToResponse(false, "Mã sản phẩm bị trùng!", 0)); } else { DateTime dtDate = DateTime.MinValue; try { if (ngay != "") { dtDate = DateTimeFormat.ConvertddMMyyyyToDateTime(ngay); } } catch (Exception) { return(ToResponse(false, "Ngày không đúng định dạng!", 0)); } int result = 0; SanPhamVayModel sp = new SanPhamVayModel(); sp.Ma = ma; sp.Ten = ma; sp.MaNguoiTao = GlobalData.User.IDUser; sp.NgayTao = dtDate; sp.MaDoiTac = 3; sp.Loai = 1; result = new SanPhamBLL().Them(sp); if (result > 0) { return(ToResponse(true, Resources.Global.Message_Succ, result)); } return(ToResponse(false, "Không thành công", 0)); } } catch (BusinessException ex) { return(ToResponse(false, ex.Message)); } }
private void DemSoSanPham() { _SPBLL = new SanPhamBLL(); dem = _SPBLL.DemTatCaSanPham(); }
public frmChiTietSP() { bll = new SanPhamBLL(); InitializeComponent(); }
public frmBaoHanh() { spBLL = new SanPhamBLL(); InitializeComponent(); }
public frmMaMoi() { ofdOpenFile = new OpenFileDialog(); InitializeComponent(); bll = new SanPhamBLL(); }
public JsonResult LayDSSanPhamByHS(int maDoiTac, int maHS) { List <SanPhamModel> rs = new SanPhamBLL().LaySanPhamByID(maDoiTac, maHS); return(ToJsonResponse(true, null, rs)); }
private void HienThiDGVSanPhamBan() { _SPBLL = new SanPhamBLL(); dgvSanPham.DataSource = _SPBLL.HienThiChiTietSanPhamBan(); dgvSanPham.Columns["MaHD"].Visible = false; dgvSanPham.Columns["MaNV"].Visible = false; //dgvSanPham.Columns["CuocPhiVanChuyen"].Visible = false; dgvSanPham.Columns["MaSP"].HeaderText = "Mã SP"; dgvSanPham.Columns["TenSP"].HeaderText = "Tên SP"; dgvSanPham.Columns["DonGiaBan"].HeaderText = "Đơn giá"; dgvSanPham.Columns["SoLuongNhap"].HeaderText = "Tồn kho"; dgvSanPham.Columns["DonViTinh"].HeaderText = "Đơn vị tính"; dgvSanPham.Columns["DacTa"].HeaderText = "Đặc tả"; dgvSanPham.Columns["DonViTinh"].Width = 120; dgvSanPham.Columns["TenSP"].Width = 120; dgvChiTietHD.Columns["CuocPhiVanChuyen"].Visible = false; LayMaHoaDonHienTai(); }
DataTable dssp = new DataTable();//table chứa danh sách sản phẩm public frmQuanLiSanPham(Form f) { this.f = f; InitializeComponent(); bll = new SanPhamBLL(); }