private void bt_thongke_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa nhập tháng");
                comboBox1.Focus();
                return;
            }
            if (comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa nhập năm");
                comboBox2.Focus();
                return;
            }
            string sql = " select Hoa_don_ban.Makhach,Tenkhach,Diachi,Dienthoai,ngayban,chi_tiet_hoa_don_ban.mabinh ,"
                         + "  chi_tiet_hoa_don_ban.soluong as so_luong,giamgia,dbo.DM_Binh_ga.dongiaban,thanhtien,tenbinh "
                         + "from Hoa_don_ban join Khach_hang on Hoa_don_ban.MaKhach = Khach_hang.Makhach JOIN dbo.Chi_tiet_hoa_don_ban "
                         + " ON hoa_don_ban.sohdb = chi_tiet_hoa_don_ban.sohdb JOIN "
                         + "dbo.DM_Binh_ga ON chi_tiet_hoa_don_ban.mabinh = dm_binh_ga.mabinh"
                         + " where MONTH(ngayban) =" + comboBox1.SelectedValue + " and YEAR(ngayban)=" + comboBox2.SelectedValue;


            BCKH = DAO.GetDataToTable(sql);
            if (BCKH.Rows.Count == 0)
            {
                MessageBox.Show("không có bản ghi nào thỏa mãn điều kiện", "thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("có" + BCKH.Rows.Count + "bản ghi thỏa mãn điều kiện", "thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            DAO.loatdata(sql, dataGridView1);
        }
Esempio n. 2
0
        private void bt_thongke_Click_1(object sender, EventArgs e)
        {
            if (text_nam.Text == "")
            {
                MessageBox.Show("bạn phải nhập năm báo cáo");
                text_nam.Focus();
                return;
            }
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("bạn phải chọn mã nhà cung cấp");
            }
            DAO.OpenConnection();
            string sql = "select Chi_tiet_hoa_don_nhap.SoHDN,NgayNhap, nha_cc.MaNCC,TenNCC," +
                         "Dienthoai,Mabinh,Soluong,GIAMGIA,Dongia,Thanhtien from Nha_cc join Hoa_don_nhap on " +
                         "Nha_cc.MaNCC = Hoa_don_nhap.MaNCC join Chi_tiet_hoa_don_nhap " +
                         "on Hoa_don_nhap.SoHDN = Chi_tiet_hoa_don_nhap.SoHDN where month(ngaynhap)='"
                         + numeric_thang.Value + "' and year(ngaynhap)='" + text_nam.Text + "'" +
                         "AND nha_cc.mancc='" + comboBox1.SelectedValue + "'";

            DAO.loatdata(sql, datagridview_DSHDN);
            // LBTONG=
            string sql1 = "select sum(thanhtien)  from Nha_cc join Hoa_don_nhap on " +
                          "Nha_cc.MaNCC = Hoa_don_nhap.MaNCC join Chi_tiet_hoa_don_nhap " +
                          "on Hoa_don_nhap.SoHDN = Chi_tiet_hoa_don_nhap.SoHDN  where month(ngaynhap)='"
                          + numeric_thang.Value + "' and year(ngaynhap)='" + text_nam.Text + "' and " +
                          " hoa_don_nhap.mancc='" + comboBox1.SelectedValue + "'";

            LBTONG.Text = DAO.GetFieldValues(sql1);
            DAO.CloseConnection();
        }
Esempio n. 3
0
        private void FrmBaoCaoTop3_Load(object sender, EventArgs e)
        {
            DAO.OpenConnection();
            goiy();
            string sql = "SELECT c.MaNV,TenNV,a.Mabinh,d.Tenbinh, sum(a.Soluong) as soluong from " +
                         "Chi_tiet_hoa_don_ban as a join Hoa_don_ban as b on a.SoHDB = b.SoHDB join " +
                         "Nhan_vien  as c on c.MaNV = b.MaNV join DM_Binh_ga as d on " +
                         "d.Mabinh = a.Mabinh group by tenbinh ,c.MaNV, TenNV, a.mabinh, tenbinh order by soluong ASC";

            DAO.loatdata(sql, dataGridView1);
            DAO.FillCombo("SELECT MaNV, TenNV FROM nhan_vien", combo_manv, "TenNV", "MaNV");
            DAO.CloseConnection();
        }
