Get sqls from Maps

/*------------------BudgetControlorMap----------------------*/
select BudgetControlorID,FeeSortID,BudgetYear,BudgetMonth,Remark,BudgetMoney from OA_Project_BudgetControlor 
Where (@BudgetYear is null or LTRIM(RTRIM(@BudgetYear)) = ‘‘ or BudgetYear = @BudgetYear)
And (@BudgetMonth is null or LTRIM(RTRIM(@BudgetMonth)) = ‘‘ or BudgetMonth= @BudgetMonth)
And (@FeeSortID is null or LTRIM(RTRIM(@FeeSortID)) = ‘‘ or FeeSortID= @FeeSortID)
        
select BudgetControlorID,FeeSortID,BudgetYear,BudgetMonth,Remark,BudgetMoney from OA_Project_BudgetControlor 
Where BudgetControlorID=@BudgetControlorID
        
select BudgetControlorID,FeeSortID,BudgetYear,BudgetMonth,Remark,BudgetMoney from OA_Project_BudgetControlor


/*------------------ChargeUpInfoMap----------------------*/
select ChargeUpID,ChargeUpDate,UserID,FormNo,FormType,OutputMoney,Income,Description,Company,Fund,Currency,Account from OA_Project_ChargeUp  where  ChargeUpID=@ChargeUpID

select ChargeUpID, ChargeUpDate, UserID, FormNo, FormType, OutputMoney, Income, Description, Company, Fund, Currency, Account from OA_Project_ChargeUp  order by ChargeUpDate desc 

select ChargeUpID, ChargeUpDate, UserID, FormNo, FormType, OutputMoney, Income, Description, Company, Fund, Currency, Account 
from OA_Project_ChargeUp 
Where (@Company is null or LTRIM(RTRIM(@Company)) = ‘‘ or Company = @Company) 
And (@Fund is null or LTRIM(RTRIM(@Fund)) = ‘‘ or Fund= @Fund) 
And (@Currency is null or LTRIM(RTRIM(@Currency)) = ‘‘ or Currency= @Currency) 
And (@Account is null or LTRIM(RTRIM(@Account)) = ‘‘ or Account= @Account) 
And (@StartDate is null or LTRIM(RTRIM(@StartDate)) = ‘‘ or ChargeUpDate>=cast(@StartDate as datetime)) 
And (@EndDate is null or LTRIM(RTRIM(@EndDate)) = ‘‘ or ChargeUpDate<=cast(@EndDate as datetime)) 
order by ChargeUpDate desc 

select SUM(OutputMoney), SUM(Income) from OA_Project_ChargeUp  Where datediff(day,ChargeUpDate,@ChargeUpDate)=0 


/*------------------Form_HR_Dimission----------------------*/
--GetDimissionFormByID
select
DimissionFormID,
DimissionFormNo,
DimissionFormOrder,
UrgencyDegree,
DimissionUserID,
LocationUnitID,
DimissionReason,
ExpectDate,
CreateByUserID,
CreateTime
from OA_Form_HR_Dimission 
where 
DimissionFormID=@ID

--GetDimissionFormList
select
DimissionFormID,
DimissionFormNo,
DimissionFormOrder,
UrgencyDegree,
DimissionUserID,
LocationUnitID,
DimissionReason,
ExpectDate,
CreateByUserID,
CreateTime
from OA_Form_HR_Dimission  


--SelectDimissionFormCode
SELECT MAX(CAST(SUBSTRING(DimissionFormNo,3,6) as int))
FROM OA_Form_HR_Dimission

--SelectDimissionFormCount
SELECT COUNT(*) FROM OA_Form_HR_Dimission



/*------------------Form_HR_Employee----------------------*/
--GetEmployeeFormByID
select * from OA_Form_HR_Employee 
where EmployeeFormID=@ID

--GetEmployeeFormList
select * from OA_Form_HR_Employee  

--SelectFormCode
SELECT MAX(CAST(SUBSTRING(EmployeeFormNo,3,6) as int))
FROM OA_Form_HR_Employee

