Example #1
0
        private void BtnTheoNgay_Click(object sender, EventArgs e)
        {
            myDataBases db       = new myDataBases();
            DateTime    dateTime = dateNgay.DateTime;

            dgvHoaDon.DataSource = db.getData("select * from tblHoaDon where CONVERT(nvarchar(10), ThoiGianLap, 121)='" + dateTime.Year.ToString() + "-" + dateTime.Month.ToString() + "-" + dateTime.Day.ToString() + "'");
            DataTable dt = db.getData("select TenThucDon, SUM(SoLuong) from tblThucDon join tblCTHD on tblThucDon.MaThucDon = tblCTHD.MaThucDon join tblHoaDon on tblHoaDon.SoHD = tblCTHD.SoHD where CONVERT(nvarchar(10), ThoiGianLap, 121)='" + dateTime.Year.ToString() + "-" + dateTime.Month.ToString() + "-" + dateTime.Day.ToString() + "' group by tblCTHD.MaThucDon, TenThucDon having SUM(SoLuong) >=all (select SUM(SoLuong) from tblCTHD join tblHoaDon on tblHoaDon.SoHD = tblCTHD.SoHD where CONVERT(nvarchar(10), ThoiGianLap, 121)='" + dateTime.Year.ToString() + "-" + dateTime.Month.ToString() + "-" + dateTime.Day.ToString() + "' group by MaThucDon)");

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    lbMaxTD.Text = dr["TenThucDon"].ToString();
                }
            }
            DataTable dt1 = db.getData("select SUM(TongTien) as TongTien, SUM(SoKhach) as TongKhach from tblHoaDon where CONVERT(nvarchar(10), ThoiGianLap, 121)='" + dateTime.Year.ToString() + "-" + dateTime.Month.ToString() + "-" + dateTime.Day.ToString() + "'");

            if (dt1 != null)
            {
                foreach (DataRow dr in dt1.Rows)
                {
                    lbTongKhach.Text = dr["TongKhach"].ToString() + "khách";
                    lbTongTien.Text  = dr["TongTien"].ToString() + " VNĐ";
                }
            }
        }
Example #2
0
        private void FormHoaDon_Load(object sender, EventArgs e)
        {
            refreshDataGridView();
            for (int i = 0; i < 9; i++)
            {
                cbThang.Items.Add("0" + (i + 1).ToString());
            }
            for (int i = 9; i < 12; i++)
            {
                cbThang.Items.Add((i + 1).ToString());
            }
            myDataBases db = new myDataBases();
            DataTable   dt = db.getData("select TenThucDon, SUM(SoLuong) from tblThucDon join tblCTHD on tblThucDon.MaThucDon = tblCTHD.MaThucDon group by tblCTHD.MaThucDon, TenThucDon having SUM(SoLuong) >=all (select SUM(SoLuong) from tblCTHD group by MaThucDon)");

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    lbMaxTD.Text = dr["TenThucDon"].ToString();
                }
            }
            DataTable dt1 = db.getData("select SUM(TongTien) as TongTien, SUM(SoKhach) as TongKhach from tblHoaDon");

            if (dt1 != null)
            {
                foreach (DataRow dr in dt1.Rows)
                {
                    lbTongKhach.Text = dr["TongKhach"].ToString() + " khách";
                    lbTongTien.Text  = dr["TongTien"].ToString() + " VNĐ";
                }
            }
        }
Example #3
0
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvCheBien.DataSource = db.getData("select TenThucDon, SoLuong, XacNhan, tblGoiMon1.MaThucDon from tblGoiMon1 join tblThucDon on tblGoiMon1.MaThucDon=tblThucDon.MaThucDon where MaBanAn=" + cbChonBan.Text);
            dgvNLHuy.DataSource   = db.getData("select TenNL from tblYeuCauNL join tblNguyenLieu on tblYeuCauNL.MaNL=tblNguyenLieu.MaNL where XacNhan=N'Hủy' group by tblYeuCauNL.MaNL, TenNL");
        }
