Beispiel #1
0
 private void btnsua_Click(object sender, EventArgs e)
 {
     if (int.Parse(txtnsx.Text) < 2005)
     {
         MessageBox.Show("không sửa được!");
     }
     try
     {
         string         soxe = dataGridView1.CurrentRow.Cells[0].Value.ToString();
         tbl_THONGTINXE hh   = connectdb.tbl_THONGTINXE.Single(p => p.SoXe.Equals(soxe));
         if (txtmaloai.Text.Length != 0)
         {
             hh.MaLoai = txtmaloai.Text;
         }
         hh.ChuXe      = txtchuxe.Text;
         hh.DonGiaNgay = Int32.Parse(txtdongia.Text);
         hh.NamSX      = int.Parse(txtnsx.Text);
         hh.TenXe      = txttenxe.Text;
         hh.SoXe       = txtsoxe.Text;
         connectdb.SaveChanges();
         loaddb();
         MessageBox.Show("Cap Nhat Thanh Cong!!!");
     }
     catch
     {
         MessageBox.Show("Chưa Cập Nhật!!!");
     }
 }
Beispiel #2
0
        private void btnthem_Click(object sender, EventArgs e)
        {
            if (int.Parse(txtnsx.Text) < 2005)
            {
                MessageBox.Show("không thêm được!");
            }

            try
            {
                tbl_THONGTINXE hh = new tbl_THONGTINXE(); // tạo obj mới
                hh.SoXe       = txtsoxe.Text.ToString();
                hh.MaLoai     = txtmaloai.Text;
                hh.ChuXe      = txtchuxe.Text;
                hh.DonGiaNgay = Int32.Parse(txtdongia.Text);
                hh.NamSX      = int.Parse(txtnsx.Text);
                hh.TenXe      = txttenxe.Text;
                connectdb.tbl_THONGTINXE.Add(hh);
                connectdb.SaveChanges();
                loaddb();
                MessageBox.Show("đã thêm");
            }
            catch (Exception)
            {
                MessageBox.Show("không thêm được");
            }
        }
        private string kiemtraoto(string a)
        {
            tbl_THONGTINXE tt = connectdb.tbl_THONGTINXE.Single(p => p.SoXe.Equals(a));

            if (tt.MaLoai.Contains("chổ"))
            {
                return(tt.MaLoai);
            }
            return(null);
        }
Beispiel #4
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string         soxe = dataGridView1.CurrentRow.Cells[0].Value.ToString();        // lay gia tri cell 0 trong bang dataGrid
            tbl_THONGTINXE hh   = connectdb.tbl_THONGTINXE.Single(p => p.SoXe.Equals(soxe)); // dieu kien Mahh = mahang get

            txtsoxe.Text   = hh.SoXe;
            txtmaloai.Text = hh.MaLoai;
            txtchuxe.Text  = hh.ChuXe;
            txtdongia.Text = hh.DonGiaNgay.ToString();
            txtnsx.Text    = hh.NamSX.ToString();
            txttenxe.Text  = hh.TenXe;
        }
        private string kiemtrabanglai(string a)
        {
            tbl_THONGTINXE tt = connectdb.tbl_THONGTINXE.Single(p => p.SoXe.Equals(a));
            tbl_LOAIXE     lx = connectdb.tbl_LOAIXE.Single(q => q.MaLoai.Equals(tt.MaLoai));
            tbl_BANGLAI    bl = connectdb.tbl_BANGLAI.Single(r => r.LoaiXe.Equals(lx.MaLoai));
            tbl_KHACHHANG  kh = connectdb.tbl_KHACHHANG.Single(e => e.MaKH.Equals(txtmkh.Text));

            if (kh.BangLai == bl.YeuCauBangLai)
            {
                return(bl.YeuCauBangLai);
            }
            return(null);
        }
Beispiel #6
0
 private void xoa()
 {
     try
     {
         string         soxe = dataGridView1.CurrentRow.Cells[0].Value.ToString();
         tbl_THONGTINXE xe   = connectdb.tbl_THONGTINXE.Single(p => p.SoXe.Equals(soxe));
         connectdb.tbl_THONGTINXE.Remove(xe);
         connectdb.SaveChanges();
         loaddb();
         MessageBox.Show("Da xoa");
     }
     catch (Exception)
     {
         MessageBox.Show("khong xóa được");
     }
 }
        private string kiemtra(string a)
        {
            tbl_THONGTINXE tt = connectdb.tbl_THONGTINXE.Single(p => p.SoXe.Equals(a));

            return(tt.MaLoai);
        }