Exemple #1
0
 /// <summary>
 /// 导入Excel的员工社保卡信息
 /// </summary>
 /// <param name="strPath">当前上传的Excel文件路径</param>
 /// <param name="strMsg">处理消息</param>
 //public void ImportPensionByImportExcel(string strPath, string employeeID, ref string strMsg)
 //{
 //    ImportSetMasterBLL bll = new ImportSetMasterBLL();
 //    T_HR_IMPORTSETMASTER master = bll.GetImportSetMasterByEntityCode("T_HR_PENSIONDETAIL", employeeID);
 //    ImportExcel penBll = new ImportExcel(strPath, 0, master, new T_HR_PENSIONDETAIL());
 //    penBll.StartImport();
 //}
 public void ImportPensionByImportExcel(string strPath, Dictionary <string, string> paras, ref string strMsg)
 {
     try
     {
         ImportSetMasterBLL   bll    = new ImportSetMasterBLL();
         T_HR_IMPORTSETMASTER master = bll.GetImportSetMasterByEntityCode("T_HR_PENSIONDETAIL", paras["CITY"], paras["OWNERCOMPANYID"]);
         if (master != null)
         {
             T_HR_PENSIONDETAIL dt     = new T_HR_PENSIONDETAIL();
             ImportExcel        penBll = new ImportExcel(strPath, 0, master, new T_HR_PENSIONDETAIL(), paras);
             bool sucess = penBll.StartImport();
             if (sucess)
             {
                 strMsg = "true";
             }
             else
             {
                 strMsg = "false";
             }
         }
         else
         {
             strMsg = "NOTFOUND";
         }
     }
     catch (Exception ex)
     {
         SMT.Foundation.Log.Tracer.Debug(System.DateTime.Now.ToString() + " ImportPensionByImportExcel:" + ex.Message);
     }
 }
Exemple #2
0
        /// <summary>
        /// 导入员工社保记录并返回显示
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="paras">参数字典</param>
        /// <param name="strMsg">返回的参数</param>
        public List <T_HR_PENSIONDETAIL> ImportPensionByImportExcelForShow(string strPath, Dictionary <string, string> paras, ref string strMsg)
        {
            List <T_HR_PENSIONDETAIL> ListResult = new List <T_HR_PENSIONDETAIL>();

            try
            {
                ImportSetMasterBLL   bll    = new ImportSetMasterBLL();
                T_HR_IMPORTSETMASTER master = bll.GetImportSetMasterByEntityCode("T_HR_PENSIONDETAIL", paras["CITY"], paras["OWNERCOMPANYID"]);
                if (master != null)
                {
                    T_HR_PENSIONDETAIL dt     = new T_HR_PENSIONDETAIL();
                    ImportExcel        penBll = new ImportExcel(strPath, 0, master, new T_HR_PENSIONDETAIL(), paras);
                    ListResult = penBll.ReadExcelDataFirst();
                }
            }
            catch (Exception ex)
            {
                SMT.Foundation.Log.Tracer.Debug(System.DateTime.Now.ToString() + " ImportPensionByImportExcel:" + ex.Message);
            }
            return(ListResult);
        }
