示例#1
0
        public static int ThemPhongBan(PhongBan phongBan)
        {
            using (var context = new VeTauEntities(false))
            {
                context.PhongBans.Add(phongBan);
                return context.SaveChanges();

            }
        }
示例#2
0
 public static int CapNhatPhongBan(PhongBan phongBan)
 {
     using (var context = new VeTauEntities(false))
     {
         var doiTuong = context.PhongBans.SingleOrDefault(pb => pb.Id == phongBan.Id);
         if (doiTuong != null)
         {
             doiTuong.TenPhongBan = phongBan.TenPhongBan;
             doiTuong.RuleBaoCao = phongBan.RuleBaoCao;
             doiTuong.RuleChuyenTau = phongBan.RuleChuyenTau;
             doiTuong.RuleLichTrinh = phongBan.RuleLichTrinh;
             doiTuong.RuleNhanSu = phongBan.RuleNhanSu;
             doiTuong.RuletBanVe = phongBan.RuletBanVe;
             doiTuong.RuleQuanTri = phongBan.RuleQuanTri;
         }
         return context.SaveChanges();
     }
 }
示例#3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (KiemTraHopLeVaThongBao())
            {
                var phongBan = new PhongBan
                {
                    Id = tbMaPhongBan.Text.ToUpper(),
                    TenPhongBan = tbTenPhongBan.Text
                };
               
                if (PhongBanDal.ThemPhongBan(phongBan)>0)
                {
                    MessageBox.Show(Resources.TaoDoiTuong +Resources.thanhCong, Resources.MThanhCong);
                    CapNhatGvPhongBan();
                }
                else
                {
                    MessageBox.Show(Resources.TaoDoiTuong +Resources.thatBai, Resources.MThatBai);
                }

            }
        }