--SelectCount
SELECT COUNT(*) FROM OA_Form_HR_Employee



/*------------------Form_Project_OrderForm----------------------*/
--GetOrderFormByID
select
OrderFormID,
OrderFormNo,
UrgencyDegree,
OrderFormOrder,
ProjectID,
CorrelationCompany,
OrderFormDate,
CompleteTime,
JoinUserXML,
AttachmentName,
OrderContent,
CreateUserID,
CreateFormDate
from OA_T_OrderForm where OrderFormID=@OrderFormID

--GetMaxOrder
select max(cast(substring(OrderFormNo,3,6) as int))  as OrderFormNo from OA_T_OrderForm

--GetOrderFormList
select
OrderFormID,
OrderFormNo,
UrgencyDegree,
OrderFormOrder,
ProjectID,
CorrelationCompany,
OrderFormDate,
CompleteTime,
JoinUserXML,
AttachmentName,
OrderContent,
CreateUserID,
CreateFormDate
from OA_T_OrderForm  



/*------------------Form_Project_WorkManeuve----------------------*/
--GetWorkManeuveFormByID
select
ManeuveFormID,
ManeuveFormNo,
UrgencyDegree,
ManeuveFormOrder,
ProjectID,
CorrelationCompany,
ManeuveFormDate,
CompleteTime,
JoinUserXML,
AttachmentName,
ManeuveContent,
CreateUserID,
CreateFormDate
from OA_T_WorkManeuveForm 
where ManeuveFormID=@ManeuveFormID

--GetWorkManeuveFormList
select
ManeuveFormID,
ManeuveFormNo,
UrgencyDegree,
ManeuveFormOrder,
ProjectID,
CorrelationCompany,
ManeuveFormDate,
CompleteTime,
JoinUserXML,
AttachmentName,
ManeuveContent,
CreateUserID,
CreateFormDate
from OA_T_WorkManeuveForm  

--GetMaxManeuveFormOrder
select max(cast(substring(ManeuveFormNo,3,6) as int))   as ManeuveFormNo    
from OA_T_WorkManeuveForm



/*------------------HR_BargainInfo----------------------*/
--GetBargainInfoByID
select
BargainID,
EmployeeID,
BargainCode,
StartTime,
EndTime,
BargainContent,
BargainUrl,
BargainDesc,
Memo,
CreateUserID,
CreateTime
from OA_HR_BargainInfo 
where BargainID=@BargainID


--GetBargainInfoList
select
BargainID,
EmployeeID,
BargainCode,
StartTime,
EndTime,
BargainContent,
BargainUrl,
BargainDesc,
Memo,
CreateUserID,
CreateTime
from OA_HR_BargainInfo  

--GetBargainInfoListByEmployeeID
select BargainID,EmployeeID,BargainCode,StartTime,EndTime,BargainContent,BargainUrl,BargainDesc,Memo,CreateUserID,CreateTime from OA_HR_BargainInfo where EmployeeID=@EmployeeID



/*------------------HR_EmployeeInfo----------------------*/
--GetEmployeeInfoByID
select OA_HR_EmployeeInfo.*, IBP_T_EA.PK_UnitID as UnitID,
IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
from OA_HR_EmployeeInfo
left outer join IBP_T_User 
on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
left outer join IBP_T_EA
on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
where EmployeeID=@EmployeeID

--GetEmployeeInfoByUserID
select OA_HR_EmployeeInfo.*, IBP_T_EA.PK_UnitID as UnitID,
IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
from OA_HR_EmployeeInfo
left outer join IBP_T_User 
on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
left outer join IBP_T_EA
on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
where EmployeeUserID=@UserID


--GetEmployeeInfoList
select OA_HR_EmployeeInfo.*,IBP_T_EA.PK_UnitID as UnitID,
IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
from OA_HR_EmployeeInfo left outer join IBP_T_User 
on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
left outer join IBP_T_EA on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
from OA_HR_EmployeeInfo WHERE EmployeeDataStatus=2 AND IsDeleted = 0
 

