public void ExecuteLeave(LeaveApplyEntity leaveApply) { int nYear = leaveApply.dtBeginTime.Year; int nMonth = leaveApply.dtBeginTime.Month; string sql = "select * From TAB_LeaveMgr_AnnualLeave where strTrainmanNumber = @strTrainmanNumber and nYear = @nYear and nMonth = @nMonth"; DbParamDict paramDict = new DbParamDict(); paramDict.Add("nYear", nYear, ParamDataType.dtInt); paramDict.Add("nMonth", nMonth, ParamDataType.dtInt); paramDict.Add("strTrainmanNumber", leaveApply.strTrainmanNumber, ParamDataType.dtString); DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql, paramDict.GetParams()).Tables[0]; if (dt.Rows.Count > 0) { paramDict.Clear(); paramDict.Add("strLeaveGUID", leaveApply.strAskLeaveGUID, ParamDataType.dtString); paramDict.Add("nLeaveState", 1, ParamDataType.dtInt); paramDict.Add("dtLeaveTime", leaveApply.dtBeginTime, ParamDataType.dtDateTime); paramDict.Add("strAnnualGUID", dt.Rows[0]["strAnnualGUID"].ToString(), ParamDataType.dtString); sql = "update TAB_LeaveMgr_AnnualLeave set strLeaveGUID = @strLeaveGUID,nLeaveState = @nLeaveState,dtLeaveTime=@dtLeaveTime where strAnnualGUID = @strAnnualGUID"; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, sql, paramDict.GetParams()); } }
public void ExecuteUnLeave(SqlTransaction trans, CancelLeaveDetailEntity entity) { string sql = "select * From TAB_LeaveMgr_AnnualLeave where strLeaveGUID = @strLeaveGUID"; DbParamDict paramDict = new DbParamDict(); paramDict.Add("strLeaveGUID", entity.strAskLeaveGUID, ParamDataType.dtString); DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql, paramDict.GetParams()).Tables[0]; if (dt.Rows.Count > 0) { paramDict.Clear(); paramDict.Add("strLeaveGUID", entity.strAskLeaveGUID, ParamDataType.dtString); paramDict.Add("nLeaveState", 2, ParamDataType.dtInt); paramDict.Add("dtUnleaveTime", entity.dtCancelTime, ParamDataType.dtDateTime); sql = "update TAB_LeaveMgr_AnnualLeave set dtUnleaveTime= @dtUnleaveTime,nLeaveState = @nLeaveState where strLeaveGUID = @strLeaveGUID"; SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql, paramDict.GetParams()); } }