Esempio n. 1
0
        public bool xoaCTBaoCaoNam(ChiTietBaoCaoNam ctBCN)
        {
            SqlConnection sqlConnection = createConnection();

            try
            {
                sqlConnection.Open();
                string SQL = "DELETE CHI_TIET_BAO_CAO_DOANH_THU_NAM WHERE MaCTBCNam = '" + ctBCN.MaCTBCNam + "'";

                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);
        }
Esempio n. 2
0
        public bool suaCTBaoCaoNam(ChiTietBaoCaoNam ctBCN)
        {
            SqlConnection sqlConnection = createConnection();

            try
            {
                sqlConnection.Open();
                string SQL = "UPDATE CHI_TIET_BAO_CAO_DOANH_THU_NAM SET Thang = '" + ctBCN.Thang + "', SoChuyenBay = '" + ctBCN.SoChuyenBay + "', DoanhThu = '" + ctBCN.DoanhThu + "', MaBaoCaoNam = '" + ctBCN.MaBCNam + "' WHERE MaCTBCNam = '" + ctBCN.MaCTBCNam + "'";;

                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);
        }
Esempio n. 3
0
        public bool themCTBaoCaoNam(ChiTietBaoCaoNam ctBCN)
        {
            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_NAM(MaCTBCNam, Thang, MaBaoCaoNam) VALUES ('" + ctBCN.MaCTBCNam + "','" + ctBCN.Thang + "', '" + ctBCN.MaBCNam + "')";
                SqlCommand cmd  = new SqlCommand(SQL, sqlConnection);
                string     SQL1 = "UPDATE CHI_TIET_BAO_CAO_DOANH_THU_NAM SET SoChuyenBay = (SELECT COUNT(DISTINCT V.MaCB) FROM VE_CHUYEN_BAY V, LICH_CHUYEN_BAY L WHERE V.MaCB = L.MaCB AND MONTH(L.NgayGio) = '" + ctBCN.Thang + "' AND YEAR(L.NgayGio) = (SELECT SUBSTRING('" + ctBCN.MaBCNam + "',4,4))), DoanhThu = (SELECT SUM(V.GiaTien) FROM VE_CHUYEN_BAY V, LICH_CHUYEN_BAY L WHERE V.MaCB = L.MaCB AND MONTH(L.NgayGio) = '" + ctBCN.Thang + "' AND YEAR(L.NgayGio) = (SELECT SUBSTRING('" + ctBCN.MaBCNam + "',4,4))) WHERE MaCTBCNam = '" + ctBCN.MaCTBCNam + "'";
                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);
        }