Exemple #3
0
        /// <summary>
        /// 批量添加员工社保
        /// </summary>
        /// <param name="listPension">社保集合</param>
        /// <param name="StrCity">城市</param>
        /// <param name="StrCompanyid">公司ID</param>
        /// <param name="StrYear">年</param>
        /// <param name="StrMonth">月</param>
        /// <param name="StrCreateUserId">创建用户</param>
        /// <param name="StrMsg">返回的消息,用来存放不合格记录的身份证号</param>
        /// <returns></returns>
        public bool BatchAddPensionDetail(List <T_HR_PENSIONDETAIL> listPension, Dictionary <string, string> paras, ref string StrMsg)
        {
            bool IsResult = false;

            SMT.Foundation.Log.Tracer.Debug("开始导入员工社保。");
            try
            {
                dal.BeginTransaction();
                ImportSetMasterBLL   bll    = new ImportSetMasterBLL();
                T_HR_IMPORTSETMASTER master = bll.GetImportSetMasterByEntityCode("T_HR_PENSIONDETAIL", paras["CITY"], paras["OWNERCOMPANYID"]);
                if (master != null)
                {
                    //用来记录身份证信息不存在的数量
                    int i = 0;
                    foreach (var ent in listPension)
                    {
                        var employee = from e in dal.GetObjects <T_HR_EMPLOYEE>()
                                       where e.IDNUMBER == ent.IDNUMBER && e.EDITSTATE == "1"
                                       select e;
                        if (employee.Count() > 0)
                        {
                            //删除旧的记录
                            var oldDetail = from c in dal.GetObjects <T_HR_PENSIONDETAIL>()
                                            where c.PENSIONMOTH == ent.PENSIONMOTH && c.PENSIONYEAR == ent.PENSIONYEAR && c.IDNUMBER == ent.IDNUMBER
                                            select c;
                            if (oldDetail.Count() > 0)
                            {
                                dal.DeleteFromContext(oldDetail.FirstOrDefault());
                            }

                            T_HR_EMPLOYEE entCurEmp = employee.FirstOrDefault();
                            if (ent.EMPLOYEEID != entCurEmp.EMPLOYEEID)
                            {
                                ent.EMPLOYEEID = entCurEmp.EMPLOYEEID;
                            }
                            //插入数据到数据库
                            dal.AddToContext(ent);
                        }
                        else
                        {
                            i++;
                            SMT.Foundation.Log.Tracer.Debug("PensionImport:" + i.ToString() + "行,没有员工身份证为此号码:" + ent.IDNUMBER);
                            StrMsg += "身份证号为:" + ent.IDNUMBER + "没有找到员工记录\n";
                        }
                    }
                    if (i > 0)
                    {
                        StrMsg += "共有" + i.ToString() + " 位员工社保导入错误。";
                    }

                    int k = dal.SaveContextChanges();
                    if (k > 0)
                    {
                        dal.CommitTransaction();
                        IsResult = true;
                        CommDal <T_HR_PENSIONDETAIL> cdal = new CommDal <T_HR_PENSIONDETAIL>();

                        string strSql = " update t_hr_pensiondetail a    set  a.pensionmasterid = (select pensionmasterid from t_hr_pensionmaster b,t_hr_employee c where a.IDNUMBER= c.IDNUMBER and b.employeeid=c.employeeid and b.editstate=1)"
                                        + "  ,a.employeeid= (select employeeid from t_hr_employee c where a.IDNUMBER = c.IDNUMBER  )"
                                        + "  ,a.CARDID= (select CARDID from t_hr_pensionmaster b ,t_hr_employee c where a.IDNUMBER = c.IDNUMBER and b.employeeid=c.employeeid and b.editstate=1)"
                                        + "  ,a.OWNERID=(select employeeid from t_hr_employee c where a.IDNUMBER = c.IDNUMBER )"
                                        + "  ,a.OWNERPOSTID=(select c.OWNERPOSTID from t_hr_employee c where a.IDNUMBER= c.IDNUMBER ) "
                                        + "  ,a.OWNERDEPARTMENTID=(select c.OWNERDEPARTMENTID from t_hr_employee c where a.IDNUMBER= c.IDNUMBER )"
                                        + " ,a.OWNERCOMPANYID=(select c.OWNERCOMPANYID from t_hr_employee c where a.IDNUMBER = c.IDNUMBER  )"
                                        + " where a.PENSIONYEAR='" + paras["YEAR"] + "' and a.PENSIONMOTH='" + paras["MONTH"] + "' and a.CREATEUSERID='" + paras["CREATEUSERID"] + "'";
                        //修改社保的所属人信息
                        cdal.ExecuteCustomerSql(strSql);
                    }
                    else
                    {
                        dal.RollbackTransaction();
                    }
                }
                else
                {
                    StrMsg = "社保主表记录不存在。";
                }
            }
            catch (Exception ex)
            {
                SMT.Foundation.Log.Tracer.Debug(System.DateTime.Now.ToString() + " ImportPensionByImportExcel:" + ex.Message);
                dal.RollbackTransaction();
            }
            return(IsResult);
        }