--SearchEmployeeInfoList
select OA_HR_EmployeeInfo.*,IBP_T_EA.PK_UnitID as UnitID,
IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
from OA_HR_EmployeeInfo
left outer join IBP_T_User 
on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
left outer join IBP_T_EA
on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
WHERE EmployeeDataStatus=2 AND IsDeleted = 0 
AND (@UserAccount is null or LTRIM(RTRIM(@UserAccount)) = ‘‘ or IBP_T_User.LogonName = @UserAccount)
AND (@Name is null or LTRIM(RTRIM(@Name)) = ‘‘ or Name = @Name)
AND (@Sex is null or LTRIM(RTRIM(@Sex)) = ‘‘ or OA_HR_EmployeeInfo.Sex= @Sex)
AND (@EmploeeStatus is null or LTRIM(RTRIM(@EmploeeStatus)) = ‘‘ or EmploeeStatus= @EmploeeStatus)
AND (@UnitID is null or LTRIM(RTRIM(@UnitID)) = ‘‘ or IBP_T_User.FK_UnitID= @UnitID)

--SelectIdentity
SELECT IDENT_CURRENT(OA_HR_EmployeeInfo)

--GetMaxMiddleNumOfEmployeeCode
SELECT TOP 1
SUBSTRING(EmployeeCode, LEN(@Prefix)+1, @MiddleNumCount) AS MiddleNum
FROM OA_HR_EmployeeInfo
WHERE 
LEN(EmployeeCode)-LEN(@Prefix)-LEN(@Postfix)=@MiddleNumCount
AND (LEN(@Prefix)=0 OR (CHARINDEX(@Prefix, EmployeeCode) = 1)) 
AND (LEN(@Postfix)=0 OR (CHARINDEX(@Postfix, EmployeeCode) = LEN(EmployeeCode) - LEN(@Postfix)+1))
ORDER BY MiddleNum DESC


/*------------------HR_FamilyMember----------------------*/
--GetFamilyMemberByID
select * from OA_HR_FamilyMemberInfo 
where FamilyMemberID = @FamilyMemberID

--GetFamilyMemberList
select * from OA_HR_FamilyMemberInfo  

--GetFamilyMemberListByEmployeeID
select * from OA_HR_FamilyMemberInfo  
where EmployeeID=@EmployeeID



/*------------------HR_LanguageAbility----------------------*/
--GetLanguageAbilityByID
select
LanguageAbilityID,
LanguageName,
LanguageAbility,
EmployeeID
from OA_HR_LanguageAbility 
where LanguageAbilityID=@LanguageAbilityID

--GetLanguageAbilityList
select
LanguageAbilityID,
LanguageName,
LanguageAbility,
EmployeeID
from OA_HR_LanguageAbility  

--GetLanguageAbilityByEmployeeID
select * from OA_HR_LanguageAbility 
where EmployeeID=@EmployeeID


/*------------------HR_RewardsPunishmentInfo----------------------*/
--GetRewardsPunishmentInfoByID
select
RewardsPunishmentID,
EmployeeID,
RewardsPunishmentType,
RewardsPunishmentDate,
RewardsPunishmentContent,
ApproveReson,
ApproveResult,
ApproveUnit,
ApproveMind,
Memo
from OA_HR_RewardsPunishment 
where RewardsPunishmentID=@RewardsPunishmentID

--GetRewardsPunishmentInfoList
select
RewardsPunishmentID,
EmployeeID,
RewardsPunishmentType,
RewardsPunishmentDate,
RewardsPunishmentContent,
ApproveReson,
ApproveResult,
ApproveUnit,
ApproveMind,
Memo
from OA_HR_RewardsPunishment  

--GetRewardsPunishmentInfoListByEmployeeId
select
EmployeeID,
RewardsPunishmentID,
RewardsPunishmentType,
RewardsPunishmentDate,
RewardsPunishmentContent,
ApproveReson,
ApproveResult,
ApproveUnit,
ApproveMind,
Memo
from OA_HR_RewardsPunishment  
where EmployeeID=@EmployeeID


