Пример #1
0
        private void frmHangHoaSearch_Load(object sender, EventArgs e)
        {
            grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();
            lbcLoaiHang.ValueMember     = "MaLoaiHang";
            lbcLoaiHang.DisplayMember   = "TenLoaiHang";

            lueChungLoai.Properties.ValueMember   = "MaChungLoai";
            lueChungLoai.Properties.DisplayMember = "TenChungLoai";
            lueChungLoai.Properties.Columns.Add(new LookUpColumnInfo("TenChungLoai", "Chủng Loại"));
            lueChungLoai.Properties.DataSource = ChungLoaiService.LoadDataTable();

            DataTable temp = LoaiHangService.LoadDataTable();
            DataRow   dr   = dtLoaiHang.NewRow();

            dr[0] = 0;
            dr[1] = "Tất cả";
            dtLoaiHang.Rows.Add(dr);
            for (int i = 0; i < temp.Rows.Count; i++)
            {
                DataRow dr1 = dtLoaiHang.NewRow();
                dr1[0] = temp.Rows[i].Field <int>("MaLoaiHang");
                dr1[1] = temp.Rows[i].Field <string>("TenLoaiHang");
                dtLoaiHang.Rows.Add(dr1);
            }
            lbcLoaiHang.DataSource = dtLoaiHang;
        }
Пример #2
0
        private void reload(object sender, FormClosingEventArgs e)
        {
            frmHangHoa f = (frmHangHoa)sender;

            if (f.isDataChanged == true)
            {
                grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();
            }
        }
Пример #3
0
 public frmChiTietKiemKe_Them()
 {
     InitializeComponent();
     isDataChanged = false;
     lueHangHoa.Properties.ValueMember   = "MaHangHoa";
     lueHangHoa.Properties.DisplayMember = "TenHangHoa";
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("MaHangHoa", 50, "Mã Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenHangHoa", 100, "Tên Hàng Hóa"));
     lueHangHoa.Properties.DataSource = HangHoaService.LoadDataTable();
 }
Пример #4
0
 private void frmPhieuXuatThemSua_Load(object sender, EventArgs e)
 {
     tedSoPhieu.Text = PhieuXuatService.AutoGenerateId();
     tedNgayLap.Text = DateTime.Now.ToString("dd/MM/yyyy");
     lueHangHoa.Properties.ValueMember   = "MaHangHoa";
     lueHangHoa.Properties.DisplayMember = "TenHangHoa";
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("MaHangHoa", 50, "Mã Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenHangHoa", 100, "Tên Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SoLuongNhap", 50, "Số Lượng Tồn"));
     lueHangHoa.Properties.DataSource = HangHoaService.LoadDataTable();
 }
Пример #5
0
        private void buttonTimKiem_Click(object sender, EventArgs e)
        {
            string key = txtTimKiem.Text;

            if (key.Trim() != "")
            {
                grcHanghoaSearch.DataSource = HangHoaService.Search(key);
            }
            else
            {
                grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();
            }
        }
Пример #6
0
 private void txtTimKiem_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         string key = txtTimKiem.Text;
         if (key.Trim() != "")
         {
             grcHanghoaSearch.DataSource = HangHoaService.Search(key);
         }
         else
         {
             grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();
         }
     }
 }
Пример #7
0
 private void frmPhieuKiemKe_Load(object sender, EventArgs e)
 {
     isSaved = false;
     txtNhanVien.ReadOnly = true;
     txtMaPhieu.ReadOnly  = true;
     btnXoa.Enabled       = false;
     btnLuu.Enabled       = false;
     txtMaPhieu.Text      = PhieuKiemKeService.AutoGenerateId();
     deNgayLap.DateTime   = DateTime.Now;
     lueHangHoa.Properties.ValueMember   = "MaHangHoa";
     lueHangHoa.Properties.DisplayMember = "TenHangHoa";
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("MaHangHoa", 50, "Mã Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenHangHoa", 100, "Tên Hàng Hóa"));
     lueHangHoa.Properties.DataSource = HangHoaService.LoadDataTable();
 }
