public static DataTable GetStatementsPage(SqlTransaction trans, PageSettings pageSettings, Guid userId, int departmentId) { Department department = new Department(trans, departmentId); Worker worker = new Worker(trans, userId); SqlParameter[] sps = new SqlParameter[19]; sps[0] = new SqlParameter("@PageIndex", SqlDbType.Int); sps[0].Value = pageSettings.PageIndex; sps[1] = new SqlParameter("@SortColumnName", SqlDbType.VarChar, 50); sps[1].Value = pageSettings.SortColumn; sps[2] = new SqlParameter("@SortOrderBy", SqlDbType.VarChar, 4); sps[2].Value = pageSettings.SortOrder; sps[3] = new SqlParameter("@NumberOfRows", SqlDbType.Int); sps[3].Value = pageSettings.PageSize; sps[4] = new SqlParameter("@TotalRecords", SqlDbType.Int); sps[4].Direction = ParameterDirection.Output; sps[5] = new SqlParameter("@CreationDate", SqlDbType.DateTime); if (pageSettings.Where.HasRule("CreationDate")) { sps[5].Value = SqlDateTime.Parse(pageSettings.Where.GetRule("CreationDate").Data); } else { sps[5].Value = DBNull.Value; } sps[6] = new SqlParameter("@CreationDateStart", SqlDbType.DateTime); sps[6].Value = pageSettings.Where.HasRule("CreationDateStart") ? SqlDateTime.Parse(pageSettings.Where.GetRule("CreationDateStart").Data) : SqlDateTime.MinValue; sps[7] = new SqlParameter("@CreationDateEnd", SqlDbType.DateTime); sps[7].Value = pageSettings.Where.HasRule("CreationDateEnd") ? SqlDateTime.Parse(pageSettings.Where.GetRule("CreationDateEnd").Data) : SqlDateTime.MaxValue; sps[8] = new SqlParameter("@CitizenLastName", SqlDbType.NVarChar, 50); sps[8].Value = pageSettings.Where.HasRule("CitizenLastName") ? pageSettings.Where.GetRule("CitizenLastName").Data : String.Empty; sps[9] = new SqlParameter("@HeadLastName", SqlDbType.NVarChar, 50); sps[9].Value = pageSettings.Where.HasRule("HeadLastName") ? pageSettings.Where.GetRule("HeadLastName").Data : String.Empty; sps[10] = new SqlParameter("@CityObjectName", SqlDbType.NVarChar, 50); sps[10].Value = pageSettings.Where.HasRule("CityObjectName") ? pageSettings.Where.GetRule("CityObjectName").Data : String.Empty; sps[11] = new SqlParameter("@Number", SqlDbType.NVarChar, 50); sps[11].Value = pageSettings.Where.HasRule("Number") ? pageSettings.Where.GetRule("Number").Data : String.Empty; sps[12] = new SqlParameter("@ExternalNumber", SqlDbType.NVarChar, 50); sps[12].Value = pageSettings.Where.HasRule("ExternalNumber") ? pageSettings.Where.GetRule("ExternalNumber").Data : String.Empty; sps[13] = new SqlParameter("@DepartmentID", SqlDbType.Int); sps[13].Value = departmentId; sps[14] = new SqlParameter("@Content", SqlDbType.NVarChar); sps[14].Value = pageSettings.Where.HasRule("Content") ? pageSettings.Where.GetRule("Content").Data : String.Empty; sps[15] = new SqlParameter("@Controlled", SqlDbType.Bit); bool controlled = false; if (pageSettings.Where.HasRule("Controlled")) { Boolean.TryParse(pageSettings.Where.GetRule("Controlled").Data, out controlled); } if (controlled) { sps[15].Value = true; } else { sps[15].Value = DBNull.Value; } sps[16] = new SqlParameter("@WorkerID", SqlDbType.Int); sps[16].Value = worker.ID; sps[17] = new SqlParameter("@InnerNumber", SqlDbType.NVarChar, 50); sps[17].Value = pageSettings.Where.HasRule("InnerNumber") ? pageSettings.Where.GetRule("InnerNumber").Data : String.Empty; sps[18] = new SqlParameter("@OpenWorker", SqlDbType.Bit); if (pageSettings.Where.HasRule("OpenWorker")) { bool openWorker = false; Boolean.TryParse(pageSettings.Where.GetRule("OpenWorker").Data, out openWorker); sps[18].Value = openWorker; } else { sps[18].Value = DBNull.Value; } DataTable dt = SPHelper.ExecuteDataset(trans, SpNames.StatementsPage, sps).Tables[0]; pageSettings.TotalRecords = sps[4].Value != DBNull.Value ? Convert.ToInt32(sps[4].Value) : 0; return(dt); }
public static DataTable GetDraftPage(SqlTransaction trans, PageSettings pageSettings, Guid userId, int departmentId) { Department department = new Department(trans, departmentId); Worker worker = new Worker(trans, userId); /*if (!Permission.IsUserPermission(trans, userId, department.ObjectID, (int)Department.ActionType.View)) * { * throw new AccessException(userId.ToString(), "Get document template"); * }*/ //worker.PostID SqlParameter[] sps = new SqlParameter[14]; sps[0] = new SqlParameter("@PageIndex", SqlDbType.Int); sps[0].Value = pageSettings.PageIndex; sps[1] = new SqlParameter("@SortColumnName", SqlDbType.VarChar, 50); sps[1].Value = pageSettings.SortColumn; sps[2] = new SqlParameter("@SortOrderBy", SqlDbType.VarChar, 4); sps[2].Value = pageSettings.SortOrder; sps[3] = new SqlParameter("@NumberOfRows", SqlDbType.Int); sps[3].Value = pageSettings.PageSize; sps[4] = new SqlParameter("@TotalRecords", SqlDbType.Int); sps[4].Direction = ParameterDirection.Output; sps[5] = new SqlParameter("@CreationDate", SqlDbType.DateTime); if (pageSettings.Where.HasRule("CreationDate")) { sps[5].Value = DateTime.Parse(pageSettings.Where.GetRule("CreationDate").Data, CultureInfo.CurrentCulture); } else { sps[5].Value = DBNull.Value; } SqlDateTime cdStart = SqlDateTime.MinValue; if (pageSettings.Where.HasRule("CreationDateStart")) { cdStart = DateTime.Parse(pageSettings.Where.GetRule("CreationDateStart").Data, CultureInfo.CurrentCulture); } sps[6] = new SqlParameter("@CreationDateStart", SqlDbType.DateTime); sps[6].Value = cdStart; SqlDateTime cdEnd = SqlDateTime.MaxValue; if (pageSettings.Where.HasRule("CreationDateEnd")) { cdEnd = DateTime.Parse(pageSettings.Where.GetRule("CreationDateEnd").Data, CultureInfo.CurrentCulture); } sps[7] = new SqlParameter("@CreationDateEnd", SqlDbType.DateTime); sps[7].Value = cdEnd; sps[8] = new SqlParameter("@Number", SqlDbType.NVarChar, 50); sps[8].Value = pageSettings.Where.HasRule("Number") ? pageSettings.Where.GetRule("Number").Data : String.Empty; sps[9] = new SqlParameter("@DepartmentID", SqlDbType.Int); sps[9].Value = departmentId; sps[10] = new SqlParameter("@DocumentCodeID", SqlDbType.Int); int documentCodeId; if (pageSettings.Where.HasRule("DocumentCodeID") && Int32.TryParse(pageSettings.Where.GetRule("DocumentCodeID").Data, out documentCodeId)) { sps[10].Value = documentCodeId; } else { sps[10].Value = DBNull.Value; } sps[11] = new SqlParameter("@Content", SqlDbType.NVarChar); sps[11].Value = pageSettings.Where.HasRule("Content") ? pageSettings.Where.GetRule("Content").Data : String.Empty; sps[12] = new SqlParameter("@OrganizationName", SqlDbType.NVarChar, 256); sps[12].Value = pageSettings.Where.HasRule("OrganizationName") ? pageSettings.Where.GetRule("OrganizationName").Data : String.Empty; sps[13] = new SqlParameter("@WorkerID", SqlDbType.Int); sps[13].Value = worker.ID; DataTable dt = SPHelper.ExecuteDataset(trans, SpNames.DraftPage, sps).Tables[0]; pageSettings.TotalRecords = sps[4].Value != DBNull.Value ? Convert.ToInt32(sps[4].Value) : 0; return(dt); }