Esempio n. 4
0
 private void BaoCaoKhachHang_Load(object sender, EventArgs e)
 {
     DAO.OpenConnection();
     string sql1 = "select DISTINCT month(ngayban) as thang from hoa_don_ban order by month(ngayban) asc";
     DAO.FillCombo(sql1, comboBox1, "thang", "thang");
     string sql2 = "select DISTINCT year(ngayban) as  nam from hoa_don_ban order by year(ngayban)";
     DAO.FillCombo(sql2, comboBox2, "nam", "nam");
     string sql = " select Hoa_don_ban.Makhach,Tenkhach,Diachi,Dienthoai,ngayban,chi_tiet_hoa_don_ban.mabinh ,"
                + " chi_tiet_hoa_don_ban.soluong as so_luong,giamgia,dbo.DM_Binh_ga.dongiaban,thanhtien,tenbinh "
               + "from Hoa_don_ban join Khach_hang on Hoa_don_ban.MaKhach = Khach_hang.Makhach JOIN dbo.Chi_tiet_hoa_don_ban "
               + " ON hoa_don_ban.sohdb = chi_tiet_hoa_don_ban.sohdb JOIN "
                + "dbo.DM_Binh_ga ON chi_tiet_hoa_don_ban.mabinh = dm_binh_ga.mabinh";
     DAO.loatdata(sql, dataGridView1);
     DAO.CloseConnection();
 }