/*------------------HR_SalaryInfo----------------------*/
--GetSalaryInfoByID
select
SalaryInfoID,
EmployeeID,
OldSalary,
CurrentSalary,
Reason,
ApprovePerson,
ChangeTime,
Memo,
CreateUserID,
CreateTime
from OA_HR_SalaryInfo 
where SalaryInfoID=@SalaryInfoID

--GetSalaryInfoList
select
SalaryInfoID,
EmployeeID,
OldSalary,
CurrentSalary,
Reason,
ApprovePerson,
ChangeTime,
Memo,
CreateUserID,
CreateTime
from OA_HR_SalaryInfo  

--GetSalaryInfoListByEmployeeID
select
SalaryInfoID,
EmployeeID,
OldSalary,
CurrentSalary,
Reason,
ApprovePerson,
ChangeTime,
Memo,
CreateUserID,
CreateTime
from OA_HR_SalaryInfo  
where EmployeeID=@EmployeeID


/*------------------HR_SchoolingInfo----------------------*/
--GetSchoolingInfoByID
select * from OA_HR_SchoolingInfo 
where SchoolingInfoID=@SchoolingInfoID

--GetSchoolingInfoList
select * from OA_HR_SchoolingInfo  

--GetSchoolingInfoListByEmployeeID
select *
from OA_HR_SchoolingInfo 
where EmployeeID=@EmployeeID


/*------------------HR_SkillsInfo----------------------*/
--GetSkillsInfoByID
select * from OA_HR_OtherSkills 
where OtherSkillsID=@OtherSkillsID

--GetSkillsInfoList
select * from OA_HR_OtherSkills  

--GetSkillsInfoByEmployeeID
select * from OA_HR_OtherSkills where EmployeeID=@EmployeeID



/*------------------HR_VitaInfo----------------------*/
--GetVitaInfoByID
select
VitaID,
EmployeeID,
WorkUnit,
WorkStartTime,
WorkEndTime,
Department,
WorkPosition,
Achievement,
SalaryRange,
DimissionReason,
ProvePerson,
ProvePersonRelation,
Memo,
CreateUserID,
CreateTime
from OA_HR_VitaInfo 
where 
VitaID=@VitaID

--GetVitaInfoList
select
VitaID,
EmployeeID,
WorkUnit,
WorkStartTime,
WorkEndTime,
Department,
WorkPosition,
Achievement,
SalaryRange,
DimissionReason,
ProvePerson,
ProvePersonRelation,
Memo,
CreateUserID,
CreateTime
from OA_HR_VitaInfo  

--GetVitaInfoListByEmployeeID
select
VitaID,
EmployeeID,
WorkUnit,
WorkStartTime,
WorkEndTime,
Department,
WorkPosition,
Achievement,
SalaryRange,
DimissionReason,
ProvePerson,
ProvePersonRelation,
Memo,
CreateUserID,
CreateTime
from OA_HR_VitaInfo 
where 
EmployeeID=@EmployeeID



/*------------------IM_InternalMessage----------------------*/
--GetInternalMessageByID
select
MessageID,
MessageTitle,
MessageContent,
SendTime,
MessageType,
SendUserID,
SendTarget,
IsDeleted,
IBP_T_User.UserName As SendUserName
from OA_IM_InternalMessage
LEFT OUTER JOIN IBP_T_User
ON IBP_T_User.PK_UserID=SendUserID
where MessageID=@MessageID

--UpdateDeleteStatusOfInternalMessage
update OA_IM_InternalMessage set IsDeleted=@IsDeleteD where MessageID=@MessageID

--GetInternalMessageReceiveInfoByID
select
MessageID,
ReceiveUserID,
ReceiveTime,
ViewState,
ViewTime
from OA_IM_InternalMessageReceive where 
MessageID=@MessageID 
AND ReceiveUserID=@ReceiveUserID

--GetMsgCountNotViewed
select Count(*)
from OA_IM_InternalMessageReceive 
where ReceiveUserID=@ReceiveUserID AND ViewState=0;

