예제 #1
0
        private void btnIn_Click(object sender, EventArgs e)
        {
            ExcelExport ex = new ExcelExport();

            if (dgvNCC.Rows.Count == 0)
            {
                MessageBox.Show("Khong co du lieu de Xuat");
                return;
            }
            List <INDSNCC> plistdiem = new List <INDSNCC>();
            int            Stt       = 1;
            string         path      = "";

            foreach (DataGridViewRow item in dgvNCC.Rows)
            {
                INDSNCC d = new INDSNCC();
                d.MaNCC     = item.Cells[0].Value.ToString();
                d.TenNCC    = item.Cells[1].Value.ToString();
                d.DiaChi    = item.Cells[2].Value.ToString();
                d.DienThoai = item.Cells[3].Value.ToString();
                d.STT       = Stt.ToString();
                Stt++;
                plistdiem.Add(d);

                path = string.Empty;
                ex.ExportDSNCC(plistdiem, ref path, false);
            }
            ex.OpenFile(path);
        }
예제 #2
0
        private void btnIN_Click(object sender, EventArgs e)
        {
            ExcelExport ex = new ExcelExport();

            if (dgvCTPN.Rows.Count == 0)
            {
                MessageBox.Show("Khong co du lieu de Xuat");
                return;
            }
            List <INPHIEUNHAP> plistdiem = new List <INPHIEUNHAP>();
            int    Stt  = 1;
            string path = "";

            for (int i = 0; i < dgvCTPN.Rows.Count - 1; i++)
            {
                INPHIEUNHAP d = new INPHIEUNHAP();
                d.TENHANG   = dgvCTPN.Rows[i].Cells[1].Value.ToString();
                d.SOLUONG   = int.Parse(dgvCTPN.Rows[i].Cells[2].Value.ToString());
                d.DONGIA    = float.Parse(dgvCTPN.Rows[i].Cells[3].Value.ToString());
                d.THANHTIEN = int.Parse(dgvCTPN.Rows[i].Cells[2].Value.ToString()) * float.Parse(dgvCTPN.Rows[i].Cells[3].Value.ToString());
                d.STT       = Stt.ToString();
                Stt++;
                plistdiem.Add(d);

                path = string.Empty;
                ex.ExportPhieuNhap(plistdiem, ref path, false, txtMaPN.Text, txtNgayHD.Text, cboNV.Text);
            }
            ex.OpenFile(path);
        }
