Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.Page.RouteData.Values["chucvu"] != null)
     {
         try
         {
             int chucvuID = Convert.ToInt32(this.Page.RouteData.Values["chucvu"]);
             Models.ChucVuEntity chucvuEntity = new Models.ChucVuEntity();
             Models.ChucVu       chucvu       = chucvuEntity.Find(chucvuID);
             if (chucvu == null)
             {
                 Response.Redirect("~/ChucVu");
             }
         }
         catch (Exception)
         {
             Response.Redirect("~/ChucVu");
         }
     }
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                Models.DonViEntity dvEntity = new Models.DonViEntity();
                dvEntity.Load_DataSource_RadDropDownTree(ddtDonVi);

                Models.ChucVuEntity cvEntity = new Models.ChucVuEntity();
                cvEntity.Load_AllChucVu_RadComboBox(cbbChucVu);

                Models.HeSoLuongEntity hslEntity = new Models.HeSoLuongEntity();
                hslEntity.Load_DataSource_ComboBox(cbbHeSoLuong);

                dpkTuNgay.SelectedDate = DateTime.Now;
            }

            if (this.Page.RouteData.Values["lamviec"] != null)
            {
                this.UpdateStatus();
                _lamviecID = Convert.ToInt32(this.Page.RouteData.Values["lamviec"]);
                Models.LamViec lamviec = _lvEntity.Find(_lamviecID);
                _nhanvienID = lamviec.NVID;
                if (!this.Page.IsPostBack)
                {
                    ddtDonVi.SelectedValue  = lamviec.DVID.ToString();
                    cbbChucVu.SelectedValue = lamviec.CVID.ToString();
                    dpkTuNgay.SelectedDate  = lamviec.LVTuNgay;
                    if (lamviec.LVDenNgay != null && lamviec.LVDenNgay != DateTime.MinValue)
                    {
                        dpkDenNgay.SelectedDate = lamviec.LVDenNgay;
                    }
                    cbbHeSoLuong.SelectedValue = lamviec.HSLID.ToString();
                    if (lamviec.LVLuongCoBan % 1 == 0)
                    {
                        txtLuongCoBan.Text = lamviec.LVLuongCoBan.ToString("###");
                    }
                    else
                    {
                        txtLuongCoBan.Text = lamviec.LVLuongCoBan.ToString();
                    }
                    txtNgheNghiep.Text      = lamviec.LVNhiemVu;
                    txtPhuCapChucVu.Text    = lamviec.LVPhuCapChucVu.ToString();
                    txtPhuCapCongVu.Text    = lamviec.LVPhuCapCongVu.ToString();
                    txtPhuCapKiemNhiem.Text = lamviec.LVPhuCapKiemNhiem.ToString();
                    txtPhuCapNghe.Text      = lamviec.LVPhuCapNghe.ToString();
                    txtPhuCapThamNien.Text  = lamviec.LVPhuCapThamNienNghe.ToString();
                    txtPhuCapVuotKhung.Text = lamviec.LVPhuCapVuotKhung.ToString();
                    txtPhuCapDocHai.Text    = lamviec.LVPhuCapVuotKhung.ToString();
                    txtTyLe.Text            = lamviec.LVTyLe.ToString();
                    txtSoNgayPhep.Text      = lamviec.LVSoNgayPhep.ToString();
                    txtSoHopDong.Text       = lamviec.LVSoHopDong;
                    if (lamviec.LVNgayHopDong != null && lamviec.LVNgayHopDong != DateTime.MinValue)
                    {
                        dpkNgayHopDong.SelectedDate = Convert.ToDateTime(lamviec.LVNgayHopDong);
                    }
                }
            }
            else
            {
                this.CreateStatus();
                _nhanvienID = Convert.ToInt32(this.Page.RouteData.Values["nhanvien"]);
                Models.NhanVienEntity nvEntity = new Models.NhanVienEntity();
                Models.NhanVien       nhanvien = nvEntity.Find_NhanVien(_nhanvienID);
                Models.LamViec        lamviec  = nhanvien.LamViecs.OrderByDescending(x => x.LVID).FirstOrDefault();
                if (lamviec != null && !this.Page.IsPostBack)
                {
                    ddtDonVi.SelectedValue  = lamviec.DVID.ToString();
                    cbbChucVu.SelectedValue = lamviec.CVID.ToString();
                    dpkTuNgay.SelectedDate  = lamviec.LVTuNgay;
                    if (lamviec.LVDenNgay != null && lamviec.LVDenNgay != DateTime.MinValue)
                    {
                        dpkDenNgay.SelectedDate = lamviec.LVDenNgay;
                    }
                    cbbHeSoLuong.SelectedValue = lamviec.HSLID.ToString();
                    if (lamviec.LVLuongCoBan % 1 == 0)
                    {
                        txtLuongCoBan.Text = lamviec.LVLuongCoBan.ToString("###");
                    }
                    else
                    {
                        txtLuongCoBan.Text = lamviec.LVLuongCoBan.ToString();
                    }
                    txtNgheNghiep.Text      = lamviec.LVNhiemVu;
                    txtPhuCapChucVu.Text    = lamviec.LVPhuCapChucVu.ToString();
                    txtPhuCapCongVu.Text    = lamviec.LVPhuCapCongVu.ToString();
                    txtPhuCapKiemNhiem.Text = lamviec.LVPhuCapKiemNhiem.ToString();
                    txtPhuCapNghe.Text      = lamviec.LVPhuCapNghe.ToString();
                    txtPhuCapThamNien.Text  = lamviec.LVPhuCapThamNienNghe.ToString();
                    txtPhuCapVuotKhung.Text = lamviec.LVPhuCapVuotKhung.ToString();
                    txtPhuCapDocHai.Text    = lamviec.LVPhuCapVuotKhung.ToString();
                    txtTyLe.Text            = lamviec.LVTyLe.ToString();
                    txtSoNgayPhep.Text      = lamviec.LVSoNgayPhep.ToString();
                }
            }
        }