public bool xoaCTBaoCaoThang(ChiTietBaoCaoThang ctBCT)
        {
            SqlConnection sqlConnection = createConnection();

            try
            {
                sqlConnection.Open();
                string SQL = "DELETE CHI_TIET_BAO_CAO_DOANH_THU_THANG WHERE STT = '" + ctBCT.STT + "'";

                SqlCommand cmd = new SqlCommand(SQL, sqlConnection);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Dong ket noi
                sqlConnection.Close();
            }
            return(false);
        }
        public bool suaCTBaoCaoThang(ChiTietBaoCaoThang ctBCT)
        {
            SqlConnection sqlConnection = createConnection();

            try
            {
                sqlConnection.Open();
                string SQL = "UPDATE CHI_TIET_BAO_CAO_DOANH_THU_THANG SET MaCB = '" + ctBCT.MaCB + "', SoVe = '" + ctBCT.SoVe + "', DoanhThu = '" + ctBCT.DoanhThu + "', MaBaoCaoThang = '" + ctBCT.MaBCThang + "' WHERE STT = '" + ctBCT.STT + "'";;

                SqlCommand cmd = new SqlCommand(SQL, sqlConnection);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Dong ket noi
                sqlConnection.Close();
            }
            return(false);
        }
        public bool themCTBaoCaoThang(ChiTietBaoCaoThang ctBCT)
        {
            SqlConnection sqlConnection = createConnection();

            try
            {
                sqlConnection.Open();
                //SqlCommand cmd = new SqlCommand("INSERT INTO SAN_BAY(MaSB,TenSB) VALUES ('" + txtMaSB.Text + "',N'" + txtTenSB.Text + "')", con);

                string     SQL  = "INSERT INTO CHI_TIET_BAO_CAO_DOANH_THU_THANG(MaCB, MaBaoCaoThang) VALUES ('" + ctBCT.MaCB + "', '" + ctBCT.MaBCThang + "')";
                SqlCommand cmd  = new SqlCommand(SQL, sqlConnection);
                string     SQL1 = "UPDATE CHI_TIET_BAO_CAO_DOANH_THU_THANG SET SoVe = (SELECT COUNT(MaVeCB) FROM VE_CHUYEN_BAY V, LICH_CHUYEN_BAY L WHERE V.MaCB = L.MaCB AND MONTH(L.NgayGio) = (SELECT SUBSTRING('" + ctBCT.MaBCThang + "',4,2)) AND YEAR(L.NgayGio) = (SELECT SUBSTRING('" + ctBCT.MaBCThang + "',6,4))), DoanhThu = (SELECT SUM(V.GiaTien) FROM VE_CHUYEN_BAY V, LICH_CHUYEN_BAY L WHERE V.MaCB = L.MaCB AND MONTH(L.NgayGio) = (SELECT SUBSTRING('" + ctBCT.MaBCThang + "',4,2)) AND YEAR(L.NgayGio) = (SELECT SUBSTRING('" + ctBCT.MaBCThang + "',6,4))) WHERE MaBaoCaoThang = '" + ctBCT.MaBCThang + "'";
                SqlCommand cmd1 = new SqlCommand(SQL1, sqlConnection);
                // Query và kiểm tra
                if ((cmd.ExecuteNonQuery() > 0) && (cmd1.ExecuteNonQuery() > 0))
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Dong ket noi
                sqlConnection.Close();
            }
            return(false);
        }