Beispiel #1
0
        private void btn_Click(object sender, EventArgs e)
        {
            string btnName = ((MaterialFlatButton)sender).Name;

            if (btnName == "LichSuHoaDon")
            {
                FrmLichSuHoaDon frmLichSuHoaDon = FrmLichSuHoaDon.Instance;
                frmLichSuHoaDon.MinimizeBox = false;

                FrmMain.Instance.TopMost = false;
                frmLichSuHoaDon.ShowDialog();
                return;
            }

            FrmHienThiBaoCao frm = new FrmHienThiBaoCao();

            if (btnName == "TatCaMon")
            {
                frm.HienTatCaMon();
            }
            else if (btnName == "MonGomNhom")
            {
                frm.HienThiMonTheoNhom();
            }
            else if (btnName == "TatCaHoaDon")
            {
                frm.HienThiTatCacHoaDon();
            }
            else if (btnName == "TatCaPhieuNhap")
            {
                frm.HienTatCaPhieuNhap();
            }
            else if (btnName == "TatCaNguyenLieu")
            {
                frm.HienTatCaNguyenLieu();
            }
            else if (btnName == "HoaDonMoiNhat")
            {
                frm.HienThiHoaDonMoiNhat();
            }
            else if (btnName == "HoaDonTrongNgay")
            {
                frm.HienThiTatHoaDonLapTrongNgay();
            }
            else if (btnName == "PhieuNhapMoiNhat")
            {
                frm.HienThiPhieuNhapMoiNhat();
            }
            else if (btnName == "PhieuNhapTrongNgay")
            {
                frm.TatCaPhieuNhapLapTrongNgay();
            }
            this.TopMost = false;
            frm.Show();
        }
        private void btnNhapHang_Click(object sender, EventArgs e)
        {
            PhieuNhapDTO phieuNhap = new PhieuNhapDTO();

            phieuNhap.NhaCungCap = (int)cmbNhaCungCap.SelectedValue;
            phieuNhap.NgayLap    = DateTime.Now;
            phieuNhap.TongTien   = Convert.ToDouble(lblTongTien.Text.Remove(lblTongTien.Text.Length - 1));
            phieuNhap.TrangThai  = true;

            List <CTPhieuNhapDTO> lsCTPhieuNhap = new List <CTPhieuNhapDTO>();

            foreach (DataGridViewRow row in dgvCTPhieuNhap.Rows)
            {
                string donGia = row.Cells["colDonGia"].Value.ToString();

                CTPhieuNhapDTO ctPhieuNhap = new CTPhieuNhapDTO();
                ctPhieuNhap.MaPhieuNhap  = Convert.ToInt32(lblMaPhieu.Text);
                ctPhieuNhap.MaNguyenLieu = Convert.ToInt32(row.Cells["colMaNguyenLieu"].Value);
                ctPhieuNhap.SoLuong      = Convert.ToDouble(row.Cells["colSoLuong"].Value);
                ctPhieuNhap.DonViTinh    = row.Cells["colDonViTinh"].Value.ToString();
                ctPhieuNhap.DonGia       = Convert.ToDouble(donGia.Remove(donGia.Length - 1));
                if (row.Cells["colGhiChu"].Value != null)
                {
                    ctPhieuNhap.GhiChu = row.Cells["colGhiChu"].Value.ToString();
                }
                else
                {
                    ctPhieuNhap.GhiChu = string.Empty;
                }

                lsCTPhieuNhap.Add(ctPhieuNhap);
            }

            if (PhieuNhapBUS.LuuPhieuNhap(phieuNhap, lsCTPhieuNhap))
            {
                if (DialogResult.Yes == MessageBox.Show("Bạn có muốn in phiếu nhập?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    FrmHienThiBaoCao frm = new FrmHienThiBaoCao();
                    frm.HienThiPhieuNhapMoiNhat();
                    FrmMain.Instance.TopMost = false;
                    frm.Show();
                }
                LamMoi();
                dgvCTPhieuNhap.Rows.Clear();
            }
            else
            {
                MessageBox.Show("Lưu phiếu nhập thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnBaoCao_Click(object sender, EventArgs e)
        {
            FrmMain.Instance.TopMost = false;
            FrmHienThiBaoCao frm = new FrmHienThiBaoCao();

            if (radTatCaMon.Checked)
            {
                frm.HienTatCaMon();
            }
            else if (radTheoLoaiMon.Checked)
            {
                frm.HienMonTheoLoai((int)cmbLoaiMon.SelectedValue);
            }
            else if (radGomNhomMon.Checked)
            {
                frm.HienThiMonTheoNhom();
            }
            else if (radTatCaHoaDon.Checked)
            {
                frm.HienThiTatCacHoaDon();
            }
            else if (radHoaDonLapTrongNgay.Checked)
            {
                frm.HienThiTatHoaDonLapTrongNgay();
            }
            else if (radHoaDonChonNgay.Checked)
            {
                frm.HienThiHoaDonTheoNgay((DateTime)dtpHoaDonChonNgay.Value);
            }
            else if (radHoaDonTheoThang.Checked)
            {
                frm.HienThiTatCacHoaDonTheoThang((DateTime)dtpTimeStart.Value, (DateTime)dtpTimeEnd.Value);
            }
            else if (radTatCaNguyenLieu.Checked)
            {
                frm.HienTatCaNguyenLieu();
            }
            else if (radTatCaPhieuNhap.Checked)
            {
                frm.HienTatCaPhieuNhap();
            }
            else if (radPhieuNhapTrongNgay.Checked)
            {
                frm.TatCaPhieuNhapLapTrongNgay();
            }
            else if (radPhieuNhapTheoThang.Checked)
            {
                frm.HienThiTatCacPhieuNhapTheoMoc((DateTime)dtpPhieuNhapStart.Value, (DateTime)dtpPhieuNhapEnd.Value);
            }
            else if (radPhieuNhapChonNgay.Checked)
            {
                frm.HienThiPhieuNhapTheoNgay((DateTime)dtpPhieuNhapChonNgay.Value);
            }
            else if (radHoaDonMoiNhat.Checked)
            {
                frm.HienThiHoaDonMoiNhat();
            }
            else if (radPhieuNhapNew.Checked)
            {
                frm.HienThiPhieuNhapMoiNhat();
            }
            else if (radDoanhThuTheoNgay.Checked)
            {
                frm.DoanhThuTheoNgay((DateTime)dtpDoanhThuTheoNgay.Value);
            }
            else if (radDoanhThuTheoMoc.Checked)
            {
                frm.DoanhThuTheoMoc((DateTime)dtpDoanhThuStart.Value, (DateTime)dtpDoanhThuEnd.Value);
            }
            frm.Show();
        }