Example #4
0
        private void DataGridView_DuaMon()
        {
            myDataBases db = new myDataBases();

            dgvDuaMon.DataSource = db.getData("select distinct MaBanAn from tblGoiMon1 where XacNhan = N'Xong'");
            dgvHuyMon.DataSource = db.getData("select distinct MaBanAn, TenThucDon from tblGoiMon1 join tblThucDon on tblGoiMon1.MaThucDon=tblThucDon.MaThucDon where XacNhan = N'Hủy'");
        }
Example #5
0
        private void BtnTheoKhoang_Click(object sender, EventArgs e)
        {
            myDataBases db = new myDataBases();
            DateTime    dateTime1 = dateTu.DateTime, dateTime2 = dateDen.DateTime;

            dgvHoaDon.DataSource = db.getData("select * from tblHoaDon where ThoiGianLap >='" + dateTime1.Year.ToString() + "-" + dateTime1.Month.ToString() + "-" + dateTime1.Day.ToString() + " 00:00:00' and ThoiGianLap <='" + dateTime2.Year.ToString() + "-" + dateTime2.Month.ToString() + "-" + dateTime2.Day.ToString() + " 23:59:59'");
            DataTable dt = db.getData("select TenThucDon, SUM(SoLuong) from tblThucDon join tblCTHD on tblThucDon.MaThucDon = tblCTHD.MaThucDon join tblHoaDon on tblHoaDon.SoHD = tblCTHD.SoHD where ThoiGianLap >='" + dateTime1.Year.ToString() + "-" + dateTime1.Month.ToString() + "-" + dateTime1.Day.ToString() + " 00:00:00' and ThoiGianLap <='" + dateTime2.Year.ToString() + "-" + dateTime2.Month.ToString() + "-" + dateTime2.Day.ToString() + " 23:59:59' group by tblCTHD.MaThucDon, TenThucDon having SUM(SoLuong) >=all (select SUM(SoLuong) from tblCTHD join tblHoaDon on tblHoaDon.SoHD = tblCTHD.SoHD where ThoiGianLap >='" + dateTime1.Year.ToString() + "-" + dateTime1.Month.ToString() + "-" + dateTime1.Day.ToString() + " 00:00:00' and ThoiGianLap <='" + dateTime2.Year.ToString() + "-" + dateTime2.Month.ToString() + "-" + dateTime2.Day.ToString() + " 23:59:59' group by MaThucDon)");

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    lbMaxTD.Text = dr["TenThucDon"].ToString();
                }
            }
            DataTable dt1 = db.getData("select SUM(TongTien) as TongTien, SUM(SoKhach) as TongKhach from tblHoaDon where ThoiGianLap >='" + dateTime1.Year.ToString() + "-" + dateTime1.Month.ToString() + "-" + dateTime1.Day.ToString() + " 00:00:00' and ThoiGianLap <='" + dateTime2.Year.ToString() + "-" + dateTime2.Month.ToString() + "-" + dateTime2.Day.ToString() + " 23:59:59'");

            if (dt1 != null)
            {
                foreach (DataRow dr in dt1.Rows)
                {
                    lbTongKhach.Text = dr["TongKhach"].ToString() + " khách";
                    lbTongTien.Text  = dr["TongTien"].ToString() + " VNĐ";
                }
            }
        }
