Ejemplo n.º 1
0
        public bool suaHangVe(HangVe hV)
        {
            SqlConnection sqlConnection = createConnection();

            try
            {
                sqlConnection.Open();
                string SQL = "UPDATE HANG_VE SET TenHV = N'" + hV.TenHV + "', GhiChu = N'" + hV.GhiChu + "' WHERE MaHV = '" + hV.MaHV + "'";

                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);
        }
Ejemplo n.º 2
0
        public bool themHangVe(HangVe hV)
        {
            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 HANG_VE(MaHV, TenHV, GhiChu) VALUES ('" + hV.MaHV + "', N'" + hV.TenHV + "',N'" + hV.GhiChu + "')";

                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);
        }