Пример #8
0
 private void frmHoaDon_Load(object sender, EventArgs e)
 {
     Init();
     txtDiemTichLuy.ReadOnly             = true;
     txtTienGiam.ReadOnly                = true;
     txtThanhTien.ReadOnly               = true;
     txtThanhTien.Text                   = "0";
     txtDiemTichLuy.Text                 = DiemTichLuy.ToString();
     lueHangHoa.Properties.ValueMember   = "MaHangHoa";
     lueHangHoa.Properties.DisplayMember = "TenHangHoa";
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("MaHangHoa", 50, "Mã Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenHangHoa", 100, "Tên Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("GiaBan", 100, "Giá"));
     lueHangHoa.Properties.DataSource = HangHoaService.LoadDataTable();
 }
Пример #9
0
 private void HangHoaSearch_Load(object sender, EventArgs e)
 {
     lueChungLoai.Properties.ValueMember   = "MaChungLoai";
     lueChungLoai.Properties.DisplayMember = "TenChungLoai";
     lueChungLoai.Properties.Columns.Add(new LookUpColumnInfo("TenChungLoai", "Tên chủng loại hàng"));
     lueChungLoai.Properties.DataSource   = ChungLoaiService.LoadDataTable();
     lueLoaiHang.Properties.ValueMember   = "MaLoaiHang";
     lueLoaiHang.Properties.DisplayMember = "TenLoaiHang";
     lueLoaiHang.Properties.Columns.Add(new LookUpColumnInfo("TenLoaiHang", "Tên Loại Hàng"));
     lueLoaiHang.Properties.DataSource = LoaiHangService.LoadDataTable();
     grcHangHoa.DataSource             = HangHoaService.LoadDataTable();
     if (Mode == MODE_NORMAL)
     {
         btnChon.Visible = false;
     }
 }
Пример #10
0
 private void lbcLoaiHang_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lbcLoaiHang.SelectedValue != null)
     {
         if (lbcLoaiHang.SelectedValue.ToString() == "0")
         {
             grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();
         }
         else
         {
             int maLoaiHang = int.Parse(lbcLoaiHang.SelectedValue.ToString());
             grcHanghoaSearch.DataSource = HangHoaService.GetByLoaiHang(maLoaiHang);
         }
     }
     else
     {
     }
 }
Пример #11
0
        private void frmHangHoaSearch_Load(object sender, EventArgs e)
        {
            grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();

            _dtLoaiHang  = LoaiHangService.LoadDataTable();
            _dtDonViTinh = DonViTinhService.LoadDataTable();

            LookUpEditLoaiHang.DataSource    = _dtLoaiHang;
            LookUpEditLoaiHang.ValueMember   = "MaLoaiHang";
            LookUpEditLoaiHang.DisplayMember = "TenLoaiHang";
            LookUpEditLoaiHang.Columns.Add(new LookUpColumnInfo("MaLoaiHang", "Mã Loại Hàng"));
            LookUpEditLoaiHang.Columns.Add(new LookUpColumnInfo("TenLoaiHang", "Tên Loại Hàng"));

            LookUpEditDonViTinh.DataSource    = _dtDonViTinh;
            LookUpEditDonViTinh.ValueMember   = "MaDVT";
            LookUpEditDonViTinh.DisplayMember = "TenDVT";
            LookUpEditDonViTinh.Columns.Add(new LookUpColumnInfo("MaDVT", "Mã Đơn Vị Tính"));
            LookUpEditDonViTinh.Columns.Add(new LookUpColumnInfo("TenDVT", "Tên Đơn Vị Tính"));
        }
Пример #12
0
 private void frmPhieuNhapThemSua_Load(object sender, EventArgs e)
 {
     tedSoPhieuNhap.Text                 = PhieuNhapService.AutoGenerateId();
     tedNgayLap.Text                     = DateTime.Now.ToString("dd/MM/yyyy");
     tedNhanVienLap.Text                 = (ProjectUltil.HoTenNhanVien != "") ? ProjectUltil.HoTenNhanVien : "";
     tedNgayLap.ReadOnly                 = true;
     tedSoPhieuNhap.ReadOnly             = true;
     tedNhanVienLap.ReadOnly             = true;
     tedTongTien.ReadOnly                = true;
     lueHangHoa.Properties.ValueMember   = "MaHangHoa";
     lueHangHoa.Properties.DisplayMember = "TenHangHoa";
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("MaHangHoa", 50, "Mã Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenHangHoa", 100, "Tên Hàng Hóa"));
     lueHangHoa.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SoLuongTon", 50, "Số Lượng Tồn"));
     lueHangHoa.Properties.DataSource       = HangHoaService.LoadDataTable();
     lueNhaCungCap.Properties.ValueMember   = "MaNhaCungCap";
     lueNhaCungCap.Properties.DisplayMember = "TenNhaCungCap";
     lueNhaCungCap.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenNhaCungCap", 100, "Tên NCC"));
     lueNhaCungCap.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("DiaChi", 100, "Địa Chỉ"));
     lueNhaCungCap.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("DienThoai", 100, "Điện Thoại"));
     lueNhaCungCap.Properties.DataSource = NhaCungCapService.LoadDataTable();
 }