Example #6
0
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvYeuCauNL.DataSource   = db.getData("select tblYeuCauNL.MaNL, TenNL, SUM(tblYeuCauNL.SoLuong) as SoLuong, DonGia, DonViTinh, XacNhan from tblYeuCauNL join tblNguyenLieu on tblYeuCauNL.MaNL  = tblNguyenLieu.MaNL group by tblYeuCauNL.MaNL, tblYeuCauNL.MaNL, TenNL, DonGia, DonViTinh, XacNhan");
            dgvNguyenLieu.DataSource = db.getData("select TenNL, TenNCC, SoLuong, HoTen, DonViTinh, DonGia, MaNL, tblNguyenLieu.MaNCC from tblNguyenLieu join tblNCC on tblNguyenLieu.MaNCC=tblNCC.MaNCC join tblNguoiDung on tblNguoiDung.MaNguoiDung=tblNguyenLieu.MaNVNhap");
            dgvYeuCauMua.DataSource  = db.getData("select tblYC_MuaNL.MaNL, TenNL, SUM(tblYC_MuaNL.SoLuong) as SoLuong, DonGia, DonViTinh, XacNhan from tblYC_MuaNL join tblNguyenLieu on tblYC_MuaNL.MaNL  = tblNguyenLieu.MaNL where XacNhan=N'Chấp Nhận' group by tblYC_MuaNL.MaNL, tblYC_MuaNL.MaNL, TenNL, DonGia, DonViTinh, XacNhan");
        }
Example #7
0
        private void FormCheBien_Load(object sender, EventArgs e)
        {
            myDataBases db = new myDataBases();

            dgvNguyenLieu.DataSource = db.getData("select TenNL, TenNCC, SoLuong, HoTen, DonViTinh, DonGia, MaNL, tblNguyenLieu.MaNCC from tblNguyenLieu join tblNCC on tblNguyenLieu.MaNCC=tblNCC.MaNCC join tblNguoiDung on tblNguoiDung.MaNguoiDung=tblNguyenLieu.MaNVNhap");
            dgvNLHuy.DataSource      = db.getData("select TenNL from tblYeuCauNL join tblNguyenLieu on tblYeuCauNL.MaNL=tblNguyenLieu.MaNL where XacNhan=N'Hủy' group by tblYeuCauNL.MaNL, TenNL");
            DataTable dt = db.getData("select distinct MaBanAn from tblGoiMon1");

            foreach (DataRow dr in dt.Rows)
            {
                cbChonBan.Items.Add(dr["MaBanAn"].ToString());
            }
        }
Example #8
0
        private void CbLoaiThucDon_SelectedIndexChanged(object sender, EventArgs e)
        {
            myDataBases db = new myDataBases();

            if (cbLoaiThucDon.Text == "==Tất Cả==")
            {
                dgvThucDon.DataSource = db.getData("SELECT * FROM tblThucDon");
            }
            else
            {
                dgvThucDon.DataSource = db.getData("SELECT * FROM tblThucDon where Loai=N'" + cbLoaiThucDon.Text + "'");
            }
        }
Example #9
0
        private void BtnTim_Click(object sender, EventArgs e)
        {
            myDataBases db = new myDataBases();

            if (cbTim_LoaiThucDon.Text == "==Tất Cả==")
            {
                dgvThucDon.DataSource = db.getData("select * from tblThucDon where TenThucDon like N'%" + textTim_TenThucDon.Text + "%'");
            }
            else
            {
                dgvThucDon.DataSource = db.getData("select * from tblThucDon where TenThucDon like N'%" + textTim_TenThucDon.Text + "%' and Loai=N'" + cbTim_LoaiThucDon.Text + "'");
            }
        }
Example #10
0
        private void CbChonBan_SelectedIndexChanged(object sender, EventArgs e)
        {
            lvThucDon.Clear();
            lvThucDon.Columns.Add("Thực Đơn", 175);
            lvThucDon.Columns.Add("Đơn Giá", 120);
            lvThucDon.Columns.Add("Số Lượng", 90);
            lvThucDon.Columns.Add("Xác Nhận", 100);
            myDataBases db = new myDataBases();
            DataTable   dt = db.getData("select TenThucDon, DonGia, SoLuong, XacNhan from tblGoiMon1 join tblThucDon on tblGoiMon1.MaThucDon=tblThucDon.MaThucDon where MaBanAn=" + cbChonBan.Text);

            n = dt.Rows.Count;
            int    dem      = 0;
            double tongtien = 0;

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    lvThucDon.Items.Add(dr["TenThucDon"].ToString());
                    lvThucDon.Items[dem].SubItems.Add(dr["DonGia"].ToString());
                    lvThucDon.Items[dem].SubItems.Add(dr["SoLuong"].ToString());
                    lvThucDon.Items[dem].SubItems.Add(dr["XacNhan"].ToString());
                    if (dr["XacNhan"].ToString() != "Hủy")
                    {
                        tongtien += double.Parse(dr["DonGia"].ToString()) * double.Parse(dr["SoLuong"].ToString());
                    }
                    dem++;
                }
            }
            lbTongTien.Text = tongtien.ToString();
            DataGridView_DuaMon();
        }
