Exemplo n.º 1
0
 public int auditVoucher(string ccode, TransferRegister tr, ref string errMsg)
 {
     try
     {
         int    i    = 0;
         string sql1 = "update HR_HI_TransferRegister set cstate='2',dAuditOn=convert(nvarchar(19),GETDATE(),120),cAuditBy='" + tr.cAuditBy + "' where cVoucherId ='" + ccode + "'";
         int    a    = db.ExecuteSql(sql1);
         string sql2 = "update UPDATE hr_hi_person SET cDept_num = '" + tr.rLaterDepCode + "' where cPsn_Num='" + tr.cPsn_Num + "'";
         int    b    = db.ExecuteSql(sql2);
         string sql3 = " INSERT  INTO hr_hi_jobInfo( PK_hr_hi_jobInfo, cjobcode ,cDepCode ,cDeptName ,cJobName ,cJobRankCode ,cJobGradeCode ,cDutycode , cDutyName ,\n" +
                       " cSupPerson ,dbegindate ,denddate ,rDChgType ,rDutyLev ,rholdpostWay ,rhpreason ,vhpAuthUnit ,vAuthorizeDoc ,\n" +
                       " dremovDate ,rremovMode ,rremovReason ,vrmAuthUnit ,vrmAuthDoc ,vstatus1 ,nstatus2 ,bMaxJobRankCode ,iRecordID ,\n" +
                       " blastflag ,cPsn_Num , bPartJob,cVoucherId )\n" +
                       " SELECT TOP 1 NEWID(), ISNULL(hr_hi_jobInfo.cjobcode, '') ,ISNULL(hr_hi_person.cDept_num, '') ,ISNULL(hr_hi_jobInfo.cDeptName, '') ,ISNULL(hr_hi_jobInfo.cJobName, '') ,ISNULL(hr_hi_jobInfo.cJobRankCode, '') ,\n" +
                       " ISNULL(hr_hi_jobInfo.cJobGradeCode, '') ,ISNULL(hr_hi_jobInfo.cDutycode, '') ,ISNULL(hr_hi_jobInfo.cDutyName, '') ,ISNULL(hr_hi_jobInfo.cSupPerson, '') ,\n" +
                       " ISNULL(hr_hi_jobInfo.dbegindate, '') ,ISNULL(hr_hi_jobInfo.denddate, '') ,ISNULL(hr_hi_jobInfo.rDChgType, '') ,ISNULL(hr_hi_jobInfo.rDutyLev, '') ,\n" +
                       " ISNULL(hr_hi_jobInfo.rholdpostWay, '') ,ISNULL(hr_hi_jobInfo.rhpreason, '') ,ISNULL(hr_hi_jobInfo.vhpAuthUnit, '') ,ISNULL(hr_hi_jobInfo.vAuthorizeDoc, '') ,\n" +
                       " ISNULL(hr_hi_jobInfo.dremovDate, '') ,ISNULL(hr_hi_jobInfo.rremovMode, '') ,ISNULL(hr_hi_jobInfo.rremovReason, '') ,ISNULL(hr_hi_jobInfo.vrmAuthUnit, '') ,\n" +
                       " ISNULL(hr_hi_jobInfo.vrmAuthDoc, '') ,ISNULL(hr_hi_jobInfo.vstatus1, '') ,ISNULL(hr_hi_jobInfo.nstatus2, 0) ,ISNULL(hr_hi_jobInfo.bMaxJobRankCode, '') ,\n" +
                       " ( SELECT    ISNULL(MAX(iRecordID), 0) + 1 FROM  hr_hi_jobInfo WHERE cPsn_Num='" + tr.cPsn_Num + "') ,\n" +
                       "  1 , hr_hi_person.cPsn_Num , 0 , '" + ccode + "'\n" +
                       " FROM    hr_hi_person\n" +
                       " LEFT OUTER JOIN hr_hi_jobInfo ON hr_hi_jobInfo.cPsn_Num = hr_hi_person.cPsn_Num\n" +
                       " AND hr_hi_jobInfo.blastflag = 1\n" +
                       " AND hr_hi_jobInfo.bPartJob = 0\n" +
                       " WHERE   hr_hi_person.cPsn_Num = '" + tr.cPsn_Num + "' ;";
         int    c    = db.ExecuteSql(sql3);
         string sql4 = "update hr_hi_jobinfo set denddate = '" + tr.dTransferDate + "' , cVoucherId = '" + ccode + "',blastflag = 0 WHERE   cPsn_Num = '" + tr.cPsn_Num + "' AND blastflag = 1 AND bPartJob = 0\n" +
                       "   AND ISNULL(iRecordID, 0) <> ( SELECT  ISNULL(MAX(iRecordID), 0)\n" +
                       "   FROM  hr_hi_jobInfo  where  cPsn_Num = '" + tr.cPsn_Num + "' ) ; ";
         int    d    = db.ExecuteSql(sql4);
         string sql5 = "UPDATE hr_hi_jobinfo SET cDepCode='" + tr.rLaterDepCode + "',beginDate='" + tr.dTransferDate + "',depName=(SELECT cdepname from Department where cdepcode='" + tr.rLaterDepCode + "') where cPsn_Num = '" + tr.cPsn_Num + "' AND blastflag = 1 AND bPartJob = 0 ";
         int    e    = db.ExecuteSql(sql5);
         string sql6 = "update HR_TM_PersonDutyClass set dLeaveDutyClassDate = '" + tr.dTransferDate + "' ,blastflag = 0  where PK_hr_tm_personDutyClass = (select top 1  PK_hr_tm_personDutyClass from HR_TM_PersonDutyClass where cpsn_num='" + tr.cPsn_Num + "' and blastflag = 1 order by dEnterDutyClassDate desc)";
         int    f    = db.ExecuteSql(sql6);
         string sql7 = "UPDATE hr_tm_DayResult SET cDepCode = '" + tr.rLaterDepCode + "',cDepCode_Num = '" + tr.rLaterDepCode + "' WHERE cPsn_Num = '" + tr.cPsn_Num + "' AND dDutyDate >= '" + tr.dTransferDate + "'";
         int    g    = db.ExecuteSql(sql7);
         string sql8 = "UPDATE hr_tm_MonthResult SET vdepcode_num = '" + tr.rLaterDepCode + "',vDepCode = '" + tr.rLaterDepCode + "' WHERE cPsn_Num = '" + tr.cPsn_Num + "' AND ((cYear = " + Convert.ToDateTime(tr.dTransferDate).Year + " AND cMonth >= " + Convert.ToDateTime(tr.dTransferDate).Month + ") OR (cYear > " + Convert.ToDateTime(tr.dTransferDate).Year + "))";
         int    h    = db.ExecuteSql(sql8);
         string sql9 = "UPDATE  UA_User   SET  cDept = (SELECT cdepname from Department where cdepcode='" + tr.rLaterDepCode + "')    WHERE   cUser_id IN  (SELECT cUser_Id FROM UserHrPersonContro WHERE UserHrPersonContro.cPsn_Num='" + tr.cPsn_Num + "')";
         int    k    = db.ExecuteSql(sql9);
         i = a + b + c + d + e + f + g + h + k;
         return(i);
     }
     catch (Exception ex)
     {
         errMsg = ex.Message.ToString();
         throw;
     }
 }
Exemplo n.º 2
0
        public int AddTransfer(TransferRegister transfer, ref string errMsg)
        {
            ccode = voucherService.GetNewCode("HM701", "DD");
            transfer.cVoucherId = ccode;
            transfer.bAuditFlag = 0;
            transfer.cstate     = "0";
            transfer.PK_HR_HI_TransferRegister = Guid.NewGuid().ToString();
            transfer.csysbarcode = "||HM701|" + ccode;
            transfer.dCreateOn   = DateTime.Now;
            string headSql = transferService.getSql(transfer);
            int    a       = voucherService.excuteSql(headSql);

            if (a >= 1)
            {
                voucherService.UpdateMaxCode("HM701");
            }

            return(a);
        }
Exemplo n.º 3
0
        public int auditTransfer(string ccode, TransferRegister transfer, ref string errMsg)
        {
            int i = transferService.auditVoucher(ccode, transfer, ref errMsg);

            return(i);
        }
Exemplo n.º 4
0
        public string getSql(TransferRegister tr)
        {
            string sql = db.InsertSql <TransferRegister>(tr, "HR_HI_TransferRegister");

            return(sql);
        }
Exemplo n.º 5
0
        public HttpResponseMessage AddTransfer(string token, string json)
        {
            string        errMsg = "";
            ReturnMessage msg    = new ReturnMessage();

            try
            {
                ReceiveLog receive = new ReceiveLog();
                receive.uuid          = Guid.NewGuid();
                receive.receiveData   = json;
                receive.interfaceCode = "Transfer";
                receive.interfaceDesc = "人事调动单新增";
                receive.op            = "add";

                vouMag = (VoucherManager)HttpContext.Current.Application.Get(token);
                if (vouMag == null)
                {
                    msg.Success = false;
                    msg.Msg     = "参数token无效或已过期";
                    msg.Code    = 500;
                }
                else
                {
                    ReceiveLogManager logManager = new ReceiveLogManager(vouMag.UFDataConnstringForNet);
                    logManager.AddReceiveLog(receive, ref errMsg);
                    TransferManager  transferManager = new TransferManager(vouMag.UFDataConnstringForNet);
                    TransferRegister transfer        = (TransferRegister)JsonConvert.DeserializeObject(json, typeof(TransferRegister));
                    int i = transferManager.AddTransfer(transfer, ref errMsg);
                    if (i >= 1)
                    {
                        //msg.Success = true;
                        //dynamic c = new { code = transferManager.ccode };
                        //msg.Data = JsonConvert.SerializeObject(c);
                        //msg.Code = 200;
                        //msg.Msg = "新增成功";
                        int q = transferManager.auditTransfer(transferManager.ccode, transfer, ref errMsg);
                        if (q >= 1)
                        {
                            msg.Success = true;
                            msg.Code    = 200;
                            dynamic c = new { code = transferManager.ccode };
                            msg.Data = JsonConvert.SerializeObject(c);
                            msg.Msg  = "审核成功";
                        }
                        else
                        {
                            msg.Success = false;
                            msg.Code    = 500;
                            msg.Msg     = "审核失败:" + errMsg;
                        }
                    }
                    else
                    {
                        msg.Success = false;
                        msg.Code    = 500;
                        msg.Msg     = "新增失败" + errMsg;
                    }
                    receive = logManager.getReturnDesc(receive, msg);
                    logManager.UpdateReceiveLog(receive, ref errMsg);
                }
                HttpContext.Current.Application.Remove(vouMag.GetGUID);
                string str = msg.ToJson();
                return(new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
            catch (Exception ex)
            {
                msg.Success = false;
                msg.Code    = 500;
                msg.Msg     = ex.Message.ToString();
                string str = msg.ToJson();
                return(new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
        }