예제 #3
0
        public void InHD()
        {
            ExcelExport ex = new ExcelExport();

            if (dgvCTHD.Rows.Count == 0)
            {
                MessageBox.Show("Khong co du lieu de Xuat");
                return;
            }
            List <INHOADON> plistdiem = new List <INHOADON>();
            int             Stt       = 1;
            string          path      = "";

            for (int i = 0; i < dgvCTHD.Rows.Count - 1; i++)
            {
                INHOADON d = new INHOADON();
                d.TENHANG   = dgvCTHD.Rows[i].Cells[1].Value.ToString();
                d.SOLUONG   = int.Parse(dgvCTHD.Rows[i].Cells[2].Value.ToString());
                d.DONGIA    = float.Parse(dgvCTHD.Rows[i].Cells[3].Value.ToString());
                d.THANHTIEN = float.Parse(dgvCTHD.Rows[i].Cells[4].Value.ToString());
                d.STT       = Stt.ToString();
                Stt++;
                plistdiem.Add(d);

                path = string.Empty;
                ex.ExportHOADON(plistdiem, ref path, false, txtMaHD.Text, txtNgayHD.Text, cboNV.Text, cboKH.Text);
            }
            ex.OpenFile(path);
        }
        public void InDS()
        {
            ExcelExport ex = new ExcelExport();

            if (dgvHangHoa.Rows.Count == 0)
            {
                MessageBox.Show("Khong co du lieu de Xuat");
                return;
            }
            List <INDSHANG> plistdiem = new List <INDSHANG>();
            int             Stt       = 1;
            string          path      = "";

            foreach (DataGridViewRow item in dgvHangHoa.Rows)
            {
                INDSHANG d = new INDSHANG();
                d.MaHH       = item.Cells[0].Value.ToString();
                d.TenHH      = item.Cells[1].Value.ToString();
                d.DonGia     = float.Parse(item.Cells[2].Value.ToString());
                d.SoLuongTon = int.Parse(item.Cells[3].Value.ToString());
                d.Loai       = item.Cells[5].Value.ToString();
                d.NCC        = item.Cells[7].Value.ToString();
                d.STT        = Stt.ToString();
                Stt++;
                plistdiem.Add(d);

                path = string.Empty;
                ex.ExportDSHang(plistdiem, ref path, false);
            }
            ex.OpenFile(path);
        }
        private void xuatFileExcel()
        {
            ExcelExport             ex     = new ExcelExport();
            List <QL_ChiTietHoaDon> dsKhoa = lstChiTiet;

            if (dsKhoa.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu");
            }
            QL_HoaDon_BanHang       hdbh    = hd_bll.layHD(maHD);
            List <QL_ChiTietHoaDon> pListSP = new List <QL_ChiTietHoaDon>();

            if (checkDungDiem.Checked)
            {
                hdbh.DiemDung = diemDung;
            }

            hdbh.TongTienThat = Convert.ToInt32(lbTongTien.Text);

            // Đỗ dữ liệu vào danh sách
            int Stt = 1;

            foreach (QL_ChiTietHoaDon item in dsKhoa)
            {
                QL_ChiTietHoaDon chitiet   = new QL_ChiTietHoaDon();
                QL_SanPham       sphientai = sp_bll.laySP(item.MaSP);

                chitiet.TenSanPham = sphientai.TenSanPham;
                chitiet.DonGia     = item.DonGia;
                chitiet.Soluong    = item.Soluong;
                chitiet.STT        = Stt.ToString();
                Stt++;
                pListSP.Add(chitiet);
            }

            string path = string.Empty;

            ex.ExportKhoa(hdbh, pListSP, ref path, false);

            if (!string.IsNullOrEmpty(path) && MessageBox.Show("Bạn có muốn mở file", "Xác Nhận", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                System.Diagnostics.Process.Start(path);
            }
        }
예제 #6
0
        private void btn_bc_Click(object sender, EventArgs e)
        {
            ExcelExport excel  = new ExcelExport();
            List <Ve>   listVe = new List <Ve>();

            for (int i = 0; i < gridView1.DataRowCount; i++)
            {
                Ve v = new Ve();
                v.STT        = i;
                v.KHACH_HANG = gridView1.GetRowCellValue(i, "KHACH_HANG.TEN").ToString();
                v.LICH       = gridView1.GetRowCellValue(i, "LICH_KHOI_HANH.TEN_LICH").ToString();
                if (gridView1.GetRowCellValue(i, "LOAI_THANH_TOAN.TEN_LOAI_TT") != null)
                {
                    v.LOAI_TT = gridView1.GetRowCellValue(i, "LOAI_THANH_TOAN.TEN_LOAI_TT").ToString();
                }
                v.NGAY_DAT  = gridView1.GetRowCellValue(i, "NGAY_DAT").ToString();
                v.TONG_TIEN = double.Parse(gridView1.GetRowCellValue(i, "TONG_TIEN").ToString());
                v.DIEM_DON  = gridView1.GetRowCellValue(i, "DIEM_DON").ToString();
                listVe.Add(v);
            }
            if (listVe.Count <= 0)
            {
                MessageBox.Show("Không có dữ liệu để xuất");
                return;
            }
            string path = string.Empty;

            excel.ExportExcelVe(listVe, ref path, false);
            // Confirm for open file was exported
            if (!string.IsNullOrEmpty(path) && MessageBox.Show("Bạn có muốn mở file không?", "Thông tin", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
            {
                System.Diagnostics.Process.Start(path);
            }
            else
            {
                MessageBox.Show("Khổng thể xuất file!", "Thông báo");
            }
        }
예제 #7
0
        private void btn_In_Dong_Click(object sender, EventArgs e)
        {
            try
            {
                double d = double.Parse(txt_TienTraLai.Text);
                if (d < 0)
                {
                    MessageBox.Show("Mời nhập tiền");
                    return;
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("Mời nhập tiền");
                return;
            }
            try
            {
                //th1: khach mua mang di
                if (ca.getFlag() == 0)
                {
                    DateTime    dt      = DateTime.Now;
                    int         maB     = ca.getMaBan();
                    int         maNV    = ca.getMaNV();
                    String      PT      = "Cash";
                    double      tong    = ca.tinhTong();
                    String      TT      = "Roi";
                    int         x       = hd.LuuHoaDon2(dt, maB, maNV, PT, tong, TT);
                    List <Item> lstCart = ca.getCart();

                    foreach (Item i in lstCart)
                    {
                        int    maHD  = x;
                        int    maMon = i.maMon;
                        int    sl    = i.sl;
                        double tong2 = i.tongTien;
                        ct.LuuChiTietHD(maHD, maMon, sl, tong2);
                    }
                    //thong bao xong
                    ca.clearCard2();
                    ca.clearCard();
                    this.Dispose();
                    if (Program.frmCNC.Visible == false)
                    {
                        Program.frmCNC = new Form_ChucNangChinh();
                    }
                    Program.frmCNC.Show();
                    MessageBox.Show("Thanh Toán Thành Công");
                    //goi hd ra
                    tblHoaDon hoaDon = hd.getMaHDTheoMaHD(x);
                    //xuat file excel
                    ExcelExport         ex         = new ExcelExport();
                    List <tblChiTietHD> lstCTExcel = ct.getCTByMaHD(x).ToList();
                    string   path  = string.Empty;
                    DateTime?dtVao = hoaDon.TGVao;
                    DateTime?dtRa  = hoaDon.TGRa;
                    double   tien1 = 0;
                    double   tien2 = 0;
                    try
                    {
                        tien1 = double.Parse(txt_TienKhachDua.Text);
                        tien2 = double.Parse(txt_TienTraLai.Text);
                    }
                    catch (Exception ee)
                    {
                        tien1 = 0;
                        tien2 = 0;
                    }
                    ex.ExportKhoa(lstCTExcel, ref path, false, dtVao.Value, dtRa.Value, (double)hoaDon.TongTienTT, lstCTExcel.Count, tien1, tien2, x, hoaDon.MaBan, hoaDon.MaNV);
                    if (!string.IsNullOrEmpty(path) && MessageBox.Show("Bạn muốn mở file", "Thông tin", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(path);
                    }
                }
                if (ca.getFlag() == 1)
                {
                    //khach tinh tien sau khi ngoi tai quan
                    int maHDExcel = 0;
                    if (ca.getCart2().Count == 0)
                    {
                        tblHoaDon h = hd.getMaHDTheoBan(ca.getMaBan());
                        maHDExcel = h.MaHD;
                        //DateTime dt = DateTime.Today;
                        DateTime dt = DateTime.Now;
                        hd.suaHoaDon(h.MaHD, dt, "Roi");

                        ca.clearCard2();
                        ca.clearCard();
                        this.Dispose();
                        if (Program.frmCNC.Visible == false)
                        {
                            Program.frmCNC = new Form_ChucNangChinh();
                        }
                        Program.frmCNC.Show();
                    }
                    //khach ngoi tai quan nhung order them roi tinh tien luon
                    else if (ca.getCart2().Count > 0)
                    {
                        tblHoaDon h = hd.getMaHDTheoBan(ca.getMaBan());
                        maHDExcel = h.MaHD;
                        List <tblChiTietHD> lstCT   = ct.getCTByMaHD(h.MaHD).ToList <tblChiTietHD>();
                        List <Item>         lstCart = ca.getCart2();
                        double tong1 = ca.tinhTong2();
                        //update lai chi tiet
                        for (int i = 0; i < lstCT.Count; i++)
                        {
                            for (int j = 0; j < lstCart.Count; j++)
                            {
                                if (lstCT[i].MaMon == lstCart[j].maMon)
                                {
                                    ct.suaChiTietHD(lstCT[i].MaHD, lstCT[i].MaMon, (lstCart[j].sl + lstCT[i].SoLuong), (lstCart[j].tongTien + (double)lstCT[i].TongTien));
                                    lstCart.Remove(lstCart[j]);
                                    j--;
                                }
                            }
                        }
                        //them cac chi tiet moi
                        foreach (Item i in lstCart)
                        {
                            int    maHD  = h.MaHD;
                            int    maMon = i.maMon;
                            int    sl    = i.sl;
                            double tong  = i.tongTien;
                            ct.LuuChiTietHD(maHD, maMon, sl, tong);
                        }
                        //update lai tong tien cho hoa don
                        hd.suaHoaDon(h.MaHD, (tong1 + (double)h.TongTienTT));
                        //update lai trang thai
                        DateTime dt = DateTime.Now;
                        hd.suaHoaDon(h.MaHD, dt, "Roi");
                        //thong bao xong
                        ca.clearCard2();
                        ca.clearCard();
                        this.Dispose();
                        if (Program.frmCNC.Visible == false)
                        {
                            Program.frmCNC = new Form_ChucNangChinh();
                        }
                        Program.frmCNC.Show();
                    }
                    MessageBox.Show("Thanh Toán Thành Công");
                    //goi hoa don ra
                    tblHoaDon hoaDon = hd.getMaHDTheoMaHD(maHDExcel);
                    //xuat file excel
                    ExcelExport         ex         = new ExcelExport();
                    List <tblChiTietHD> lstCTExcel = ct.getCTByMaHD(maHDExcel).ToList();
                    string   path  = string.Empty;
                    DateTime?dtVao = hoaDon.TGVao;
                    DateTime?dtRa  = hoaDon.TGRa;
                    double   tien1 = 0;
                    double   tien2 = 0;
                    try
                    {
                        tien1 = double.Parse(txt_TienKhachDua.Text);
                        tien2 = double.Parse(txt_TienTraLai.Text);
                    }
                    catch (Exception ee)
                    {
                        tien1 = 0;
                        tien2 = 0;
                    }
                    ex.ExportKhoa(lstCTExcel, ref path, false, dtVao.Value, dtRa.Value, (double)hoaDon.TongTienTT, lstCTExcel.Count, tien1, tien2, maHDExcel, hoaDon.MaBan, hoaDon.MaNV);
                    if (!string.IsNullOrEmpty(path) && MessageBox.Show("Bạn muốn mở file", "Thông tin", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(path);
                    }
                }
            }
            catch (Exception ee)
            { }
        }