Example #11
0
        private string getID(string tendangnhap, string matkhau)
        {
            string id = "";

            try
            {
                myDataBases db = new myDataBases();
                DataTable   dt = new DataTable();
                dt = db.getData("SELECT * FROM tblNguoiDung WHERE TenDangNhap = '" + tendangnhap + "' AND MatKhau = '" + matkhau + "'");
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        id    = dr["MaNguoiDung"].ToString();
                        hoten = dr["HoTen"].ToString();
                        quyen = dr["Quyen"].ToString();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi xảy ra khi truy vấn dữ liệu hoặc kết nối với server thất bại !");
            }

            return(id);
        }
Example #12
0
 private void ViewHoaDon_Load(object sender, EventArgs e)
 {
     if ((formLogin.quyen == "Giám Đốc") || (formLogin.quyen == "Bồi Bàn"))
     {
         btnThanhToan.Visible = true;
     }
     lblTime.Text    = (DateTime.Now.Hour < 10 ? "0" + DateTime.Now.Hour.ToString() : DateTime.Now.Hour.ToString()) + ":" + (DateTime.Now.Minute < 10 ? "0" + DateTime.Now.Minute.ToString() : DateTime.Now.Minute.ToString()) + ":" + (DateTime.Now.Second < 10 ? "0" + DateTime.Now.Second.ToString() : DateTime.Now.Second.ToString());
     lblDate.Text    = (DateTime.Now.Day < 10 ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString()) + "-" + (DateTime.Now.Month < 10 ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString()) + "-" + DateTime.Now.Year;
     lbhoten.Text    = formLogin.hoten;
     lbBanSo.Text    = formGoiMon.SoBan;
     lbSoKhach.Text  = formGoiMon.SoKhach;
     lbTongTien.Text = formGoiMon.TongTien + "VNĐ";
     try
     {
         myDataBases db = new myDataBases();
         dgvMonAn.DataSource = db.getData("select TenThucDon, DonGia, SoLuong from tblGoiMon1 join tblThucDon on tblGoiMon1.MaThucDon=tblThucDon.MaThucDon where MaBanAn=" + lbBanSo.Text + " and XacNhan!=N'Hủy'");
         for (int i = 0; i < dgvMonAn.Rows.Count - 1; i++)
         {
             dgvMonAn.Rows[i].Cells[0].Value = (i + 1).ToString();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Chưa chọn bàn!");
     }
 }
Example #13
0
        private void BtnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                myDataBases db   = new myDataBases();
                string      date = DateTime.Now.Year + "-" + (DateTime.Now.Month < 10 ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString()) + "-" + (DateTime.Now.Day < 10 ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString());

                db.executeQuery("insert into tblHoaDon values (dbo.sinhmaHD()," + lbBanSo.Text + ",'" + date + " " + lblTime.Text + "'," + lbSoKhach.Text + ",'" + formLogin.MaNguoiDung + "'," + formGoiMon.TongTien + ")");

                DataTable dt = db.getData("select tblGoiMon1.MaThucDon, SoLuong from tblGoiMon1 join tblThucDon on tblGoiMon1.MaThucDon=tblThucDon.MaThucDon where MaBanAn=" + lbBanSo.Text + " and XacNhan!=N'Hủy'");
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        db.executeQuery("insert into tblCTHD values (dbo.sinhmaCTHD(),'" + dr["MaThucDon"].ToString() + "'," + dr["SoLuong"].ToString() + ")");
                    }
                }
                db.executeQuery("delete from tblGoiMon1 where MaBanAn=" + lbBanSo.Text);
                MessageBox.Show("Đã lưu!");
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi!");
            }
        }
