protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            SanPhamDTO sp  = SanPhamBUS.LayDSSanPhamCapNhat(txtmasp.Text);
            SanPhamDTO sp2 = SanPhamBUS.LayDSSanPhamCapNhat(txtmasp.Text);

            sp.TenSP    = txtTenSP.Text;
            sp.ThongTin = txtThongTin.Text;
            sp.GiaTien  = Convert.ToInt32(txtGiaTien.Text);
            sp.MaLoaiSp = ddlSanPham.SelectedValue.ToString();
            if (imgHinhSanPham.HasFile)
            {
                string sTenfile;
                sTenfile = imgHinhSanPham.FileName;
                imgHinhSanPham.SaveAs(MapPath("../images/" + sTenfile));
                sp.AnhMinhHoa = sTenfile.ToString();
            }
            else
            {
                sp2.AnhMinhHoa = sp.AnhMinhHoa;
            }
            if (SanPhamBUS.CapNhatSP(sp, txtmasp.Text))
            {
                load();
                Response.Write("<script>alert('Cập nhật sản phẩm thành công!')</script>");
            }
            else
            {
                Response.Write("<script>alert('Cập nhật sản phẩm thất bại!')</script>");
            }
        }
        private void FormChiTietThanhVien_Load(object sender, EventArgs e)
        {
            ThanhVienDTO thanhVienDTO = ThanhVienBUS.SelectThanhVienById(maThanhVien);

            labelMaThanhVien.Text  = "Mã thành viên: " + maThanhVien;
            labelTenThanhVien.Text = "Tên thành viên: " + thanhVienDTO.TenThanhVien;
            labelDiaChi.Text       = "Địa chỉ: " + thanhVienDTO.DiaChi;
            labelTongCV.Text       = "Tổng CV: " + thanhVienDTO.CV.ToString();

            List <PhieuXuatDTO> listPhieuXuatDTO = PhieuXuatBUS.SelectPhieuXuatByMaThanhVien(maThanhVien);

            if (listPhieuXuatDTO != null)
            {
                dataGridViewChiTiet.Rows.Clear();
                List <ChiTietPhieuXuatDTO> listChiTietPhieuXuatDTO = new List <ChiTietPhieuXuatDTO>();
                foreach (PhieuXuatDTO itemPhieuXuat in listPhieuXuatDTO)
                {
                    listChiTietPhieuXuatDTO = ChiTietPhieuXuatBUS.SelectChiTietPhieuXuatByMaPhieuXuat(itemPhieuXuat.MaPhieuXuat);
                    if (listChiTietPhieuXuatDTO != null)
                    {
                        foreach (ChiTietPhieuXuatDTO itemCTPX in listChiTietPhieuXuatDTO)
                        {
                            dataGridViewChiTiet.Rows.Add(
                                itemPhieuXuat.MaPhieuXuat,
                                itemPhieuXuat.NgayBan.ToString("dd/MM/yyyy"),
                                NhanVienBUS.SelectNhanVienById(itemPhieuXuat.MaNhanVien).TenNhanVien,
                                SanPhamBUS.SelectSanPhamById(itemCTPX.MaSanPham).TenSanPham,
                                itemCTPX.SoLuong.ToString(),
                                string.Format("{0:#,0.##}", itemCTPX.ThanhTien)
                                );
                        }
                    }
                }
            }
        }
        void CapNhatSoLuongSanPham(string masp, int sl, int mode)
        {
            var kq     = sp.Where(p => p.MASP == masp).FirstOrDefault();
            int sl_ton = Convert.ToInt32(kq.SL_TON);

            if (mode == 0)
            {
                kq.SL_TON = sl_ton - sl;
            }
            // sl ton =100
            // sl trong ct = 50
            // sl cap nhat =40
            if (mode == 1)
            {
                if (sl < sl_cthd)
                {
                    kq.SL_TON = sl_ton + (sl_cthd - sl);
                }
                else if (sl > sl_cthd)
                {
                    kq.SL_TON = sl_ton - (sl - sl_cthd);
                }
            }
            if (mode == 2)
            {
                kq.SL_TON = sl_ton + sl_cthd;
            }
            SanPhamBUS.SuaSanPham(kq);
        }
