/// <summary> /// Get the Criteria for page load. /// </summary> /// <returns></returns> private BusinessEntities.ContractCriteria GetCriteriaForPageload() { //Define the ContractCriteria object. BusinessEntities.ContractCriteria criteria = new BusinessEntities.ContractCriteria(); //Set the all default criteria. if (Session[SessionNames.PAGENUMBER] == null) { Session[SessionNames.PAGENUMBER] = 1; } criteria.PageNumber = Convert.ToInt32(Session[SessionNames.PAGENUMBER].ToString()); ViewState[currentPageIndex] = criteria.PageNumber; criteria.Direction = DESCENDING; //GridViewSortDirection = SortDirection.Descending; if ((sortExpression == string.Empty) || (sortExpression == null)) { sortExpression = criteria.SortExpression; criteria.SortExpression = CommonConstants.CON_PROJECTCODE; } else { criteria.SortExpression = sortExpression; } if (ViewState[SessionNames.CONTRACT_PREVIOUS_SORT_EXPRESSION] == null) { criteria.SortExpression = CommonConstants.CON_PROJECTCODE; } else { criteria.SortExpression = ViewState[SessionNames.CONTRACT_PREVIOUS_SORT_EXPRESSION].ToString(); } if (ViewState[currentPageIndex] != null) { criteria.PageNumber = Convert.ToInt32(ViewState[currentPageIndex].ToString()); } else { criteria.PageNumber = 1; ViewState[currentPageIndex] = criteria.PageNumber; } if (ViewState[SessionNames.CONTRACT_SORTDIRECTIONFORBINDING] == null) { criteria.Direction = DESCENDING; } else { criteria.Direction = ViewState[SessionNames.CONTRACT_SORTDIRECTIONFORBINDING].ToString(); } return(criteria); }
/// <summary> /// Get the criteria for sorting & paging. /// </summary> /// <returns></returns> private BusinessEntities.ContractCriteria GetCriteriaForPagingAndSorting() { try { //Define the ContractCriteria object. BusinessEntities.ContractCriteria criteria = new BusinessEntities.ContractCriteria(); //setting the Sort Expression ie on which field sort will happen. if (ViewState[SessionNames.CONTRACT_PREVIOUS_SORT_EXPRESSION] == null) { criteria.SortExpression = CommonConstants.CON_PROJECTCODE; } else { criteria.SortExpression = ViewState[SessionNames.CONTRACT_PREVIOUS_SORT_EXPRESSION].ToString(); } // setting page number according to which record will fetch. if (ViewState[currentPageIndex] != null) { criteria.PageNumber = Convert.ToInt32(ViewState[currentPageIndex].ToString()); } else { criteria.PageNumber = 1; ViewState[currentPageIndex] = criteria.PageNumber; } //Setting the sort direction. if (ViewState[SessionNames.CONTRACT_SORTDIRECTIONFORBINDING] == null) { criteria.Direction = DESCENDING; } else { criteria.Direction = ViewState[SessionNames.CONTRACT_SORTDIRECTIONFORBINDING].ToString(); } return(criteria); } catch (RaveHRException ex) { throw ex; } catch (Exception ex) { throw new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME_LISTOFPROJECT, "GetCriteriaForPagingAndSorting", EventIDConstants.RAVE_HR_CONTRACT_PRESENTATION_LAYER); } }
/// <summary> /// This method will fetch record of all project details for project list deatails page. /// </summary> /// <returns>list</returns> public BusinessEntities.RaveHRCollection GetProjectsListDetails(BusinessEntities.ContractCriteria criteria) { try { //instantiate contract project object of data layer objContractProj = new Rave.HR.DataAccessLayer.Contracts.ContractProject(); raveHRCollection = objContractProj.GetProjectsListDetails(criteria); return(raveHRCollection); } catch (RaveHRException ex) { throw ex; } catch (Exception ex) { throw new RaveHRException(ex.Message, ex, Sources.BusinessLayer, CONTRACTPROJECT, GETPROJECTSLISTDETAILS, EventIDConstants.RAVE_HR_CONTRACT_BUSNIESS_LAYER); } }
/// <summary> /// This method will fetch records from data base and return to business layer /// </summary> /// <param name=>BusinessEntities.ContractCriteria</param> /// <returns>BusinessEntities.RaveHRCollection</returns> public BusinessEntities.RaveHRCollection GetProjectsListDetails(BusinessEntities.ContractCriteria criteria) { int pageCount = 1; int counter = 0; List <BusinessEntities.ContractProject> objListOfProjects = null; // Initialise Data Access Class object DataAccessClass objProjectDetails = new DataAccessClass(); // Initialise Collection class object raveHRCollection = new BusinessEntities.RaveHRCollection(); try { //Open the connection to DB objProjectDetails.OpenConnection(DBConstants.GetDBConnectionString()); SqlParameter[] sqlParam = new SqlParameter[4]; sqlParam[0] = new SqlParameter(SPParameter.SortExpresion, DbType.String); sqlParam[0].Value = criteria.SortExpression + criteria.Direction; sqlParam[1] = new SqlParameter(SPParameter.pageNum, DbType.Int32); sqlParam[1].Value = criteria.PageNumber; sqlParam[2] = new SqlParameter(SPParameter.pageSize, DbType.Int32); sqlParam[2].Value = 10; sqlParam[3] = new SqlParameter(SPParameter.pageCount, SqlDbType.Int); sqlParam[3].Direction = ParameterDirection.Output; //gets the all project details. DataSet dsProjectdetails = objProjectDetails.GetDataSet(SPNames.Contract_GetProjectList, sqlParam); pageCount = Convert.ToInt32(sqlParam[3].Value); //Create entities and add to list BusinessEntities.ContractProject objProjects = null; objListOfProjects = new List <BusinessEntities.ContractProject>(); foreach (DataRow dr in dsProjectdetails.Tables[0].Rows) { counter++; objProjects = new BusinessEntities.ContractProject(); objProjects.ProjectID = Convert.ToInt32(dr[DbTableColumn.Con_ProjectID]); objProjects.ProjectCode = dr[DbTableColumn.Con_ProjectCode].ToString(); objProjects.DocumentName = dr[DbTableColumn.Con_DocumentName].ToString(); objProjects.ContractCode = dr[DbTableColumn.Con_ContractCode].ToString(); objProjects.ProjectName = dr[DbTableColumn.Con_ConProjectName].ToString(); objProjects.ContractType = dr[DbTableColumn.Con_ContractName].ToString(); objProjects.ClientName = dr[DbTableColumn.ClientName].ToString(); //add page count only first time. if (counter == 1) { objProjects.PageCount = pageCount; } //--add to list objListOfProjects.Add(objProjects); } raveHRCollection.Add(objListOfProjects); return(raveHRCollection); } catch (RaveHRException ex) { throw ex; } catch (Exception ex) { throw new RaveHRException(ex.Message, ex, Sources.DataAccessLayer, CLASSNAME, "GetProjectsListDetails", EventIDConstants.RAVE_HR_CONTRACT_DATA_ACCESS_LAYER); } finally { objProjectDetails.CloseConncetion(); } }
/// <summary> /// This method will fetch records from data base and return to business layer /// </summary> /// <param name="criteria"></param> /// <returns></returns> public List <BusinessEntities.ContractProject> GetProjectForContracts(BusinessEntities.ContractCriteria criteria) { DataAccessClass objDAContractsForProject = new DataAccessClass(); List <BusinessEntities.ContractProject> objListProjectsForContract = null; try { objDAContractsForProject.OpenConnection(DBConstants.GetDBConnectionString()); SqlParameter[] sqlParam = new SqlParameter[2]; sqlParam[0] = new SqlParameter(SPParameter.ContractId, DbType.Int32); sqlParam[0].Value = criteria.ContractId; sqlParam[1] = new SqlParameter(SPParameter.Mode, DbType.Int32); sqlParam[1].Value = criteria.Mode; //--get result DataSet dsContractsForProject = objDAContractsForProject.GetDataSet(SPNames.Contract_GetContract, sqlParam); //--Create entities and add to list BusinessEntities.ContractProject objBEProjectsForContratcs = null; objListProjectsForContract = new List <BusinessEntities.ContractProject>(); foreach (DataRow dr in dsContractsForProject.Tables[0].Rows) { objBEProjectsForContratcs = new BusinessEntities.ContractProject(); if (dr[DbTableColumn.ProjectId] != null) { objBEProjectsForContratcs.ContractProjectID = Convert.ToInt32(dr[DbTableColumn.ProjectId].ToString()); } if (dr[DbTableColumn.Con_ProjectCode] != null) { objBEProjectsForContratcs.ProjectCode = dr[DbTableColumn.Con_ProjectCode].ToString(); } if (dr[DbTableColumn.Con_ProjectName] != null) { objBEProjectsForContratcs.ProjectName = dr[DbTableColumn.Con_ProjectName].ToString(); } if (dr[DbTableColumn.ProjectType] != null) { objBEProjectsForContratcs.ProjectType = dr[DbTableColumn.ProjectType].ToString(); } if (!string.IsNullOrEmpty(dr[DbTableColumn.Con_StartDate].ToString())) { objBEProjectsForContratcs.ProjectStartDate = Convert.ToDateTime(dr[DbTableColumn.Con_StartDate]); } if (!string.IsNullOrEmpty(dr[DbTableColumn.Con_EndDate].ToString())) { objBEProjectsForContratcs.ProjectEndDate = Convert.ToDateTime(dr[DbTableColumn.Con_EndDate]); } if (dr[DbTableColumn.ResourcePlanId] != null) { objBEProjectsForContratcs.RPId = Convert.ToInt32(dr[DbTableColumn.ResourcePlanId].ToString()); } //--add to list objListProjectsForContract.Add(objBEProjectsForContratcs); } return(objListProjectsForContract); } catch (RaveHRException ex) { throw ex; } catch (Exception ex) { throw new RaveHRException(ex.Message, ex, Sources.DataAccessLayer, CLASSNAME, "GetProjectForContracts", EventIDConstants.RAVE_HR_CONTRACT_DATA_ACCESS_LAYER); } finally { objDAContractsForProject.CloseConncetion(); } }
public List <BusinessEntities.ContractProject> GetProjectsDetailsForFilter(BusinessEntities.ContractProject objGridDetail, BusinessEntities.ContractCriteria objContractCriteria) { objContractProj = new Rave.HR.DataAccessLayer.Contracts.ContractProject(); return(objContractProj.GetProjectDetailsForFilter(objGridDetail, objContractCriteria)); }