Beispiel #1
0
        private void btnThemMB_Click(object sender, EventArgs e)
        {
            MayBay objMB = new MayBay();

            //Lấy giá trị từ giao diện
            objMB.MaMayBay    = txtMaMB.Text;
            objMB.TenMayBay   = txtTenMB.Text;
            objMB.HangSanXuat = txtHangSX.Text;
            objMB.SoLuongGhe1 = Convert.ToInt32(txtGhe1.Text);
            objMB.SoLuongGhe2 = Convert.ToInt32(txtGhe2.Text);

            bool kq = false;

            kq = ConnectSQL.ActMayBay.ThemMoi(objMB);
            if (kq)
            {
                MessageBox.Show("Thêm máy bay thành công");
                //reload lại danh sách sau khi thêm
                HienThiDanhSachMB();
            }
        }
Beispiel #2
0
        public bool CapNhat(MayBay objMB)
        {
            string sqlstr = "Update MayBay set MaMayBay = @MaMayBay, TenMayBay = @TenMayBay, HangSanXuat = @HangSanXuat, SoLuongGhe1 = @SoLuongGhe1, SoLuongGhe2 = @SoLuongGhe2 where MaMayBay = @MaMayBay ";

            SqlParameter[] pars = new SqlParameter[5];

            pars[0]       = new SqlParameter("@MaMayBay", SqlDbType.NChar, 5);
            pars[0].Value = objMB.MaMayBay;

            pars[1]       = new SqlParameter("@TenMayBay", SqlDbType.NChar, 30);
            pars[1].Value = objMB.TenMayBay;

            pars[2]       = new SqlParameter("@HangSanXuat", SqlDbType.NChar, 30);
            pars[2].Value = objMB.HangSanXuat;

            pars[3]       = new SqlParameter("@SoLuongGhe1", SqlDbType.Int);
            pars[3].Value = objMB.SoLuongGhe1;

            pars[4]       = new SqlParameter("@SoLuongGhe2", SqlDbType.Int);
            pars[4].Value = objMB.SoLuongGhe2;

            return(ConnectSQL.ThucHien(sqlstr, pars));
        }
Beispiel #3
0
        public bool ThemMoi(MayBay objMB)
        {
            string sqlstr = "insert into MayBay(MaMayBay, TenMayBay, HangSanXuat, SoLuongGhe1, SoLuongGhe2) values (@MaMayBay, @TenMayBay, @HangSanXuat, @SoLuongGhe1, @SoLuongGhe2)";

            SqlParameter[] pars = new SqlParameter[5];

            pars[0]       = new SqlParameter("@MaMayBay", SqlDbType.NChar, 5);
            pars[0].Value = objMB.MaMayBay;

            pars[1]       = new SqlParameter("@TenMayBay", SqlDbType.NChar, 30);
            pars[1].Value = objMB.TenMayBay;

            pars[2]       = new SqlParameter("@HangSanXuat", SqlDbType.NChar, 30);
            pars[2].Value = objMB.HangSanXuat;

            pars[3]       = new SqlParameter("@SoLuongGhe1", SqlDbType.Int);
            pars[3].Value = objMB.SoLuongGhe1;

            pars[4]       = new SqlParameter("@SoLuongGhe2", SqlDbType.Int);
            pars[4].Value = objMB.SoLuongGhe2;

            return(ConnectSQL.ThucHien(sqlstr, pars));
        }
Beispiel #4
0
        private void btnSuaMB_Click(object sender, EventArgs e)
        {
            string mamb = "" + dgrMayBay.CurrentRow.Cells[0].Value;

            MayBay objMB = new MayBay();

            //Lấy giá trị từ giao diện
            objMB.MaMayBay    = txtMaMB.Text;
            objMB.TenMayBay   = txtTenMB.Text;
            objMB.HangSanXuat = txtHangSX.Text;
            objMB.SoLuongGhe1 = Convert.ToInt32(txtGhe1.Text);
            objMB.SoLuongGhe2 = Convert.ToInt32(txtGhe2.Text);

            bool kq = false;

            kq = ConnectSQL.ActMayBay.CapNhat(objMB);
            if (kq)
            {
                MessageBox.Show("Cập nhật máy bay thành công");
                //reload lại danh sách sau khi thêm
                HienThiDanhSachMB();
            }
        }