Exemplo n.º 1
0
        public static DTO_PRO_SYLL update_PRO_SYLL(AppEntities db, DTO_PRO_SYLL item, string Username)
        {
            var dbitem = db.tbl_PRO_SYLL.Find(item.ID);

            if (dbitem == null)
            {
                dbitem             = new tbl_PRO_SYLL();
                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;
                dbitem.IDDetai     = item.IDDetai;
                dbitem.IDNhanSu    = item.IDNhanSu;
                db.tbl_PRO_SYLL.Add(dbitem);
            }

            var objHRM_SYLL = db.tbl_CUS_HRM_STAFF_NhanSu_SYLL.FirstOrDefault(c => c.IDNhanSu == item.IDNhanSu);

            if (objHRM_SYLL != null)
            {
                int        id         = dbitem.ID;
                CopyHelper copyHelper = new CopyHelper();
                copyHelper.Copy(objHRM_SYLL, dbitem);
                dbitem.ID = id;
            }
            dbitem.IDDetai    = item.IDDetai;
            dbitem.IDNhanSu   = item.IDNhanSu;
            dbitem.IsDisabled = item.IsDisabled;
            dbitem.IsDeleted  = item.IsDeleted;

            dbitem.ModifiedBy   = Username;
            dbitem.ModifiedDate = DateTime.Now;

            try
            {
                db.SaveChanges();

                var detai = db.tbl_PRO_DeTai.FirstOrDefault(c => c.ID == dbitem.IDDetai);
                if (detai != null)
                {
                    if (detai.IDNCV == dbitem.IDNhanSu)
                    {
                        BS_HelperReference.PRO_SYLL_NCV_Update(db, dbitem.IDDetai, dbitem.IDNhanSu);
                    }
                }

                BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_SYLL", DateTime.Now, Username);
                item.ID          = dbitem.ID;
                item.CreatedBy   = dbitem.CreatedBy;
                item.CreatedDate = dbitem.CreatedDate;

                item.ModifiedBy   = dbitem.ModifiedBy;
                item.ModifiedDate = dbitem.ModifiedDate;
                return(item);
            }
            catch (DbEntityValidationException e)
            {
                errorLog.logMessage("save_PRO_SYLL", e);
                return(null);
            }
        }
Exemplo n.º 2
0
        public static DTO_PRO_SYLL save_PRO_SYLL(AppEntities db, DTO_PRO_SYLL item, string Username)
        {
            var dbitem = db.tbl_PRO_SYLL.Find(item.ID);

            if (dbitem == null)
            {
                dbitem             = new tbl_PRO_SYLL();
                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;
                db.tbl_PRO_SYLL.Add(dbitem);
            }

            dbitem.IDDetai            = item.IDDetai;
            dbitem.IDNhanSu           = item.IDNhanSu;
            dbitem.HoTen              = item.HoTen;
            dbitem.GioiTinh           = item.GioiTinh;
            dbitem.NgaySinh           = item.NgaySinh;
            dbitem.DiaChi             = item.DiaChi;
            dbitem.DienThoaiCQ        = item.DienThoaiCQ;
            dbitem.DienThoaiNhaRieng  = item.DienThoaiNhaRieng;
            dbitem.Mobile             = item.Mobile;
            dbitem.Email              = item.Email;
            dbitem.ChucVu             = item.ChucVu;
            dbitem.CoQuanLamViec      = item.CoQuanLamViec;
            dbitem.ThuTruongCoQuan    = item.ThuTruongCoQuan;
            dbitem.DienThoaiThuTruong = item.DienThoaiThuTruong;
            dbitem.DiaChiCoQuan       = item.DiaChiCoQuan;
            dbitem.NgayKy_ChuKy       = item.NgayKy_ChuKy;
            dbitem.NgayKy_Nam         = item.NgayKy_Nam;
            dbitem.NgayKy_Ngay        = item.NgayKy_Ngay;
            dbitem.NgayKy_Thang       = item.NgayKy_Thang;

            if (item.ListKinhNghiem != null)
            {
                dbitem.JSON_KinhNghiem = JsonConvert.SerializeObject(item.ListKinhNghiem);
            }
            else
            {
                dbitem.JSON_KinhNghiem = string.Empty;
            }

            if (item.ListTrinhDoChuyenMon != null)
            {
                dbitem.JSON_TrinhDoChuyenMon = JsonConvert.SerializeObject(item.ListTrinhDoChuyenMon);
            }
            else
            {
                dbitem.JSON_TrinhDoChuyenMon = string.Empty;
            }

            dbitem.FormConfig = item.FormConfig;
            dbitem.HTML       = item.HTML;
            dbitem.IsDisabled = item.IsDisabled;
            dbitem.IsDeleted  = item.IsDeleted;

            dbitem.ModifiedBy   = Username;
            dbitem.ModifiedDate = DateTime.Now;

            try
            {
                db.SaveChanges();

                BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_SYLL", DateTime.Now, Username);

                var detai = db.tbl_PRO_DeTai.FirstOrDefault(c => c.ID == dbitem.IDDetai);
                if (detai != null)
                {
                    if (detai.IDNCV == dbitem.IDNhanSu)
                    {
                        BS_HelperReference.PRO_SYLL_NCV_Update(db, dbitem.IDDetai, dbitem.IDNhanSu);
                    }
                }

                item.ID          = dbitem.ID;
                item.CreatedBy   = dbitem.CreatedBy;
                item.CreatedDate = dbitem.CreatedDate;

                item.ModifiedBy   = dbitem.ModifiedBy;
                item.ModifiedDate = dbitem.ModifiedDate;
                return(item);
            }
            catch (DbEntityValidationException e)
            {
                errorLog.logMessage("save_PRO_SYLL", e);
                return(null);
            }
        }