Example #14
0
        private void DgvHoaDon_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int numrow;

            numrow = e.RowIndex;
            if (numrow >= 0)
            {
                myDataBases db = new myDataBases();
                dgvCTHD.DataSource = db.getData("select tblCTHD.*, TenThucDon, DonGia from tblCTHD join tblThucDon on tblCTHD.MaThucDon=tblThucDon.MaThucDon where SoHD='" + dgvHoaDon.Rows[numrow].Cells[0].Value.ToString() + "'");
                dtExcel            = db.getData("select tblCTHD.*, TenThucDon, DonGia from tblCTHD join tblThucDon on tblCTHD.MaThucDon=tblThucDon.MaThucDon where SoHD='" + dgvHoaDon.Rows[numrow].Cells[0].Value.ToString() + "'");
                ngaylp             = dgvHoaDon.Rows[numrow].Cells[2].Value.ToString();
                nguoilp            = dgvHoaDon.Rows[numrow].Cells[4].Value.ToString();
                banso    = dgvHoaDon.Rows[numrow].Cells[1].Value.ToString();;
                sokhach  = dgvHoaDon.Rows[numrow].Cells[3].Value.ToString();
                tongtien = dgvHoaDon.Rows[numrow].Cells[5].Value.ToString();
            }
        }
Example #15
0
        private void FormGoiMon_Load(object sender, EventArgs e)
        {
            refreshDataGridView();
            myDataBases db = new myDataBases();
            DataTable   dt = db.getData("SELECT * FROM tblBanAn");

            foreach (DataRow dr in dt.Rows)
            {
                cbChonBan.Items.Add(dr["MaBanAn"].ToString());
            }
            cbLoaiThucDon.Items.Add("==Tất Cả==");
            DataTable dt1 = db.getData("select distinct Loai from tblThucDon");

            foreach (DataRow dr in dt1.Rows)
            {
                cbLoaiThucDon.Items.Add(dr["Loai"].ToString());
            }
            DataGridView_DuaMon();
        }
Example #16
0
        private void DgvNguyenLieu_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            dgvrowNL = e.RowIndex;
            if (dgvrowNL >= 0)
            {
                textTenNL.Text   = dgvNguyenLieu.Rows[dgvrowNL].Cells[0].Value.ToString();
                textSoLuong.Text = dgvNguyenLieu.Rows[dgvrowNL].Cells[2].Value.ToString();
                sl = int.Parse(textSoLuong.Text);
            }
            myDataBases db = new myDataBases();

            dgvNLHuy.DataSource = db.getData("select TenNL from tblYeuCauNL join tblNguyenLieu on tblYeuCauNL.MaNL=tblNguyenLieu.MaNL where XacNhan=N'Hủy'");
        }
Example #17
0
        private void BtnDanhSach_Click(object sender, EventArgs e)
        {
            refreshDataGridView();
            myDataBases db = new myDataBases();
            DataTable   dt = db.getData("select TenThucDon, SUM(SoLuong) from tblThucDon join tblCTHD on tblThucDon.MaThucDon = tblCTHD.MaThucDon group by tblCTHD.MaThucDon, TenThucDon having SUM(SoLuong) >=all (select SUM(SoLuong) from tblCTHD group by MaThucDon)");

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    lbMaxTD.Text = dr["TenThucDon"].ToString();
                }
            }
            DataTable dt1 = db.getData("select SUM(TongTien) as TongTien, SUM(SoKhach) as TongKhach from tblHoaDon");

            if (dt1 != null)
            {
                foreach (DataRow dr in dt1.Rows)
                {
                    lbTongKhach.Text = dr["TongKhach"].ToString() + " khách";
                    lbTongTien.Text  = dr["TongTien"].ToString() + " VNĐ";
                }
            }
        }
