Exemplo n.º 1
0
 private void btnXoaPT_Click(object sender, EventArgs e)
 {
     using (DataClasses1DataContext data = new DataClasses1DataContext())
     {
         string            maTour = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaSoTour").ToString();
         string            maPT   = gridView3.GetRowCellValue(gridView3.FocusedRowHandle, "MaSoPhuongTien").ToString();
         ChiTietPhuongTien ctpt   = data.ChiTietPhuongTiens.Where(t => t.MaSoTour == int.Parse(maTour) && t.MaSoPhuongTien == int.Parse(maPT)).FirstOrDefault();
         DialogResult      r;
         r = MessageBox.Show("Bạn có muốn xóa phương tiện này", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (r == DialogResult.Yes)
         {
             data.ChiTietPhuongTiens.DeleteOnSubmit(ctpt);
             data.SubmitChanges();
             loadDgvPhuongTienTheoMa(int.Parse(maTour));
         }
     }
 }
Exemplo n.º 2
0
 private void btnLuuPT_Click(object sender, EventArgs e)
 {
     using (DataClasses1DataContext data = new DataClasses1DataContext())
     {
         if (trangThai3 == "them")
         {
             ChiTietPhuongTien ctpt   = new ChiTietPhuongTien();
             string            maTour = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaSoTour").ToString();
             ctpt.MaSoTour       = int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaSoTour").ToString());
             ctpt.MaSoPhuongTien = int.Parse(cboPhuongTien.EditValue.ToString());
             data.ChiTietPhuongTiens.InsertOnSubmit(ctpt);
             data.SubmitChanges();
             loadDgvPhuongTienTheoMa(int.Parse(maTour));
             ClearAllDichVu();
             MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
     }
 }