Esempio n. 5
0
        private void bt_timkiem_Click(object sender, EventArgs e)
        {
            string sql;

            if ((txtNgaynhap.Text == "") && (cboMaNCC.Text == "") && (cboMabinh.Text == ""))


            {
                MessageBox.Show("Hãy nhập một điều kiện tìm kiếm!!!", "Yêu cầu ...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            sql = "select tenbinh /*Chi_tiet_hoa_don_nhap.SoHDN*/, Hoa_don_nhap.NgayNhap,Chi_tiet_hoa_don_nhap.Mabinh," +
                  "Hoa_don_nhap.MaNCC,Chi_tiet_hoa_don_nhap.Dongia,Chi_tiet_hoa_don_nhap.Soluong,Chi_tiet_hoa_don_nhap.Giamgia," +
                  "Chi_tiet_hoa_don_nhap.Thanhtien,manv,hoa_don_nhap.sohdn" +
                  " from Chi_tiet_hoa_don_nhap join Hoa_don_nhap on Chi_tiet_hoa_don_nhap.SoHDN = Hoa_don_nhap.SoHDN join DM_Binh_ga ON DM_Binh_ga.Mabinh = Chi_tiet_hoa_don_nhap.Mabinh where 1=1 ";

            if (cboMabinh.Text != "")
            {
                sql = sql + " AND dm_binh_ga.Mabinh Like N'%" + cboMabinh.Text + "%'";
            }

            if (cboMaNCC.Text != "")
            {
                sql = sql + " AND Mancc Like N'%" + cboMaNCC.SelectedValue + "%'";
            }

            if (txtNgaynhap.Text != "")
            {
                sql = sql + "AND CONVERT(VARCHAR(25), Ngaynhap, 126) Like N'%" + DAO.ConvertDateTime(txtNgaynhap.Text) + "%'";
            }

            DataTable DM_Binh_ga = DAO.GetDataToTable(sql);

            if (DM_Binh_ga.Rows.Count == 0)
            {
                MessageBox.Show("không có bản ghi nào thỏa mãn điều kiện", "thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Có " + DM_Binh_ga.Rows.Count + " bản ghi thỏa mãn điều kiện!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            DAO.loatdata(sql, DataGridView_hdn);
        }
Esempio n. 6
0
        private void BaoCaoDanhSachHDN_Load(object sender, EventArgs e)
        {
            DAO.OpenConnection();
            string sql = "select Chi_tiet_hoa_don_nhap.SoHDN,NgayNhap, nha_cc.MaNCC,TenNCC," +
                         "Dienthoai,Mabinh,Soluong,GIAMGIA,Dongia,Thanhtien from Nha_cc join Hoa_don_nhap on " +
                         "Nha_cc.MaNCC = Hoa_don_nhap.MaNCC join Chi_tiet_hoa_don_nhap " +
                         "on Hoa_don_nhap.SoHDN = Chi_tiet_hoa_don_nhap.SoHDN";

            DAO.loatdata(sql, datagridview_DSHDN);
            DAO.FillCombo("select * from nha_cc", comboBox1, "mancc", "mancc");
            goiy();
            // textBoxtenncc.AutoCompleteMode = AutoCompleteMode.Suggest;
            //  textBoxtenncc.AutoCompleteSource = AutoCompleteSource.CustomSource;
            // AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
            // getda (DataCollection);
            //  textBox1.AutoCompleteCustomSource = DataCollection;
            DAO.CloseConnection();
        }
Esempio n. 7
0
        private void bt_thongke_Click(object sender, EventArgs e)
        {
            DAO.OpenConnection();
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa nhập tháng");
                comboBox1.Focus();
                return;
            }
            if (comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa nhập năm");
                comboBox2.Focus();
                return;
            }
            string sql = "select sum(thanhtien) as tong_tien,DM_binh_ga.dongiaban," +
                         "dm_binh_ga.mabinh,tenbinh,sum(chi_tiet_hoa_don_ban.soluong) as so_luong, ngayban " +

                         "from chi_tiet_Hoa_don_ban join dm_binh_ga on " +
                         "chi_tiet_hoa_don_ban.mabinh = dm_binh_ga.mabinh join hoa_don_ban on hoa_don_ban.sohdb = chi_tiet_hoa_don_ban.sohdb " +
                         " where MONTH(ngayban)=" + comboBox1.SelectedValue + " and YEAR(ngayban)=" + comboBox2.SelectedValue +

                         " group BY dm_binh_ga.mabinh,tenbinh,DM_binh_ga.dongiaban,ngayban ";

            BCDT = DAO.GetDataToTable(sql);
            if (BCDT.Rows.Count == 0)
            {
                MessageBox.Show("không có bản ghi nào thỏa mãn điều kiện", "thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("có" + BCDT.Rows.Count + "bản ghi thỏa mãn điều kiện", "thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            DAO.loatdata(sql, dataGridViewdoanhthu);



            labeldoanhthu.Text = DAO.GetFieldValues("SELECT SUM(thanhtien) FROM dbo.Chi_tiet_hoa_don_ban JOIN dbo.Hoa_don_ban ON hoa_don_ban.sohdb = chi_tiet_hoa_don_ban.sohdb  " +
                                                    " where MONTH(ngayban)=" + comboBox1.SelectedValue + " and YEAR(ngayban)=" + comboBox2.SelectedValue);
            DAO.CloseConnection();
        }
Esempio n. 8
0
        private void BaoCaoDoanhThu_Load(object sender, EventArgs e)
        {
            DAO.OpenConnection();
            string sql1 = "select distinct month(ngayban) as thang from hoa_don_ban order by month(ngayban) asc";

            DAO.FillCombo(sql1, comboBox1, "thang", "thang");
            string sql2 = "select distinct year(ngayban) as  nam from hoa_don_ban order by year(ngayban)";

            DAO.FillCombo(sql2, comboBox2, "nam", "nam");
            string sql = "select sum(thanhtien) as tong_tien,DM_binh_ga.dongiaban," +
                         "dm_binh_ga.mabinh,tenbinh,sum(chi_tiet_hoa_don_ban.soluong) as so_luong," +
                         " ngayban" +
                         " from chi_tiet_Hoa_don_ban join dm_binh_ga on " +
                         "chi_tiet_hoa_don_ban.mabinh = dm_binh_ga.mabinh join hoa_don_ban on hoa_don_ban.sohdb = chi_tiet_hoa_don_ban.sohdb " +


                         " group BY dm_binh_ga.mabinh,tenbinh,DM_binh_ga.dongiaban,ngayban";

            DAO.loatdata(sql, dataGridViewdoanhthu);
            DAO.CloseConnection();
        }
Esempio n. 9
0
        // private void buttonthem_Click(object sender, EventArgs e)


        private void loaddata()
        {
            string sql = "select* from Khoi_luong";

            DAO.loatdata(sql, gridviewKhoiluong);
        }
Esempio n. 10
0
        private void loaddata()
        {
            string sql = "select * from nha_cc";

            DAO.loatdata(sql, dataGridViewncc);
        }
Esempio n. 11
0
        private void loaddata()
        {
            string sql = "select * from Ca_lam";

            DAO.loatdata(sql, dataGridView1);
        }
Esempio n. 12
0
        private void loaddata()
        {
            string sql = "select * from Khach_hang";

            DAO.loatdata(sql, dataGridViewkhachhang);
        }
Esempio n. 13
0
        private void frmKhachHang_Load(object sender, EventArgs e)
        {
            string sql = "select * from Khach_hang";

            DAO.loatdata(sql, dataGridViewkhachhang);
        }
Esempio n. 14
0
        //private void CongViec_Load(object sender, EventArgs e)
        private void loaddata()
        {
            string sql = "select * from cong_viec";

            DAO.loatdata(sql, dataGridViewcv);
        }