Пример #13
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     rowSelected = gridView.GetSelectedRows()[0];
     if (rowSelected >= 0)
     {
         if (MessageBox.Show("Xác nhận xóa nhân viên đã chọn?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             if (HangHoaService.Delete(gridView.GetRowCellValue(rowSelected, "MaHangHoa").ToString()))
             {
                 grcHanghoaSearch.DataSource = HangHoaService.LoadDataTable();
                 MessageBox.Show("Xóa thành công!");
             }
             else
             {
                 MessageBox.Show("Không thể xóa vì nhân viên này còn thông tin liên quan!");
             }
         }
     }
     else
     {
         MessageBox.Show("Vui lòng chọn 1 dòng để xóa!");
     }
 }
Пример #14
0
        private void grcHangHoa_Load(object sender, EventArgs e)
        {
            var dt = HangHoaService.LoadDataTable();

            grcHangHoa.DataSource = dt;
        }
Пример #15
0
        private void btnLapBaoCao_Click(object sender, EventArgs e)
        {
            if (cbbThang.Text == "")
            {
                MessageBox.Show("Vui lòng chọn tháng!");
                return;
            }
            thang = int.Parse(cbbThang.Text);
            if (cbbNam.Text == "")
            {
                MessageBox.Show("Vui lòng chọn năm!");
                return;
            }
            nam = int.Parse(cbbNam.Text);
            DateTime dateStart = new DateTime(nam, thang, 1);
            DateTime dateEnd   = new DateTime(nam, thang, ProjectUltil.soNgay(nam, thang));

            if (dateStart > DateTime.Now.Date)
            {
                MessageBox.Show("Thời gian phải trước ngày hiện tại!");
                return;
            }
            //if(dateEnd > DateTime.Now.Date)
            //{
            //    dateEnd = DateTime.Now.Date;
            //}
            dsPhieuNhap    = PhieuNhapService.Search(null, dateStart, dateEnd);
            dsPhieuXuat    = PhieuXuatService.Search(null, dateStart, dateEnd);
            dsBaoCaoTonKho = BaoCaoTonKhoService.GetByMonthYear(thang, nam);
            dsHangHoa      = HangHoaService.LoadDataTable();
            if (dsBaoCaoTonKho.Rows.Count > 0)
            {
                grcBaoCaoTonKho.DataSource = ChiTietBaoCaoTonKhoService.GetById(dsBaoCaoTonKho.Rows[0].Field <int>("MaBaoCaoTonKho"));
                btnIn.Enabled = true;
            }
            else
            {
                bctk            = new BaoCaoTonKho();
                bctk.MaNhanVien = (ProjectUltil.MaNhanVien != "") ? ProjectUltil.MaNhanVien : "NV0001";
                bctk.Nam        = nam;
                bctk.Thang      = thang;
                bctk.NgayLap    = DateTime.Now.Date;
                if ((bctk.MaBaoCaoTonKho = BaoCaoTonKhoService.Insert(bctk)) != -1)
                {
                    for (int i = 0; i < dsHangHoa.Rows.Count; i++)
                    {
                        ctbctk = new ChiTietBaoCaoTonKho();
                        ctbctk.MaBaoCaoTonKho = bctk.MaBaoCaoTonKho;
                        ctbctk.MaHangHoa      = dsHangHoa.Rows[i].Field <string>("MaHangHoa");
                        ctbctk.SoLuongDauKy   = 0;
                        for (int j = 0; j < dsPhieuNhap.Rows.Count; j++)
                        {
                            dsCTPhieuNhap = ChiTietPhieuNhapService.GetById(dsPhieuNhap.Rows[j].Field <string>("SoPhieuNhap"));
                            for (int k = 0; k < dsCTPhieuNhap.Rows.Count; k++)
                            {
                                if (dsCTPhieuNhap.Rows[k].Field <string>("MaHangHoa") == ctbctk.MaHangHoa)
                                {
                                    int soluong = dsCTPhieuNhap.Rows[k].Field <int>("SoLuong");
                                    ctbctk.SoLuongNhap += soluong;
                                }
                            }
                        }

                        for (int j = 0; j < dsPhieuXuat.Rows.Count; j++)
                        {
                            dsCTPhieuXuat = ChiTietPhieuXuatService.GetById(dsPhieuXuat.Rows[j].Field <string>("SoPhieuXuat"));
                            for (int k = 0; k < dsCTPhieuXuat.Rows.Count; k++)
                            {
                                if (dsCTPhieuXuat.Rows[k].Field <string>("MaHangHoa") == ctbctk.MaHangHoa)
                                {
                                    int soluong = dsCTPhieuXuat.Rows[k].Field <int>("SoLuong");
                                    ctbctk.SoLuongXuat += soluong;
                                }
                            }
                        }

                        ctbctk.SoLuongCuoiKy = ctbctk.SoLuongDauKy + ctbctk.SoLuongNhap - ctbctk.SoLuongXuat;
                        if (!ChiTietBaoCaoTonKhoService.Insert(ctbctk))
                        {
                            ChiTietBaoCaoTonKhoService.Delete(ctbctk.MaBaoCaoTonKho.ToString());
                            BaoCaoTonKhoService.Delete(ctbctk.MaBaoCaoTonKho.ToString());
                            MessageBox.Show("Không thể thêm chi tiết báo cáo!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Không thể lập báo cáo!");
                }
                grcBaoCaoTonKho.DataSource = ChiTietBaoCaoTonKhoService.GetById(bctk.MaBaoCaoTonKho);
                btnIn.Enabled = true;
            }
        }
Пример #16
0
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            string         key = null;
            Nullable <int> loaiHang = null, slTonTu = null, slTonDen = null, slQuayTu = null, slQuayDen = null;

            if (cheKey.Checked == true)
            {
                if (sctKey.Text != "")
                {
                    key = sctKey.Text;
                }
            }
            if (cheLoai.Checked == true)
            {
                if (lueLoaiHang.Text.Trim() != "")
                {
                    DataRowView row = lueLoaiHang.Properties.GetDataSourceRowByKeyValue(lueLoaiHang.EditValue) as DataRowView;
                    try
                    {
                        loaiHang = int.Parse(row.Row["MaLoaiHang"].ToString());
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Không thể lấy mã loại!");
                        return;
                    }
                }
            }
            if (cheSLTon.Checked == true)
            {
                if (cbbSLTonTu.Text != "")
                {
                    try
                    {
                        slTonTu = int.Parse(cbbSLTonTu.Text);
                    }
                    catch (Exception)
                    {
                    }
                }
                if (cbbSLTonDen.Text != "")
                {
                    try
                    {
                        slTonDen = int.Parse(cbbSLTonDen.Text);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (cheSLQuay.Checked == true)
            {
                if (cbbSLQuayTu.Text != "")
                {
                    try
                    {
                        slQuayTu = int.Parse(cbbSLQuayTu.Text);
                    }
                    catch (Exception)
                    {
                    }
                }
                if (cbbSLQuayDen.Text != "")
                {
                    try
                    {
                        slQuayDen = int.Parse(cbbSLQuayDen.Text);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (key == null && loaiHang == null && slTonTu == null && slTonDen == null && slQuayTu == null && slQuayDen == null)
            {
                grcHangHoa.DataSource = HangHoaService.LoadDataTable();
            }
            else
            {
                grcHangHoa.DataSource = HangHoaService.Search1(key, loaiHang, slTonTu, slTonDen, slQuayTu, slQuayDen);
            }
        }
Пример #17
0
 private void reloadHangHoa(object sender, FormClosingEventArgs e)
 {
     lueHangHoa.Properties.DataSource = HangHoaService.LoadDataTable();
 }