Esempio n. 4
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridView    gv  = (GridView)sender;
        GridViewRow row = GridView1.Rows[e.RowIndex];

        string     sMaSP = gv.DataKeys[e.RowIndex]["MaSP"].ToString();
        SanPhamDTO spDTO = new SanPhamDTO();

        spDTO.Ma = int.Parse(sMaSP);
        if (gv.Rows.Count == 1)
        {
            CurrentPage--;
        }

        string sAvatar = row.Cells[2].Text;

        try
        {
            FileInfo file = new FileInfo(Server.MapPath(sAvatar));
            if (file.Exists)
            {
                File.Delete(Server.MapPath(sAvatar));
            }
        }
        catch
        {
        }

        SanPhamBUS.XoaSanPham(spDTO);

        BindItemsList();
    }
 // sự kiện load khi khởi động chương trình
 private void frmMain_Load(object sender, EventArgs e)
 {
     spBUS = new SanPhamBUS();
     showSanPham();
     lockControl();
     clearData();
 }
Esempio n. 6
0
        private void LoadDanhSachSPSP()
        {
            SanPhamBUS bus = new SanPhamBUS();

            lsdto = new List <SanPhamDTO>();
            lsdto = bus.LayDSSanPhamTheoLoai(cboLoaiSP.SelectedValue.ToString()).FindAll(o => o.MaLoaiSP == cboLoaiSP.SelectedValue.ToString());

            //colBHTenSP.DataSource = lsdto;
            //colBHTenSP.DisplayMember = "TenSP";
            //colBHTenSP.ValueMember = "MaSP";


            for (int i = 0; i < lsdto.Count; i++)
            {
                ListViewItem lvi = new ListViewItem(lsdto[i].TenSP);
                lvi.SubItems.Add(lsdto[i].TenSP);
                if (File.Exists(lsdto[i].HinhAnh))
                {
                    byte[]       byteHA = File.ReadAllBytes(lsdto[i].HinhAnh);
                    MemoryStream ms     = new MemoryStream(byteHA);
                    Image        img    = Image.FromStream(ms);
                    imgnho.Images.Add(img);

                    lvi.ImageIndex = imgnho.Images.Count - 1;
                }
                lsvNhapSP.Items.Add(lvi);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Tab danh sach san pham
        /// </summary>
        void LoadDataTabDSSP()
        {
            lstSanPham    = SanPhamBUS.LayDanhSachSanPham();
            lstNhaPP      = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi();
            lstAnhMinhHoa = AnhMinhHoaSPBUS.LayDanhSachAnhMinhHoa();
            //var kq = from sp in lstSanPham
            //         select new
            //         {
            //             sp.MASP,
            //             sp.TENSP,
            //             sp.SL_TON,
            //             sp.GIABAN,
            //             sp.DVT,
            //             sp.LOAISANPHAM.TENLOAI,
            //             sp.NHAPHANPHOI.TENNPP
            //         };
            var kq = from sp in lstSanPham
                     join npp in lstNhaPP
                     on sp.MANPP equals npp.MANPP
                     select new
            {
                sp.MASP,
                sp.TENSP,
                sp.SL_TON,
                sp.GIABAN,
                sp.DVT,
                sp.LOAISANPHAM.TENLOAI,
                npp.TENNPP
            };

            this.dgvDSSanPham.DataSource          = kq.ToList();
            this.dgvDSSanPham.AutoGenerateColumns = false;
        }
Esempio n. 8
0
 public frmDonHangChiTiet()
 {
     InitializeComponent();
     donhangchitietBUS = new DonHangChiTietBUS();
     sanphamBUS        = new SanPhamBUS();
     donhangBUS        = new DonHangBUS();
 }
Esempio n. 9
0
        private void FormChonSanPham_Load(object sender, EventArgs e)
        {
            List <SanPhamDTO> sanPhamDTO = new List <SanPhamDTO>();

            sanPhamDTO = SanPhamBUS.SelectSanPhamAll();

            for (int i = 0; i < sanPhamDTO.Count; i++)
            {
                dataGridView_ChoSanPham.Rows.Add(i + 1, sanPhamDTO[i].MaSanPham, sanPhamDTO[i].TenSanPham, LoaiSanPhamBUS.SelectLoaiSanPhamById(sanPhamDTO[i].MaLoaiSanPham).TenLoaiSanPham, false);
            }


            List <LoaiSanPhamDTO> lstcbspDTO = LoaiSanPhamBUS.SelectLoaiSanPhamAll();

            LoaiSanPhamDTO all = new LoaiSanPhamDTO();

            all.MaLoaiSanPham  = "Tất cả";
            all.TenLoaiSanPham = "Tất cả";

            lstcbspDTO.Insert(0, all);

            comboBoxLoaiSanPham.DisplayMember = "TenLoaiSanPham";
            comboBoxLoaiSanPham.ValueMember   = "TenLoaiSanPham";
            comboBoxLoaiSanPham.DataSource    = lstcbspDTO;
            comboBoxLoaiSanPham.SelectedIndex = 0;
        }
Esempio n. 10
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            SanPhamDTO sp = new SanPhamDTO();

            sp.Ten    = txtTen.Text;
            sp.MoTa   = txtMota.Text;
            sp.Gia    = Convert.ToInt32(txtGia.Text);
            sp.HSD    = txtHSD.Text;
            sp.LoaiSP = Convert.ToInt32(cbLoaiSP.SelectedValue);
            sp.NCC    = Convert.ToInt32(cbNCC.SelectedValue);
            sp.Hinh   = "";
            sp.TThai  = 1;
            if (radAn.Checked)
            {
                sp.TThai = 0;
            }
            int id = SanPhamBUS.themSanPham(sp);

            if (openFileDialog1.Tag != null)
            {
                string filePath = (string)openFileDialog1.Tag;
                string img      = id + Path.GetExtension(filePath);
                File.Copy(filePath, "images\\" + img, true);
                SanPhamBUS.capNhatAnhSP(id, img);
            }
            MessageBox.Show("Thêm sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Esempio n. 11
0
        //
        // Phương thức event khi nhấn Thêm ở tab hoá đơn
        // Mỗi lần nhấn thêm 1 sản phẩm vào data grid view
        //
        private void BtnAdd4_Click(object sender, EventArgs e)
        {
            try
            {
                int yeuCau = Convert.ToInt32(txtSoL4.Text);
                int thucTe = new SanPhamBUS().GetSoL(txtTenSP4.Text);
                int maSP   = new SanPhamBUS().GetMaSP(txtTenSP4.Text);

                if (yeuCau > thucTe || yeuCau == 0)
                {
                    MessageBox.Show("Sản phẩm không đủ số lượng yêu cầu");
                }
                else
                {
                    int donGiaBan = new SanPhamBUS().GetDGB(txtTenSP4.Text);
                    int tong      = donGiaBan * Convert.ToInt32(txtSoL4.Text);
                    int thanhTien = Convert.ToInt32(txtThanhTien4.Text);
                    gridData4.Rows.Add(txtTenSP4.Text, txtSoL4.Text, donGiaBan.ToString(), tong.ToString());

                    thanhTien         += tong;
                    txtTenSP4.Text     = "";
                    txtSoL4.Text       = "";
                    txtThanhTien4.Text = thanhTien.ToString();
                }

                txtTenSP4.Text = "";
                txtSoL4.Text   = "";
            }
            catch
            {
                MessageBox.Show("Kiểm tra lại thông tin vừa nhập");
            }
        }
Esempio n. 12
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (_sp != null)
            {
                _sp.Ten  = txtTen.Text;
                _sp.Gia  = Convert.ToInt32(txtGia.Text);
                _sp.MoTa = txtMota.Text;

                _sp.LoaiSP = Convert.ToInt32(cbLoaiSP.SelectedValue);
                _sp.NCC    = Convert.ToInt32(cbNCC.SelectedValue);
                _sp.HSD    = txtHSD.Text;
                _sp.TThai  = 1;

                if (radAn.Checked)
                {
                    _sp.TThai = 0;
                }
                if (openFileDialog1.Tag != null)
                {
                    string filePath = (string)openFileDialog1.Tag;
                    File.Copy(filePath, "images\\" + _sp.Ma.ToString() + Path.GetExtension(filePath), true);
                    _sp.Hinh = _sp.Ma.ToString() + Path.GetExtension(filePath);
                }
                if (SanPhamBUS.suaSanPham(_sp))
                {
                    MessageBox.Show("Sửa sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                SanPhamBUS insertSanPham = new SanPhamBUS();
                SanPhamDTO sanPham       = new SanPhamDTO();

                sanPham.IdDanhMucSanPham        = int.Parse(dropDanhMucSanPham.SelectedItem.Value);
                sanPham.TenSanPham              = txtTenSanPham.Text;       // txtTenSanPham là ID của TextBox
                sanPham.MoTaSanPham             = CKEditorControlMoTa.Text; //txtTenSanPham là ID của TextBox
                sanPham.HinhSanPham.LinkSanPham = fileuploadHinhSanPham.FileBytes;
                // fileuploadHinhSanPham là ID của điều khiển FileUpLoad
                sanPham.GiaSanPham     = int.Parse(txtGia.Text); // txtGia là ID của TextBox
                insertSanPham._sanPham = sanPham;
                try
                {
                    insertSanPham.Insert();
                }
                catch
                {
                    Response.Redirect("../Trangloi.aspx");
                }
                // tắt khúc này vì chưa có trang SanPham.aspx nên khi add thành công thì nó chuyển qua trang SanPham sẽ lỗi
                //Response.Redirect("SanPham.aspx");
            }
        }
 public void Test_DeleteSP_Success()
 {
     spBUS = new SanPhamBUS();
     Assert.AreEqual(14, spBUS.LoadSPBUS().Count);
     spBUS.DeleteSPBUS(17);
     Assert.AreEqual(13, spBUS.LoadSPBUS().Count);
 }
Esempio n. 15
0
        private void btnTimTheoGia_Click(object sender, EventArgs e)
        {
            int giaTu  = txtTGLonHon.Text != "" ? Convert.ToInt32(txtTGLonHon.Text) : 0;
            int giaDen = txtTGNhoHon.Text != "" ? Convert.ToInt32(txtTGNhoHon.Text) : 0;

            LoadSanPham(SanPhamBUS.timTheoGiaSP(giaTu, giaDen, Convert.ToInt32(cbbTGLoai.SelectedIndex)));
        }
Esempio n. 16
0
        private void btn_Xong_Click(object sender, EventArgs e)
        {
            bool flag = false;

            for (int i = 0; i < dataGridView_ChoSanPham.RowCount; i++)
            {
                if (dataGridView_ChoSanPham.Rows[i].Cells[clCheck.Index].Value.ToString() == "True")
                {
                    listsanPhamDTO_ChonSanPham.Add(SanPhamBUS.SelectSanPhamById(dataGridView_ChoSanPham.Rows[i].Cells[clMaSanPham.Index].Value.ToString()));
                    flag = true;
                }
            }

            if (flag == false)
            {
                DialogResult result = MessageBox.Show("Chưa có sản phẩm nào được chọn, bạn muốn thoát?", "Sản phẩm", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.OK)
                {
                    huy = true;
                    this.Dispose();
                }
            }
            else
            {
                huy = false;
                this.Dispose();
            }
        }
Esempio n. 17
0
        private void loadtheoten()
        {
            SanPhamBUS bus = new SanPhamBUS();

            lsdto = bus.TimKiemTheoMa(txtTimSP.Text);
            lsdto = new List <SanPhamDTO>();
            lsdto = bus.TimKiemTheoMa(txtTimSP.Text).FindAll(o => o.TinhTrang == 1);
            lsvNhapSP.Items.Clear();
            //colBHTenSP.DataSource = lsdto;
            //colBHTenSP.DisplayMember = "TenSP";
            //colBHTenSP.ValueMember = "MaSP";

            for (int i = 0; i < lsdto.Count; i++)
            {
                ListViewItem lvi = new ListViewItem(lsdto[i].TenSP);
                lvi.SubItems.Add(lsdto[i].TenSP);
                if (File.Exists(lsdto[i].HinhAnh))
                {
                    byte[]       byteHA = File.ReadAllBytes(lsdto[i].HinhAnh);
                    MemoryStream ms     = new MemoryStream(byteHA);
                    Image        img    = Image.FromStream(ms);
                    imgnho.Images.Add(img);

                    lvi.ImageIndex = imgnho.Images.Count - 1;
                }
                else
                {
                    lsdto[i].HinhAnh = null;
                }
                lsvNhapSP.Items.Add(lvi);
            }
        }
Esempio n. 18
0
        private void frmQuanLySanPham_Load(object sender, EventArgs e)
        {
            SanPhamBUS SPBUS = new SanPhamBUS();

            dgvDanhSachSP.AutoGenerateColumns = false;
            dgvDanhSachSP.DataSource          = SPBUS.LayDanhSachSanPham();
        }
Esempio n. 19
0
        private void btnModeThem_Click(object sender, EventArgs e)
        {
            if (this.txtMaSp.Text == string.Empty ||
                this.txtTenSP.Text == string.Empty ||
                this.txtGiaBanSp.Text == string.Empty ||
                this.txtSLTonSp.Text == string.Empty ||
                this.txtDVT.Text == string.Empty ||
                this.txtLoaiSanPham.Text == string.Empty ||
                this.txtNhaPhanPhoi.Text == string.Empty ||
                this.imgSanPham.Image == null)
            {
                MessageBox.Show("Bạn chưa điền đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            SANPHAM sanpham = new SANPHAM();

            sanpham.MASP      = this.txtMaSp.Text;
            sanpham.TENSP     = this.txtTenSP.Text;
            sanpham.GIABAN    = Convert.ToInt32(this.txtGiaBanSp.Text);
            sanpham.SL_TON    = Convert.ToInt32(this.txtSLTonSp.Text);
            sanpham.DVT       = this.txtDVT.Text;
            sanpham.MALOAI    = this.txtLoaiSanPham.Text;
            sanpham.MANPP     = this.txtNhaPhanPhoi.Text;
            sanpham.TRANGTHAI = true;

            string maAnh = this.txtMaSp.Text + "_" + DateTime.Now.ToString("dd-MM-yy-h-m-s");

            string[] chuoiXuLiTenAnh = this.tenAnhMinhHoa.Split('.');
            this.tenAnhMinhHoa = this.txtMaSp.Text + "_" + DateTime.Now.ToString("dd-MM-yy-h-m-s") + "." + chuoiXuLiTenAnh[1];
            ANHMINHHOASP anhMH = new ANHMINHHOASP {
                MAANH = maAnh, TENANHMINHHOA = this.tenAnhMinhHoa, MASP = sanpham.MASP, TRANGTHAI = true
            };

            if (!SanPhamBUS.KiemTraMaSPTonTai(sanpham.MASP))
            {
                try
                {
                    SanPhamBUS.ThemSanPham(sanpham);
                    AnhMinhHoaSPBUS.ThemAnhMinhHoa(anhMH);

                    this.imgSanPham.Image.Save(patch + anhMH.TENANHMINHHOA);
                    MessageBox.Show("Thêm sản phẩm thành công !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                    LoadDataTabQLSP();
                    LoadDataTabDSSP();
                    string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã thêm một sản phẩm (" + sanpham.MASP + ")";
                    LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
                    {
                        NGAYTAO       = DateTime.Now.Date,
                        NV_THAOTAC    = this.manv,
                        VITRI_THAOTAC = this.vitrithaotac,
                        GHICHU        = lsth
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Esempio n. 20
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            int    categoryid, Price, userid;
            string id, name, des;

            id         = txtID.Text.Trim();
            name       = txtTenDT.Text.Trim();
            categoryid = int.Parse(txtMaloai.Text.Trim());
            des        = txtMota.Text.Trim();
            Price      = int.Parse(txtGia.Text.Trim());

            userid = int.Parse(txtUserID.Text.Trim());

            SanPhamDTO spo = new SanPhamDTO(id, name, categoryid, des, Price, userid);

            try
            {
                int i = new SanPhamBUS().Add(spo);
                dgvSanPham.DataSource = GetProductGUI();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 21
0
 private void txtMaSp_Validated(object sender, EventArgs e)
 {
     if (SanPhamBUS.KiemTraMaSPTonTai(this.txtMaSp.Text))
     {
         MessageBox.Show("Mã sản phẩm đã tồn tại !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.txtMaSp.Focus();
         return;
     }
     if (this.txtMaSp.Text == string.Empty)
     {
         return;
     }
     if (this.txtMaSp.Text.Length > 10)
     {
         MessageBox.Show("Mã sản phẩm không được vượt quá 10 kí tự !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.txtMaSp.Focus();
         return;
     }
     if (!KiemtraDinhDangMASP(this.txtMaSp.Text))
     {
         MessageBox.Show("Mã sản phẩm không đúng định dạng !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.txtMaSp.Focus();
         return;
     }
 }
Esempio n. 22
0
        //Status=0 Load_Default(), thanhphanNhap và DataGripView khi status = 0
        private void Load_Create()
        {
            Load_Default();

            //lamlai thanh phan nhap
            txtMaThanhVien.Clear();
            txtTenKhachHang.Clear();
            txtDiaChi.Clear();
            txtTenKhachHang.ReadOnly = false;
            txtDiaChi.ReadOnly       = false;

            //Load Datagripview
            int stt = 1;
            List <SanPhamDTO> listSanPhamDTO = SanPhamBUS.SelectSanPhamAll();

            if (listSanPhamDTO != null)
            {
                dataGridView_XuatHang.Rows.Clear();
                SanPhamDTO sanPhamDTO = new SanPhamDTO();
                for (int i = 0; i < listSanPhamDTO.Count; i++)
                {
                    sanPhamDTO = listSanPhamDTO[i];
                    dataGridView_XuatHang.Rows.Add(stt, sanPhamDTO.MaSanPham, sanPhamDTO.TenSanPham, sanPhamDTO.CV, sanPhamDTO.DonGia, sanPhamDTO.SoLuongTon, 0, 0);
                    stt++;
                }
            }
            btnTao.Enabled = false;
        }
Esempio n. 23
0
        public void LoadDataSanPham()
        {
            
            SanPhamBUS sp = new SanPhamBUS();
            dataSanPham.DataSource = sp.GetData();

        }
Esempio n. 24
0
        private void FrmTongQuan_Load(object sender, EventArgs e)
        {
            HDBanBUS bus = new HDBanBUS();
            HDBanDTO dto = bus.DemMaHDBan();

            txtDemHDB.Text = dto.MaHDBan;
            //Load SO HD Nhap
            HDNhapBUS bus1 = new HDNhapBUS();
            HDNhapDTO dto1 = bus1.DemMaHDNhap();

            txtDemHDN.Text = dto1.MaHDNhap;
            //Load TongSP Da Ban
            SanPhamBUS  bus2 = new SanPhamBUS();
            SP_CTHDBDTO dto2 = bus2.TongSoSPBan();

            txtTongSPBan.Text = dto2.SLSP.ToString();
            //Load TongSP Da Nhap
            SanPhamBUS       bus3 = new SanPhamBUS();
            SP_CTHDN_LSP_HDN dto3 = bus3.TongSoSPNhap();

            txtTongSPDaNhap.Text = dto3.TongSL.ToString();
            //Load HD huy
            HDBanBUS bus4 = new HDBanBUS();
            HDBanDTO dto4 = bus4.DemSoHDHuy();

            txtTongSPDaNhap.Text = dto4.MaHDBan.ToString();
            //loadTongDoanhThu
            HDBanBUS bus5 = new HDBanBUS();
            HDBanDTO dto5 = bus5.TongDoanhThuTrongNgay();

            txtTongDT.Text = dto5.TongTien.ToString("#.##");
        }
        private void btnAddAddSanPham_Click(object sender, EventArgs e)
        {
            try
            {
                SANPHAM SP = new SANPHAM();
                SP.MASP       = tbMaSPAddSanPham.Text;
                SP.TENSP      = tbTenSPAddSanPham.Text;
                SP.THUONGHIEU = tbThuongHieuAddSanPham.Text;
                SP.THONGTIN   = rtbThongTinAddSanPham.Text;
                SP.GIANHAP    = Convert.ToDecimal(tbGiaAddSanPham.Text);
                SP.GIABAN     = Convert.ToDecimal((SP.GIANHAP * (decimal)0.05) + SP.GIANHAP);
                SP.LOAISP     = tbLoaiSP.Text;
                SP.IMAGES     = tbImages.Text;
                SP.SOLUONG    = Convert.ToInt32(nudSLuong.Value);
                SP.MANK       = cbbMaKhoAddSanPham.Text;
                SP.MANCC      = cbbMaNCCAddSanPham.Text;
                SP.TIMENHAP   = DateTime.Now;

                SanPhamBUS SPBUS = new SanPhamBUS();
                SPBUS.insertSP(SP);
                pathImage();
                this.Dispose();
            }
            catch { }
        }
        private void btnLapPhieuMoi_Click(object sender, EventArgs e)
        {
            i                      = 0;
            Tien                   = 0;
            txtTongtien.Text       = "0";
            btnLapPhieuMoi.Enabled = false;
            btnThemSP.Enabled      = true;
            cboNCC.Enabled         = false;
            btnIn.Enabled          = true;
            txtSoPĐ.Text           = DonDatHangBUS.GetIDPhieuDat();
            txtMaSP.ResetText();
            txtTenSP.ResetText();
            txtSoLuong.ResetText();
            txtGia.ResetText();
            dtkNgayDat.Value = DateTime.Now;
            dgvDanhSach.Rows.Clear();
            // Thêm vào auto complete.
            AutoCompleteStringCollection auto = new AutoCompleteStringCollection();

            foreach (DataRow row in SanPhamBUS.DanhSachSPTheoNCC(cboNCC.SelectedValue.ToString()).Rows)
            {
                auto.Add(row["MaSanPham"].ToString());
            }
            txtMaSP.AutoCompleteMode         = AutoCompleteMode.Suggest;
            txtMaSP.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            txtMaSP.AutoCompleteCustomSource = auto;
        }
Esempio n. 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                SanPhamDTO sp = SanPhamBUS.LaySanPhamTheoMaSp(Request.QueryString["qqq"]);
                lblTenSP.Text          = sp.TenSP;
                imgAnhMinhHoa.ImageUrl = "images/" + sp.AnhMinhHoa;
                lblThongTin.Text       = sp.ThongTin;
                lblMaSP.Text           = sp.MaSP;
                lblGia.Text            = sp.GiaTien.ToString();
                lblMaSP.Visible        = false;


                DropDownList_size.DataSource     = SanPhamBUS.LaySanPhamTheoTheoSise(Request.QueryString["qqq"]);
                DropDownList_size.DataTextField  = "sizenumber";
                DropDownList_size.DataValueField = "SoLuongTonKho";
                DropDownList_size.DataBind();

                lblSLTK.Text = DropDownList_size.Items[0].Value.ToString();

                rpt_LoaiGiay.DataSource = LoaiSanPhamBUS.LayDSLoaiSanPham();
                rpt_LoaiGiay.DataBind();

                rpt_SizeGiay.DataSource = SizeGiayBUS.LayDSSize();
                rpt_SizeGiay.DataBind();

                rpt_spcungloai.DataSource = SanPhamBUS.LaySanPhamCungLoaiTrongTrangChiTiet(sp.MaLoaiSP);
                rpt_spcungloai.DataBind();
            }
        }
Esempio n. 28
0
        private void LoadDanhSachSP()
        {
            //KhachHangBUS BUS = new KhachHangBUS();
            //List<KhachHangDTO> lsdtokh = BUS.LAYDSKH();
            //cmbkh.DataSource = lsdtokh;
            //cmbkh.DisplayMember = "MaKH";
            //cmbkh.ValueMember = "MaKH";

            SanPhamBUS bus = new SanPhamBUS();

            lsdto = bus.LayDSSanPham();
            lsdto = new List <SanPhamDTO>();
            lsdto = bus.LayDSSanPham().FindAll(o => o.TinhTrang == 1);

            for (int i = 0; i < lsdto.Count; i++)
            {
                ListViewItem lvi = new ListViewItem(lsdto[i].TenSP);
                lvi.SubItems.Add(lsdto[i].TenSP);
                if (File.Exists(lsdto[i].HinhAnh))
                {
                    byte[]       byteHA = File.ReadAllBytes(lsdto[i].HinhAnh);
                    MemoryStream ms     = new MemoryStream(byteHA);
                    Image        img    = Image.FromStream(ms);
                    imgnho.Images.Add(img);

                    lvi.ImageIndex = imgnho.Images.Count - 1;
                }
                lsvHienThiDSSP.Items.Add(lvi);
            }
        }
Esempio n. 29
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (this.txtMasp.Text == string.Empty || this.txtSoLuong.Text == string.Empty)
            {
                MessageBox.Show("Bạn chưa điền đầy đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtMasp.Focus();
                return;
            }
            if (!SanPhamBUS.KiemTraMaSPTonTai(this.txtMasp.Text))
            {
                MessageBox.Show("Mã sản phẩm không tồn tại !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtMasp.Focus();
                return;
            }

            if (!KiemTraSLMasp(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text)))
            {
                this.txtSoLuong.Focus();
                return;
            }

            if (!KiemTraMaspTonTaiTrongCTHD(this.txtMasp.Text))
            {
                CTHoaDonBanHangBUS.ThemCTHoaDon(new CTHOADONBANHANG
                {
                    MAHD      = hd.MAHD,
                    MASP      = this.txtMasp.Text,
                    SOLUONG   = Convert.ToInt32(this.txtSoLuong.Text.Trim()),
                    DONGIA    = TinhDonGia(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text)),
                    DVT       = sp.Where(p => p.MASP == this.txtMasp.Text).FirstOrDefault().DVT,
                    TRANGTHAI = true
                });
                MessageBox.Show("Thêm sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadDSCTHD(hd.MAHD);
                CapNhatSoLuongSanPham(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text), 0);
                hd.TONGTIEN = lstcthd.Sum(p => p.DONGIA);
                HoaDonBanHangBUS.CapNhatHoaDon(hd);
                if (CongNoBUS.LayDanhSachCongNo().Where(p => p.MAKH == this.lblMaKH.Text && p.MAHD == hd.MAHD && p.TRANGTHAI == true).FirstOrDefault() != null)
                {
                    CapNhatThongTienCongNo();
                }
                this.dangThayDoiCTHD = false;
                loadThongTinHD(hd.MAHD);
                Reset();
                string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã thêm sản phẩm " + this.txtMasp.Text + " vào chi tiết hóa đơn " + hd.MAHD;
                LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
                {
                    NGAYTAO       = DateTime.Now.Date,
                    NV_THAOTAC    = this.manv,
                    VITRI_THAOTAC = this.vitrithaotac,
                    GHICHU        = lsth
                });
            }
            else
            {
                MessageBox.Show("Mã sản phẩm đã tồn tại !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtMasp.Focus();
                return;
            }
        }
Esempio n. 30
0
        public IActionResult Index(string id)
        {
            string idd = id ?? "B77D9CF5-E9A2-4D31-9490-25E4E3971C61";
            //BUS
            SanPhamBUS     sanphambus     = new SanPhamBUS();
            SizeSanPhamBUS sizesanphambus = new SizeSanPhamBUS();
            GioHangBUS     giohangbus     = new GioHangBUS();
            DiaChiBUS      diachibus      = new DiaChiBUS();

            SanPham sanpham = sanphambus.GetSanPham(idd);

            DiaChi diachi = diachibus.GetDiaChiMer(sanpham.IdTaiKhoanNavigation.TenDangNhap);

            ViewBag.DiaChiMerchant = diachi;

            List <SizeSanPham> listsizesanpham = sizesanphambus.GetSize(idd);

            ViewBag.ListSizeSanPham = listsizesanpham;

            List <HangSanPham> hang = ctx.HangSanPham.ToList();

            ViewBag.Hang = hang;

            List <SanPham> spmoi = sanphambus.GetSanPhams("", "", 1, 4);

            ViewBag.SanPhamMoi = spmoi;

            return(View(sanpham));
        }