Example #18
0
        private void FormNguyenLieu_Load(object sender, EventArgs e)
        {
            refreshDataGridView();
            if (formLogin.quyen.ToString() == "Giám Đốc")
            {
                btnSave.Visible   = true;
                btnCancel.Visible = true;
                grXuLy.Visible    = true;
            }
            myDataBases db = new myDataBases();
            DataTable   dt = db.getData("select distinct MaNCC from tblNCC");

            foreach (DataRow dr in dt.Rows)
            {
                cbMaNCC.Items.Add(dr["MaNCC"].ToString());
            }
        }
Example #19
0
        private void FormThucDon_Load(object sender, EventArgs e)
        {
            refreshDataGridView();
            if (formLogin.quyen.ToString() == "Giám Đốc")
            {
                btnSave.Visible   = true;
                btnCancel.Visible = true;
                grXuLy.Visible    = true;
            }
            myDataBases db  = new myDataBases();
            DataTable   dt1 = db.getData("select distinct Loai from tblThucDon");

            cbTim_LoaiThucDon.Items.Add("==Tất Cả==");
            foreach (DataRow dr in dt1.Rows)
            {
                cbLoaiThucDon.Items.Add(dr["Loai"].ToString());
                cbTim_LoaiThucDon.Items.Add(dr["Loai"].ToString());
            }
        }
Example #20
0
 private void FormNhanVien_Load(object sender, EventArgs e)
 {
     refreshDataGridView();
     if (formLogin.quyen.ToString() == "Giám Đốc")
     {
         btnSave.Visible         = true;
         btnCancel.Visible       = true;
         grXuLy.Visible          = true;
         lbTenDangNhap.Visible   = true;
         lbMatKhau.Visible       = true;
         lbQuyen.Visible         = true;
         textTenDangNhap.Visible = true;
         textMatKhau.Visible     = true;
         cbQuyen.Visible         = true;
         myDataBases db = new myDataBases();
         DataTable   dt = db.getData("select distinct Quyen from tblNguoiDung");
         foreach (DataRow dr in dt.Rows)
         {
             cbQuyen.Items.Add(dr["Quyen"].ToString());
         }
     }
 }
Example #21
0
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvThucDon.DataSource = db.getData("SELECT * FROM tblThucDon");
        }
Example #22
0
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvNguyenLieu.DataSource = db.getData("select TenNL, TenNCC, SoLuong, HoTen, DonViTinh, DonGia, MaNL, tblNguyenLieu.MaNCC from tblNguyenLieu join tblNCC on tblNguyenLieu.MaNCC=tblNCC.MaNCC join tblNguoiDung on tblNguoiDung.MaNguoiDung=tblNguyenLieu.MaNVNhap");
        }
Example #23
0
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvNhanVien.DataSource = db.getData("SELECT * FROM tblNguoiDung");
        }
Example #24
0
        private void BtnTim_Click(object sender, EventArgs e)
        {
            myDataBases db = new myDataBases();

            dgvNhanVien.DataSource = db.getData("select * from tblNguoiDung where HoTen like N'%" + textTim_HoTen.Text + "%'");
        }