--SearchSendMessage
/*
if MessageTitle is not null and is not empty
set MessageTitle = ‘%‘ +MessageTitle +‘%‘
*/
select
MessageID,
MessageTitle,
MessageContent,
SendTime,
MessageType,
SendUserID,
SendTarget,
IsDeleted,
IBP_T_User.UserName As SendUserName
from OA_IM_InternalMessage
LEFT OUTER JOIN IBP_T_User ON IBP_T_User.PK_UserID=SendUserID
WHERE SendUserID = @SendUserID And IsDeleted=0 
AND (@MessageTitle is null or LTRIM(RTRIM(@MessageTitle)) = ‘‘ or MessageTitle LIKE @MessageTitle)
AND (@MessageContent is null or LTRIM(RTRIM(@MessageContent)) = ‘‘ or MessageContent LIKE @MessageContent)
AND (@SendStartTime is null or LTRIM(RTRIM(@SendStartTime)) = ‘‘ or SendTime >= cast(@SendStartTime as datetime))
AND (@SendEndTime is null or LTRIM(RTRIM(@SendEndTime)) = ‘‘ or SendTime <= cast(@SendEndTime as datetime))
AND (@SendTarget is null or LTRIM(RTRIM(@SendTarget)) = ‘‘ or MessageID IN (Select MessageID From OA_IM_InternalMessageReceive WHERE ReceiveUserID=@SendTarget))
Order by SendTime Desc

--SearchReceiveMessage
select
OA_IM_InternalMessage.MessageID,
ReceiveUserID,
ReceiveTime,
ViewState,
ViewTime
from OA_IM_InternalMessageReceive
Left Outer Join OA_IM_InternalMessage ON  
OA_IM_InternalMessageReceive.MessageID = OA_IM_InternalMessage.MessageID
Where OA_IM_InternalMessageReceive.ReceiveUserID = @ReceiveUserID
AND (@MessageTitle is null or LTRIM(RTRIM(@MessageTitle)) = ‘‘ or OA_IM_InternalMessage.MessageTitle LIKE @MessageTitle)
AND (@MessageContent is null or LTRIM(RTRIM(@MessageContent)) = ‘‘ or OA_IM_InternalMessage.MessageContent LIKE @MessageContent)
AND (@ReceiveStartTime is null or LTRIM(RTRIM(@ReceiveStartTime)) = ‘‘ or ReceiveTime >= cast(@ReceiveStartTime as datetime))
AND (@ReceiveEndTime is null or LTRIM(RTRIM(@ReceiveEndTime)) = ‘‘ or ReceiveTime <= cast(@ReceiveEndTime as datetime)) 
AND (@SendUserID is null or LTRIM(RTRIM(@SendUserID)) = ‘‘ or OA_IM_InternalMessage.SendUserID = @SendUserID)
Order by ReceiveTime Desc


/*------------------LateInfoMap----------------------*/
--GetLateInfoByID
select
BLMonthRPTID,
RPTYear,
RPTMonth,
RPTStatus,
RPTCreateUser,
RPTCreateDate,
RPTAuditUser,
RPTAuditDate
from OA_T_BeLateMonthRPT where 
BLMonthRPTID=@BLMonthRPTID


--GetLateInfoList
select
BLMonthRPTID,
RPTYear,
RPTMonth,
RPTStatus,
RPTCreateUser,
RPTCreateDate,
RPTAuditUser,
RPTAuditDate
from OA_T_BeLateMonthRPT  


--GetLateInfoByYearAndMonth
select
BLMonthRPTID,
RPTYear,
RPTMonth,
RPTStatus,
RPTCreateUser,
RPTCreateDate,
RPTAuditUser,
RPTAuditDate
from OA_T_BeLateMonthRPT 
WHERE (@RPTYear is null or LTRIM(RTRIM(@RPTYear)) = ‘‘ or RPTYear = @RPTYear)
AND (@RPTMonth is null or LTRIM(RTRIM(@)) = ‘‘ or RPTMonth= @RPTMonth)
 
