Ejemplo n.º 1
0
 protected void Button17_Click(object sender, DirectEventArgs e)
 {
     try
     {
         DaoTaoController      daotao   = new DaoTaoController();
         DAL.DM_GiaoVienDaoTao giaovien = new DAL.DM_GiaoVienDaoTao();
         giaovien.ChucVu             = txt_chucvu.Text;
         giaovien.CreatedBy          = CurrentUser.ID;
         giaovien.CreatedDate        = DateTime.Now;
         giaovien.DiaChiLienHe       = txt_diachi.Text;
         giaovien.DiDong             = txt_didong.Text;
         giaovien.DiDong             = txt_didong.Text;
         giaovien.DonViCongTac       = txt_donvicongtac.Text;
         giaovien.DTCoQuan           = txt_dtcq.Text;
         giaovien.Email              = txt_email.Text;
         giaovien.GioiTinh           = bool.Parse(cbx_gioitinh.SelectedItem.Value);
         giaovien.HocVan             = txt_hocvan.Text;
         giaovien.HoTenGV            = gv_txtHoten.Text;
         giaovien.KinhNghiemGiangDay = txt_kinhnghiem.Text;
         giaovien.LaNhanvienCty      = chk_nvcongty.Checked;
         giaovien.MaGV     = gv_txtMaGiaoVien.Text;
         giaovien.MA_DONVI = new UserController().GetDonViByUserID(CurrentUser.ID).FirstOrDefault().MA_DONVI;
         if (df_ngaysinh.SelectedDate.ToString().Contains("01/01/0001") == false)
         {
             giaovien.NgaySinh = df_ngaysinh.SelectedDate;
         }
         if (e.ExtraParams["Command"] == "Edit")
         {
             daotao.UpdateGiaoVien(giaovien);
             RM.RegisterClientScriptBlock("zz", "#{grp_GiaoVienDaoTaoStore}.reload();");
             wdGiaoVien.Hide();
         }
         else
         {
             daotao.InsertGiaoVien(giaovien);
             daotao.ThemGiaoVienVaoKhoaHoc(new DAL.GiaoVien_KhoaDaoTao()
             {
                 CreatedBy   = CurrentUser.ID,
                 CreatedDate = DateTime.Now,
                 MaGiaoVien  = giaovien.MaGV,
                 MaKhoaHoc   = hdfRecordID.Text
             });
             RM.RegisterClientScriptBlock("zz", "#{grp_GiaoVienDaoTaoStore}.reload();");
             if (e.ExtraParams["Close"] == "True")
             {
                 wdGiaoVien.Hide();
             }
         }
     }
     catch (Exception ex)
     {
         Dialog.ShowError("Lối xảy ra " + ex.Message);
     }
 }
Ejemplo n.º 2
0
    protected void btnSave_Click(object sender, DirectEventArgs e)
    {
        try
        {
            DaoTaoController      daotao   = new DaoTaoController();
            DAL.DM_GiaoVienDaoTao giaovien = new DAL.DM_GiaoVienDaoTao();

            giaovien.ChucVu       = txt_chucvu.Text;
            giaovien.CreatedBy    = CurrentUser.ID;
            giaovien.CreatedDate  = DateTime.Now;
            giaovien.DiaChiLienHe = txt_diachi.Text;
            giaovien.DiDong       = txt_didong.Text;
            giaovien.DonViCongTac = txt_donvicongtac.Text;
            giaovien.DTCoQuan     = txt_dtcq.Text;
            giaovien.Email        = txt_email.Text;
            giaovien.GioiTinh     = bool.Parse(cbx_gioitinh.SelectedItem.Value);
            //giaovien.HocVan = txt_hocvan.Text;
            //if (cbx_trinhdo.Value != null)
            //    giaovien.HocVan = cbx_trinhdo.Value.ToString();
            giaovien.HocVan             = hdftrinhdo.Text;
            giaovien.HoTenGV            = gv_txtHoten.Text;
            giaovien.KinhNghiemGiangDay = txt_kinhnghiem.Text;
            giaovien.LaNhanvienCty      = chk_nvcongty.Checked;
            giaovien.MaGV = gv_txtMaGiaoVien.Text;
            if (!df_ngaysinh.SelectedDate.ToString().Contains("0001"))
            {
                giaovien.NgaySinh = df_ngaysinh.SelectedDate;
            }
            giaovien.MA_DONVI = Session["MaDonVi"].ToString();

            if (e.ExtraParams["Command"] == "Edit")
            {
                daotao.UpdateGiaoVien(giaovien);
                grpTeacherList.GetGridPanel().Reload();
                wdGiaoVien.Hide();
                Dialog.ShowNotification("Cập nhật thành công");
            }
            else
            {
                daotao.InsertGiaoVien(giaovien);
                grpTeacherList.GetGridPanel().Reload();
                if (e.ExtraParams["Close"] == "True")
                {
                    wdGiaoVien.Hide();
                }
                else
                {
                    grpTeacherList.GetResourceManager().RegisterClientScriptBlock("rsf", "ResetValue()");
                }
                Dialog.ShowNotification("Cập nhật thành công");
            }
            grpTeacherList.GetGridPanel().Reload();
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("Violation of PRIMARY KEY constraint"))
            {
                Dialog.ShowError("Mã giáo viên không được trùng !");
            }
            else
            {
                Dialog.ShowError(ex.Message);
            }
        }
    }