Exemple #1
0
 public FormLaborContractDetail(string _maHopDong)
 {
     InitializeComponent();
     using (var uow = new UnitOfWork())
     {
         LaborContract lb = uow.FindObject <LaborContract>(CriteriaOperator.Parse("MaHopDong = ?", _maHopDong));
         if (lb != null)
         {
             txtMaHopDong.Enabled   = false;
             txtMaHopDong.Text      = lb.MaHopDong;
             cbbLoaiHopDong.Text    = lb.LoaiHopDong;
             lkMaNhanVien.EditValue = lb.iNhanVien.MaNhanVien;
             dtNgayKy.Text          = lb.NgayKy.ToShortDateString();
             dtNgayHetHan.EditValue = lb.NgayHetHan.ToShortDateString();
             lkChucVu.EditValue     = LayChucVuCuaNhanVien(lb.iNhanVien.MaNhanVien);
             calLuongCoBan.Text     = (LayLuongCoBanCuaNhanVien(lb.iNhanVien.MaNhanVien)).ToString();
         }
     }
 }
 private void lkuSoHopDong_EditValueChanged(object sender, EventArgs e)
 {
     using (var uow = new UnitOfWork())
     {
         if (lkuSoHopDong.EditValue != null)
         {
             try
             {
                 LaborContract l = uow.FindObject <LaborContract>(CriteriaOperator.Parse("MaHopDong = ?", lkuSoHopDong.Text));
                 if (l != null)
                 {
                     dtNgayVaoHopDong.EditValue = l.NgayKy;
                 }
             }
             catch
             { }
         }
     }
 }
        protected override void OnDelete()
        {
            if (XtraMessageBox.Show("Bạn có muốn xóa không?", "THÔNG BÁO!", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            for (int i = 0; i < grvUCList.SelectedRowsCount; i++)
            {
                _maHopDong = grvUCList.GetRowCellValue(grvUCList.GetSelectedRows()[i], colMaHopDong).ToString();
                using (var uow = new UnitOfWork())
                {
                    LaborContract br = uow.FindObject <LaborContract>(CriteriaOperator.Parse("MaHopDong = ?", _maHopDong));
                    if (br != null)
                    {
                        br.Delete();
                        uow.CommitChanges();
                        uow.PurgeDeletedObjects();
                    }
                }
            }
            RefreshData();
        }
Exemple #4
0
 public FormLaborContractDetail(LaborContract lb)
 {
     InitializeComponent();
 }
Exemple #5
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            bool flag = true;

            #region "Lưu Thông Tin Hợp Đồng"

            using (var uow = new UnitOfWork())
            {
                LaborContract lb = uow.FindObject <LaborContract>(CriteriaOperator.Parse("MaHopDong = ?", txtMaHopDong.Text));
                if (txtMaHopDong.Enabled == true && lb != null)
                {
                    XtraMessageBox.Show("Mã hợp đồng đã tồn tại. Vui lòng nhập mã khác.", "THÔNG BÁO");
                    return;
                }
                if (lb == null)
                {
                    lb           = new LaborContract(uow);
                    flag         = false;
                    lb.MaHopDong = txtMaHopDong.Text;
                }
                lb.LoaiHopDong = cbbLoaiHopDong.Text;
                lb.iNhanVien   = uow.FindObject <Employee>(CriteriaOperator.Parse("MaNhanVien = ?", lkMaNhanVien.EditValue));
                lb.NgayKy      = DateTime.Parse(dtNgayKy.Text);
                lb.NgayHetHan  = DateTime.Parse(dtNgayHetHan.Text);
                lb.ChucVu      = uow.FindObject <Competence>(CriteriaOperator.Parse("CompetenceID = ?", lkChucVu.EditValue));
                lb.LuongCoBan  = decimal.Parse(calLuongCoBan.Text);
                try
                {
                    if (LaHopLe() == true)
                    {
                        lb.Save();
                        uow.CommitChanges();
                        FormLaborContractList f = this.Tag as FormLaborContractList;
                        f.RefreshData();
                        if (flag == false)
                        {
                            XtraMessageBox.Show("Thêm thành công", "Đã lưu");
                        }
                        else
                        {
                            XtraMessageBox.Show("Cập nhật thành công", "Đã lưu");
                        }
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "Có lỗi!");
                }
            }
            #endregion

            #region "Cập Nhật Thông Tin Nhân Viên"
            using (var uow = new UnitOfWork())
            {
                Employee update = uow.FindObject <Employee>(CriteriaOperator.Parse("MaNhanVien = ?", lkMaNhanVien.EditValue));
                if (update != null)
                {
                    update.ChucVu           = uow.FindObject <Competence>(CriteriaOperator.Parse("CompetenceID = ?", lkChucVu.EditValue));
                    update.HopDong          = uow.FindObject <LaborContract>(CriteriaOperator.Parse("MaHopDong = ?", txtMaHopDong.Text));
                    update.LuongCoBan       = decimal.Parse(calLuongCoBan.Text);
                    update.TinhTrangHopDong = cbbLoaiHopDong.Text;
                    try
                    {
                        if (LaHopLe() == true)
                        {
                            update.Save();
                            uow.CommitChanges();
                        }
                    }

                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "Có lỗi!");
                    }
                }
            }
            #endregion
        }
 public FormLaborContractList()
 {
     InitializeComponent();
     lb = new LaborContract();
 }