--DeleteLateInfoByYearAndMonth
delete from OA_T_BeLateMonthRPT
WHERE (@RPTYear is null or LTRIM(RTRIM(@RPTYear)) = ‘‘ or RPTYear = @RPTYear)
AND (@RPTMonth is null or LTRIM(RTRIM(@RPTMonth)) = ‘‘ or RPTMonth= @RPTMonth)
 
--GetLateInfoDetailByID
select
DetailID,
BLMonthRPTID,
UserID,
WorkDays,
BLNumberONFifteen,
BLTimeONFifteen,
BLNumberOutFifteen,
BLTimeOutFifteen,
BLNumberTotal,
BLTimeTotal,
isSendWarning,
SendWarningStatus
from OA_T_BeLateMonthRPTDetail 
where DetailID=@DetailID

--GetLateInfoDetailList
select
DetailID,
BLMonthRPTID,
UserID,
WorkDays,
BLNumberONFifteen,
BLTimeONFifteen,
BLNumberOutFifteen,
BLTimeOutFifteen,
BLNumberTotal,
BLTimeTotal,
isSendWarning,
SendWarningStatus
from OA_T_BeLateMonthRPTDetail  

--GetLateInfoDetailListByMasterId
select
DetailID,
BLMonthRPTID,
UserID,
WorkDays,
BLNumberONFifteen,
BLTimeONFifteen,
BLNumberOutFifteen,
BLTimeOutFifteen,
BLNumberTotal,
BLTimeTotal,
isSendWarning,
SendWarningStatus,
UnitName,
UserName
from OA_T_BeLateMonthRPTDetail 
Left Outer Join IBP_T_User 
On IBP_T_User.PK_UserID=OA_T_BeLateMonthRPTDetail.UserID
Left Outer Join IBP_T_EA
On IBP_T_EA.PK_UnitID=IBP_T_User.FK_UnitID
where BLMonthRPTID=@BLMonthRPTID
Order by UnitName,UserName


/*------------------ProjectEstimateCostMap----------------------*/
--GetProjectEstimateCostByID
select
CostID,
ProjectID,
ProjectEstimateQuote,
ProjectEstimateBudget,
CreateUserID,
CreateDate,
Remark
from OA_T_ProjectEstimateCost 
where CostID=@CostID

--GetProjectEstimateCostByProject
select TOP 1
CostID,
ProjectID,
ProjectEstimateQuote,
ProjectEstimateBudget,
CreateUserID,
CreateDate,
Remark
from OA_T_ProjectEstimateCost 
where ProjectID=@ProjectID
ORDER BY CreateDate DESC

--GetProjectEstimateCostList
select
CostID,
ProjectID,
ProjectEstimateQuote,
ProjectEstimateBudget,
CreateUserID,
CreateDate,
Remark from OA_T_ProjectEstimateCost  


/*------------------TimeCard_OverTimeInfoMap----------------------*/
--GetOverTimeInfoByID
select
OTMonthRPTID,
RPTYear,
RPTMonth,
RPTStatus,
RPTCreateUser,
RPTCreateDate,
RPTAuditUser,
RPTAuditDate,
RPTEndDate
from OA_T_OvertimeMonthRPT 
where 
OTMonthRPTID=@OTMonthRPTID

--GetOverTimeInfoByYearAndMonth
select
OTMonthRPTID,
RPTYear,
RPTMonth,
RPTStatus,
RPTCreateUser,
RPTCreateDate,
RPTAuditUser,
RPTAuditDate,
RPTEndDate
from OA_T_OvertimeMonthRPT 
WHERE (@RPTYear is null or LTRIM(RTRIM(@RPTYear)) = ‘‘ or RPTYear = @RPTYear)
AND (@RPTMonth is null or LTRIM(RTRIM(@RPTMonth)) = ‘‘ or RPTMonth= @RPTMonth)
 
