コード例 #1
0
 public int Insert(PhongVO phongVO)
 {
     try
     {
         return(phongDAO.Insert(phongVO));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #2
0
 private void btn_ThemConfirm_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txt_maphong.Text == "")
         {
             MessageBox.Show("Vui lòng nhập mã phòng.");
             return;
         }
         Phong       p           = new Phong();
         DataRowView rowview_lp  = cb_loaiphong.SelectedItem as DataRowView;
         DataRowView rowview_tt  = cb_tinhtrang.SelectedItem as DataRowView;
         DataRowView rowview_tth = cb_trangthai.SelectedItem as DataRowView;
         p.MaPhong   = Int32.Parse(txt_maphong.Text);
         p.LoaiPhong = rowview_lp["MaLoai"].ToString();
         p.TinhTrang = Int32.Parse(rowview_tt["MaTT"].ToString());
         p.TrangThai = Int32.Parse(rowview_tth["MaTT"].ToString());
         p.GhiChu    = txt_ghichu.Text;
         MessageBoxResult kq = MessageBox.Show("Bạn có chắc chắn không?", "Xác nhận", MessageBoxButton.YesNo);
         if (kq == MessageBoxResult.Yes)
         {
             PhongDAO.Insert(p);
             MessageBox.Show("Thêm thành công", "Thành công");
             EmptyText();
             UnenableText();
             btn_Them.IsEnabled         = true;
             btn_ThemConfirm.Visibility = Visibility.Hidden;
             btn_Huy.Visibility         = Visibility.Hidden;
             grid_phong.ItemsSource     = PhongDAO.LoadAll().DefaultView;
         }
         else
         {
             EmptyText();
             UnenableText();
             btn_Them.IsEnabled         = true;
             btn_ThemConfirm.Visibility = Visibility.Hidden;
             return;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }