public HRPersonInfo getPersonInfo(string personCode, ref string errMsg) { try { string today = DateTime.Today.ToString("yyyy-MM-dd"); String sql = "select a.cpsn_num,a.cpsn_name,a.dEnterUnitDate,a.JobNumber,a.cJobCode,a.dLeaveDate,a.rPersonType,IsNull(a1.cDepCode,a.cdept_num) as cDept_num,b.cdepname,c.vdescription as rSex,d.vdescription as rPersonTypeName,e.reducation,HR_CT002.vdescription as EducationName,f.cDutycode,f.vdutyname,j.cJobCode,j.vjobname,a.cJobGradeCode,g.cJobGradeName,a.cJobRankCode,r.cJobRankName,p.dBeginDate, a.cDutyclass,k.vName AS cDutyclassName from hr_hi_person as a left join hr_tm_dayresult as a1 on a.cpsn_num=a1.cpsn_num and ddutyDate='" + today + "' left join department as b on IsNull(a1.cDepCode,a.cdept_num)=b.cdepcode left join HR_CT001 c on c.ccodeID=a.rSex left join HR_CT000 d on d.ccodeID=a.rPersonType left join hr_hi_edu e on a.cPsn_Num = e.cPsn_Num and isnull(e.irecordid,0) = ( select max(isnull(lshy.irecordid,0)) from dbo.hr_hi_edu as lshy where isnull(lshy.blastflag,0)=1 and lshy.cPsn_Num= e.cPsn_Num ) left join HR_CT002 on HR_CT002.ccodeID = e.reducation left join HR_HI_JOBINFO on a.cPsn_Num = HR_HI_JOBINFO.cPsn_Num and isnull(HR_HI_JOBINFO.irecordid,0) = ( select max(isnull(lshy.irecordid,0)) from dbo.HR_HI_JOBINFO as lshy where isnull(lshy.blastflag,0)=1 and lshy.cPsn_Num= HR_HI_JOBINFO.cPsn_Num ) left join HR_OM_DUTY f on HR_HI_JOBINFO.cDutycode = f.cDutycode left join HR_HI_Probation p on a.cPsn_Num = p.cPsn_Num and p.blastflag = 1 left join HR_HM_JobGrade g on a.cJobGradeCode = g.cJobGradeCode left join HR_HM_JobRank r on a.cJobRankCode = r.cJobRankCode left join hr_om_job j on j.cJobCode=a.cJobCode LEFT JOIN hr_tm_DutyClass k ON k.cCode=a.cDutyclass where a.cpsn_num='" + personCode + "'"; DataSet ds = db.Query(sql); HRPersonInfo info = new HRPersonInfo(); if (ds != null) { DataRow dr = ds.Tables[0].Rows[0]; info.personCode = dr["cpsn_num"].ToString(); info.personName = dr["cpsn_name"].ToString(); info.depCode = dr["cDept_num"].ToString(); info.depName = dr["cdepname"].ToString(); info.jobNum = dr["cJobCode"].ToString(); if (dr["cDutyclass"].ToString() != "") { info.dutyClass = dr["cDutyclass"].ToString(); } if (dr["cDutyclassName"].ToString() != "") { info.dutyClassName = dr["cDutyclassName"].ToString(); } } return(info); } catch (Exception ex) { errMsg = ex.Message.ToString(); throw; } }
public int AddErrand(ErrandVoucher errand, ref string errMsg) { ccode = voucherService.GetNewCode("TM02", "CC"); List <ErrandVoucherBody> bodyList = errand.body; errand.head.cVoucherId = ccode; errand.head.cVoucherCode = ccode; errand.head.cCode = "TM140"; errand.head.cExamineApproveType = 2; errand.head.cStatus = "0"; errand.head.pk_hr_tm_ErrandMain = Guid.NewGuid().ToString(); errand.head.dCreateOn = DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd"); errand.head.vReason = bodyList[0].vReason; errand.head.dBeginDate = bodyList[0].dBeginDate; errand.head.dEndDate = bodyList[0].dEndDate; for (int q = 0; q < bodyList.Count; q++) { string person = bodyList[q].cPsn_Num; HRPersonInfo info = voucherService.getPersonInfo(person, ref errMsg); bodyList[q].cDepCode = info.depCode; bodyList[q].cDepName = info.depName; errand.head.cDepName = info.depName; errand.head.cDepCode = info.depCode; bodyList[q].cCreator = errand.head.cCreateBy; //bodyList[q].pk_hr_tm_Errand = Guid.NewGuid().ToString(); bodyList[q].cVoucherId = ccode; bodyList[q].cExamineApproveType = "2"; bodyList[q].cSysBarCode = "|" + q.ToString(); bodyList[q].bAuditFlag = false; bodyList[q].cStatus = "0"; bodyList[q].cErrandType = errand.head.cErrandType; } string headSql = errandService.getHeadSql(errand.head); int a = voucherService.excuteSql(headSql); string bodySql = errandService.getBodySql(errand.body); int b = 0; if (a == 1) { b = voucherService.excuteSql(bodySql); } if (b >= 1) { voucherService.UpdateMaxCode("TM02"); } int i = a + b; return(i); }
public int InsertBody(LeaveVoucherHead head, LeaveVoucherBody body, HRPersonInfo info, string barcode, int row, decimal leaveHours, ref string errMsg) { try { string cSysBarCode = barcode + "|" + (row + 1).ToString(); string year = DateTime.Today.ToString("yyyy"); string sql = " insert into hr_tm_Leave (cExamineApproveType,cDepCode,cDepName,cDutyClass,cLeaveType,cPsn_Num,cSysBarCode,cVoucherId,dBeginDate,dEndDate,nDeductedTime,dPlanEndDate,irowno, IsDeducted,nActualLeaveHours,nActualLeaveTime,PK_hr_tm_Leave,rLeaveStatus,rLeaveTimeType,vLeaveReason,vLeaveUnit,vRemark,vRestPeriod,vTerminateReason) "; sql += "values ('2','" + info.depCode + "','" + info.depName + "','" + info.dutyClass + "','" + head.cLeaveType + "','" + body.cPersonCode + "','" + cSysBarCode + "','" + head.cVoucherCode + "','" + body.dBeginDate + "','" + body.dEndDate + "','0','" + body.dEndDate + "', " + row + ",0," + leaveHours + "," + body.nActualLeaveTime + ",'" + body.pk_hr_tm_Leave + "','0','" + head.rLeaveTimeType + "','" + body.vLeaveReason + "', " + body.vLeaveUnit + ",'" + body.vRemark + "','" + year + "','')"; return(db.ExecuteSql(sql)); } catch (Exception ex) { errMsg = ex.Message.ToString(); throw; } }
public int AddOverTime(OverTimeVoucher overtime, ref string errMsg) { ccode = voucherService.GetNewCode("TM03", "JB"); int record = Convert.ToInt32(overTimeService.GetNewRecord()); List <OverTimeVoucherBody> bodyList = overtime.body; overtime.head.VoucherID = ccode; overtime.head.VoucherCode = ccode; overtime.head.cExamineApproveType = 2; overtime.head.bAuditFlag = 0; overtime.head.cStatus = 0; overtime.head.iRecordId = record + 1; if (overtime.head.iComputeType == "3") { overtime.head.dJbDate = Convert.ToDateTime(bodyList[0].dBeginTime).ToString("yyyy-MM-dd"); overtime.head.dBeginTime = Convert.ToDateTime(bodyList[0].dBeginTime).TimeOfDay.ToString(); overtime.head.dEndTime = Convert.ToDateTime(bodyList[0].dEndTime).TimeOfDay.ToString(); overtime.head.dDutyTime = Convert.ToDateTime(bodyList[0].dBeginTime).TimeOfDay.ToString(); overtime.head.dOffTime = Convert.ToDateTime(bodyList[0].dEndTime).TimeOfDay.ToString(); overtime.head.iBeginCardAhead = 150; overtime.head.iEndCardForward = 150; overtime.head.nManHours = (Convert.ToDateTime(bodyList[0].dEndTime) - Convert.ToDateTime(bodyList[0].dBeginTime)).Hours.ToString(); } else if (overtime.head.iComputeType == "1") { overtime.head.dJbDate = bodyList[0].dJbDate; overtime.head.dBeginTime = ""; overtime.head.dEndTime = ""; overtime.head.dDutyTime = ""; overtime.head.dOffTime = ""; overtime.head.iBeginCardAhead = 0; overtime.head.iEndCardForward = 0; overtime.head.nManHours = bodyList[0].nManHours; } overtime.head.dCreatTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd"); overtime.head.vReason = bodyList[0].vReason; overtime.head.vRemark = bodyList[0].vRemark; for (int q = 0; q < bodyList.Count; q++) { string person = bodyList[q].cPsn_Num; HRPersonInfo info = voucherService.getPersonInfo(person, ref errMsg); overtime.head.cDept_num = info.depCode; bodyList[q].cCreator = overtime.head.cCreator; bodyList[q].cCreatorNum = overtime.head.cCreatorNum; bodyList[q].JobNumber = info.jobNum; bodyList[q].VoucherID = ccode; bodyList[q].uRecordId = Guid.NewGuid().ToString(); bodyList[q].iComputeType = overtime.head.iComputeType; if (overtime.head.iComputeType == "3") { bodyList[q].dDutyTime = Convert.ToDateTime(bodyList[q].dBeginTime).TimeOfDay.ToString(); bodyList[q].dOffTime = Convert.ToDateTime(bodyList[q].dEndTime).TimeOfDay.ToString(); bodyList[q].dJbDate = Convert.ToDateTime(bodyList[q].dBeginTime).ToString("yyy-MM-dd"); bodyList[q].nOvertimeHours = (Convert.ToDateTime(bodyList[q].dEndTime) - Convert.ToDateTime(bodyList[q].dBeginTime)).TotalHours.ToString(); bodyList[q].nManHours = (Convert.ToDateTime(bodyList[q].dEndTime) - Convert.ToDateTime(bodyList[q].dBeginTime)).TotalHours.ToString(); bodyList[q].nSubOVTime = "0"; bodyList[q].dBeginTime = Convert.ToDateTime(bodyList[q].dBeginTime).AddMinutes(-150).TimeOfDay.ToString(); bodyList[q].dEndTime = Convert.ToDateTime(bodyList[q].dEndTime).AddMinutes(150).TimeOfDay.ToString(); bodyList[q].cTimeUseless1 = overtime.head.cTimeUseless1; bodyList[q].cTimeUseless2 = overtime.head.cTimeUseless2; } else if (overtime.head.iComputeType == "1") { bodyList[q].dJbDate = bodyList[q].dJbDate; bodyList[q].dBeginTime = ""; bodyList[q].dEndTime = ""; bodyList[q].dDutyTime = ""; bodyList[q].dOffTime = ""; bodyList[q].nSubOVTime = "0"; bodyList[q].nManHours = bodyList[q].nManHours; bodyList[q].nOvertimeHours = bodyList[q].nManHours; } bodyList[q].dCreatTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd"); bodyList[q].uOverTimeCode = Guid.NewGuid().ToString(); bodyList[q].cExamineApproveType = 2; bodyList[q].bAuditFlag = 0; bodyList[q].cStatus = 0; bodyList[q].iRowNo = q; bodyList[q].vJbCode = overtime.head.vJbCode; bodyList[q].rFreeCardMode = overtime.head.rFreeCardMode; bodyList[q].rDealType = overtime.head.rDealType; } string headSql = overTimeService.getHeadSql(overtime.head); string bodySql = overTimeService.getBodySql(overtime.body); int a = voucherService.excuteSql(headSql); int b = 0; int c = 0; if (a == 1) { b = voucherService.excuteSql(bodySql); } if (b >= 1) { c = voucherService.UpdateMaxCode("TM03"); } int i = a + b + c; return(i); }
public int addLeave(LeaveVoucher leave, ref string errMsg) { LeaveVoucherHead head = leave.head; string voucherCode = service.getNewCode(); ccode = voucherCode; int row = 0; string barcode = "||TM110|" + voucherCode; head.cVoucherCode = voucherCode; List <LeaveVoucherBody> lstBody = leave.body; HRPersonInfo info = service.getPersonInfo(lstBody[0].cPersonCode, ref errMsg); if (lstBody.Count == 1) { head.cDepCode = info.depCode; head.cDepName = info.depName; head.vLeaveReason = lstBody[0].vLeaveReason; head.vRemark = lstBody[0].vRemark; } head.pk_hr_tm_LeaveMain = Guid.NewGuid().ToString(); head.dBeginDate = Convert.ToDateTime(lstBody[0].dBeginDate).ToString("yyyy-MM-dd HH:mm:dd"); head.dEndDate = Convert.ToDateTime(lstBody[0].dEndDate).ToString("yyyy-MM-dd HH:mm:dd"); List <PersonDayResult> personDayResults = service.getPersonDayResult(lstBody); int headdata = service.InsertHead(head, barcode, ref errMsg); if (headdata > 0) { row = row + headdata; int q = service.updateMaxCode(); row = row + q; for (int i = 0; i < lstBody.Count; i++) { //TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(lstBody[i].dBeginDate).Ticks); //TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(lstBody[i].dEndDate).Ticks); //TimeSpan ts = ts1.Subtract(ts2).Duration(); //int day = ts.Days; //int hours = ts.Hours; //获取当前人员排班 List <PersonDayResult> curPersonDay = personDayResults.Where(num => num.cPsn_Num == lstBody[i].cPersonCode).ToList(); int day = curPersonDay.Count; if (day > 1) { } else { TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(lstBody[i].dBeginDate).Ticks); TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(lstBody[i].dEndDate).Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); int hours = ts.Hours; //decimal hours = getLeaveHours(lstBody[i].dBeginDate, lstBody[i].dEndDate); if (hours <= 4) { lstBody[i].LeaveHours = 4; lstBody[i].vLeaveUnit = 2; lstBody[i].nActualLeaveTime = 0.5M; } if (hours > 4 && hours < 8) { lstBody[i].LeaveHours = hours; lstBody[i].vLeaveUnit = 1; lstBody[i].nActualLeaveTime = hours; } } //decimal hours = service.getLeaveHours(lstBody[i].dBeginDate, lstBody[i].dEndDate, // lstBody[i].cPersonCode); decimal hoursForLeave = lstBody[i].LeaveHours; lstBody[i].pk_hr_tm_Leave = Guid.NewGuid().ToString(); int bodydata = service.InsertBody(head, lstBody[i], info, barcode, i, hoursForLeave, ref errMsg); if (bodydata > 0) { row = bodydata + row; } } } return(row); }