--GetOverTimeInfoList
select
OTMonthRPTID,
RPTYear,
RPTMonth,
RPTStatus,
RPTCreateUser,
RPTCreateDate,
RPTAuditUser,
RPTAuditDate,
RPTEndDate
from OA_T_OvertimeMonthRPT  


--GetOverTimeInfoDetailByID
select
DetailID,
OTMonthRPTID,
UserID,
LastOTTime,
OTTimeTotal,
ReturnMoneyTime,
LeaveOTTime,
FurloughTimeTotal
from OA_T_OvertimeMonthRPTDetail 
where DetailID=@DetailID


--GetOverTimeInfoDetailList
select
DetailID,
OTMonthRPTID,
UserID,
LastOTTime,
OTTimeTotal,
ReturnMoneyTime,
LeaveOTTime,
FurloughTimeTotal
from OA_T_OvertimeMonthRPTDetail  


--GetMaxEndDate
Select Max(RPTEndDate) FROM OA_T_OvertimeMonthRPT


--GetLeaveOTTimeForMaxMonth" parameterClass="string
SELECT LeaveOTTime 
FROM OA_T_OvertimeMonthRPTDetail
Where UserID=@UserID AND 
OTMonthRPTID IN (Select OTMonthRPTID From OA_T_OvertimeMonthRPT WHERE RPTEndDate=(Select Max(RPTEndDate) FROM OA_T_OvertimeMonthRPT))


--GetOTInfoDetailListByMasterId" resultMap="OverTimeInfoDetailResult" parameterClass="string
select
DetailID,
OTMonthRPTID,
UserID,
LastOTTime,
OTTimeTotal,
ReturnMoneyTime,
LeaveOTTime,
FurloughTimeTotal,
UserName,
UnitName
from OA_T_OvertimeMonthRPTDetail 
Left Outer Join IBP_T_User 
On IBP_T_User.PK_UserID=OA_T_OvertimeMonthRPTDetail.UserID
Left Outer Join IBP_T_EA
On IBP_T_EA.PK_UnitID=IBP_T_User.FK_UnitID
where OTMonthRPTID=@OTMonthRPTID
Order by UnitName,UserName


/*------------------TimeCard_YearFurlough----------------------*/
--SearchYearFurlough
select
YFID,
YearWord,
PFStartDate,
TFStartDate,
PFEndDate,
TFEndDate,
PFMount,
TFMount,
SurplusMount,
YFEditUserID,
YFEditDate,
IBP_T_User.PK_UserID as UserID,
IBP_T_User.UserName,
IBP_T_EA.UnitName
from  IBP_T_User 
Left Outer Join IBP_T_EA
On IBP_T_EA.PK_UnitID=IBP_T_User.FK_UnitID
Left Outer Join OA_YearFurlough 
On IBP_T_User.PK_UserID=OA_YearFurlough.UserID
WHERE (YearWord=@YearWorD OR YearWord IS NULL) AND IBP_T_User.Status=1  
Order by UnitName,UserName


--GetYearFurloughByUserAndYear
select
YFID,
YearWord,
UserID,
PFStartDate,
TFStartDate,
PFEndDate,
TFEndDate,
PFMount,
TFMount,
SurplusMount,
YFEditUserID,
YFEditDate,
UnitName,
UserName
from OA_YearFurlough
Left Outer Join IBP_T_User 
On IBP_T_User.PK_UserID=OA_YearFurlough.UserID 
Left Outer Join IBP_T_EA
On IBP_T_EA.PK_UnitID=IBP_T_User.FK_UnitID
where YearWord=@YearWorD And UserID=@UserID 


--GetYearFurloughList
select
YFID,
UserID,
PFStartDate,
TFStartDate,
PFEndDate,
TFEndDate,
PFMount,
TFMount,
SurplusMount,
YFEditUserID,
YFEditDate
from OA_YearFurlough  