Example #25
0
        private void BtnPrint_Click(object sender, EventArgs e)
        {
            Excel.Application exApp;
            Excel.Workbook    exBook;
            Excel.Worksheet   exSheet;
            Excel.Range       exRange;
            exApp   = new Excel.Application();
            exBook  = (Excel.Workbook)(exApp.Workbooks.Add(true));
            exSheet = (Excel.Worksheet)exBook.ActiveSheet;

            Excel.Range head = exSheet.get_Range("B2", "D2");
            head.MergeCells          = true;
            head.Value2              = "HÓA ĐƠN TÍNH TIỀN";
            head.Font.Bold           = true;
            head.Font.Name           = "Times New Roman";
            head.Font.Size           = "18";
            head.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;

            Excel.Range cl1 = exSheet.get_Range("B10", "B10");
            cl1.Value2      = "Tên Món";
            cl1.ColumnWidth = 30;

            Excel.Range cl2 = exSheet.get_Range("C10", "C10");
            cl2.Value2              = "Đơn Giá";
            cl2.ColumnWidth         = 20;
            cl2.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;

            Excel.Range cl3 = exSheet.get_Range("D10", "D10");
            cl3.Value2              = "Số Lượng";
            cl3.ColumnWidth         = 10;
            cl3.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;

            Excel.Range cl4 = exSheet.get_Range("C4", "C8");
            cl4.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
            exSheet.Cells[4, 2]     = "Ngày Lập Phiếu: ";
            exSheet.Cells[4, 3]     = ngaylp;
            exSheet.Cells[5, 2]     = "Người Lập Phiếu: ";
            myDataBases db      = new myDataBases();
            DataTable   dtHoTen = db.getData("select HoTen from tblNguoiDung where MaNguoiDung='" + nguoilp + "'");
            string      tenlp   = "";

            if (dtHoTen != null)
            {
                foreach (DataRow dr in dtHoTen.Rows)
                {
                    tenlp = dr["HoTen"].ToString();
                }
            }
            exSheet.Cells[5, 3] = tenlp;
            exSheet.Cells[6, 2] = "Bàn Số: ";
            exSheet.Cells[6, 3] = banso;
            exSheet.Cells[7, 2] = "Số Khách: ";
            exSheet.Cells[7, 3] = sokhach;
            exSheet.Cells[8, 2] = "Tổng Tiền: ";
            exSheet.Cells[8, 3] = tongtien + " VNĐ";
            int iRow = 11;

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                exSheet.Cells[iRow, 2] = dtExcel.Rows[i]["TenThucDon"].ToString();
                exSheet.Cells[iRow, 3] = dtExcel.Rows[i]["DonGia"].ToString();
                exSheet.Cells[iRow, 4] = dtExcel.Rows[i]["SoLuong"].ToString();
                iRow++;
            }
            exRange = exSheet.get_Range("B10", "D" + (iRow - 1).ToString());

            exRange.Borders.Color = Color.Black.ToArgb();

            //exSheet.Cells[iRow+1, 3] = "Nhà Hàng MyLove";
            Excel.Range nhahang = exSheet.get_Range("C" + (iRow + 1).ToString(), "D" + (iRow + 1).ToString());
            nhahang.MergeCells          = true;
            nhahang.Font.Name           = "Times New Roman";
            nhahang.Value2              = "Nhà Hàng MyLove";
            nhahang.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;

            exApp.UserControl = false;
            exApp.Visible     = true;
        }
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvYeuCauMua.DataSource = db.getData("select tblYC_MuaNL.MaNL, TenNL, SUM(tblYC_MuaNL.SoLuong) as SoLuong, DonGia, DonViTinh, XacNhan from tblYC_MuaNL join tblNguyenLieu on tblYC_MuaNL.MaNL  = tblNguyenLieu.MaNL group by tblYC_MuaNL.MaNL, tblYC_MuaNL.MaNL, TenNL, DonGia, DonViTinh, XacNhan");
        }
        private void refreshDataGridView()
        {
            myDataBases db = new myDataBases();

            dgvThanhToan.DataSource = db.getData("select tblNhapNL.MaNL, TenNL, tblNhapNL.SoLuong, NgayNhap, DonGia, DonViTinh, XacNhan from tblNhapNL join tblNguyenLieu on tblNhapNL.MaNL  = tblNguyenLieu.MaNL where XacNhan=N'Đã Nhận, Chưa Thanh Toán Tiền'");
        }
Example #28
0
        private void BtnTim_Click(object sender, EventArgs e)
        {
            myDataBases db = new myDataBases();

            dgvNCC.DataSource = db.getData("select * from tblNCC where TenNCC like N'%" + textTim_TenNCC.Text + "%'");
        }