--GetYearFurloughCanUsed
SELECT
YFID,
YearWord,
UserID,
PFStartDate,
TFStartDate,
PFEndDate,
TFEndDate,
PFMount,
TFMount,
SurplusMount,
YFEditUserID,
YFEditDate,
UnitName,
UserName
FROM OA_YearFurlough
Left Outer Join IBP_T_User 
On IBP_T_User.PK_UserID=OA_YearFurlough.UserID 
Left Outer Join IBP_T_EA
On IBP_T_EA.PK_UnitID=IBP_T_User.FK_UnitID
WHERE TFStartDate<=Cast(@TFStartDate as DateTime) AND TFEndDate>= Cast(@TFEndDate as DateTime) And UserID=@UserID


--UpdateSurplusMount
update OA_YearFurlough set 
SurplusMount=Cast(SurplusMount as Float)-Cast(@SurplusMount as Float)
where TFStartDate<=Cast(@TFStartDate@ as DateTime) AND TFEndDate>= Cast(@TFStartDate@ as DateTime) And UserID=@UserID



/*------------------WorkFlow_FormField----------------------*/
--GetFormFieldByID
select
FormFieldID,
FormTypeID,
FormFieldName,
FormFieldNo
from OA_WorkFlow_FormField 
where FormFieldID=@FormFieldID


--GetFormFieldByFormTypeID
select
FormFieldID,
FormTypeID,
FormFieldName,
FormFieldNo
from OA_WorkFlow_FormField 
where FormTypeID=@FormTypeID


--GetFormFieldList
select
FormFieldID,
FormTypeID,
FormFieldName,
FormFieldNo
from OA_WorkFlow_FormField  



/*------------------WorkFlow_NodeAction----------------------*/
--GetNodeActionByID
select
NodeActionID,
FormTypeID,
NodeActionName,
NodeActionNo
from OA_WorkFlow_NodeAction 
where NodeActionID=@NodeActionID

--GetNodeActionList
select
NodeActionID,
FormTypeID,
NodeActionName,
NodeActionNo
from OA_WorkFlow_NodeAction  


--GetNodeActionListByFormTypeID
select
NodeActionID,
FormTypeID,
NodeActionName,
NodeActionNo
from OA_WorkFlow_NodeAction 
Where FormTypeID=@FormTypeID 
OR FormTypeID is NULL
ORDER BY NodeActionNo



/*------------------WorkFlow_NodeActionResult----------------------*/
--GetNodeActionResultByID
select
FlowScoreID,
ProjectFormID,
NodeActionCode,
FieldName,
FieldValue
from OA_WorkFlow_NodeActionResult 
where FlowScoreID=@FlowScoreID

--GetNodeActionResultList
select
FlowScoreID,
ProjectFormID,
NodeActionCode,
FieldName,
FieldValue
from OA_WorkFlow_NodeActionResult  

--DeleteNodeActionResultByFormIDAndActionCode
delete from OA_WorkFlow_NodeActionResult 
WHERE (@ProjectFormID is null or LTRIM(RTRIM(@ProjectFormID)) = ‘‘ or ProjectFormID = @ProjectFormID)
AND (@NodeActionCode is null or LTRIM(RTRIM(@NodeActionCode)) = ‘‘ or NodeActionCode = @NodeActionCode)

--GetNodeActionResult
select
FlowScoreID,
ProjectFormID,
NodeActionCode,
FieldName,
FieldValue
from OA_WorkFlow_NodeActionResult 
where ProjectFormID=@ProjectFormID AND NodeActionCode=@NodeActionCode

--GetNodeActionResultByParam
select
FlowScoreID,
ProjectFormID,
NodeActionCode,
FieldName,
FieldValue
from OA_WorkFlow_NodeActionResult 
WHERE (@ProjectFormID is null or LTRIM(RTRIM(@ProjectFormID)) = ‘‘ or ProjectFormID = @ProjectFormID)
AND (@NodeActionCode is null or LTRIM(RTRIM(@NodeActionCode)) = ‘‘ or NodeActionCode = @NodeActionCode)
AND (@FieldName is null or LTRIM(RTRIM(@FieldName)) = ‘‘ or FieldName = @FieldName)
View Code

 

Get sqls from Maps,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。