458 lines
17 KiB
C#
458 lines
17 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.SanKu
|
|
{
|
|
public partial class DataValidation : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
UnitService.InitUnitDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, true);
|
|
UnitService.InitUnitDropDownList(this.drpPersonUnit, this.CurrUser.LoginProjectId, true);
|
|
TabStrip1_TabIndexChanged(null, null);
|
|
}
|
|
}
|
|
|
|
protected void TabStrip1_TabIndexChanged(object sender, EventArgs e)
|
|
{
|
|
string title = "项目校验";
|
|
if (TabStrip1.ActiveTabIndex == 0)
|
|
{
|
|
title = "项目校验";
|
|
this.BindGrid();
|
|
}
|
|
else if (TabStrip1.ActiveTabIndex == 1)
|
|
{
|
|
title = "单位校验";
|
|
this.BindGrid2();
|
|
}
|
|
else if (TabStrip1.ActiveTabIndex == 2)
|
|
{
|
|
title = "用户校验";
|
|
this.BindGrid3();
|
|
}
|
|
else if (TabStrip1.ActiveTabIndex == 3)
|
|
{
|
|
title = "项目人员校验";
|
|
this.BindGrid4();
|
|
}
|
|
else
|
|
{
|
|
title = "项目校验";
|
|
this.BindGrid();
|
|
}
|
|
this.Panel1.Title = title;
|
|
|
|
var db = Funs.DB;
|
|
//记录操作日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = "数据校验";
|
|
newModel.CONTENT = title;
|
|
newModel.RESULT = "成功";
|
|
newModel.DETAIL = "成功";
|
|
newModel.OPERATOR = this.CurrUser.UserName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
#region 项目校验
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT tba.ProjectId,ProjectCode,tba.ProjectName,StartDate ,'预立项项目或者未关联主数据项目' AS Memo
|
|
FROM Base_Project AS tba WITH(NOLOCK)
|
|
WHERE ProjectState=1 AND ISNULL(isDelete,0)=1 AND( MasterSysId IS NULL OR MasterSysId NOT IN (SELECT pro_id FROM ads_pms_pro_info_build)) ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.txtProjectName.Text.Trim()))
|
|
{
|
|
strSql += " AND ProjectName LIKE @ProjectName ";
|
|
listStr.Add(new SqlParameter("@ProjectName", "%" + this.txtProjectName.Text.Trim() + "%"));
|
|
}
|
|
//if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
//{
|
|
// strSql += " AND tba.UnitId = @UnitId2";
|
|
// listStr.Add(new SqlParameter("@UnitId2", this.drpUnit.SelectedValue));
|
|
//}
|
|
strSql += " ORDER BY tba.StartDate ";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
// var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = tb;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#region 导出
|
|
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("异常项目" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
this.Grid1.PageSize = Grid1.RecordCount;
|
|
this.BindGrid();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 单位校验
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid2()
|
|
{
|
|
string strSql = @"SELECT UnitId,UnitCode,UnitName,CollCropCode,MasterAdOrgCode,MasterAdOrgName,
|
|
CASE
|
|
--WHEN MasterAdOrgCode IS NULL OR LTRIM(RTRIM(MasterAdOrgCode)) = '' THEN '未关联主数据组织'
|
|
WHEN CollCropCode IS NULL OR LTRIM(RTRIM(CollCropCode)) = '' THEN '社会统一信用代码为空'
|
|
WHEN LEN(LTRIM(RTRIM(CollCropCode))) <> 18 THEN '社会统一信用代码不正确'
|
|
END AS Memo
|
|
FROM Base_Unit
|
|
WHERE (MasterAdOrgCode IS NULL OR LEN(LTRIM(RTRIM(ISNULL(CollCropCode,'')))) <> 18) ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.txtUnitName.Text.Trim()))
|
|
{
|
|
strSql += " AND (UnitName LIKE @UnitName OR MasterAdOrgName LIKE @UnitName) ";
|
|
listStr.Add(new SqlParameter("@UnitName", "%" + this.txtUnitName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtMasterAdOrgCode.Text.Trim()))
|
|
{
|
|
strSql += " AND MasterAdOrgCode LIKE @MasterAdOrgCode ";
|
|
listStr.Add(new SqlParameter("@MasterAdOrgCode", "%" + this.txtMasterAdOrgCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtCollCropCode.Text.Trim()))
|
|
{
|
|
strSql += " AND CollCropCode LIKE @CollCropCode ";
|
|
listStr.Add(new SqlParameter("@CollCropCode", "%" + this.txtCollCropCode.Text.Trim() + "%"));
|
|
}
|
|
strSql += " ORDER BY UnitName ";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid2.RecordCount = tb.Rows.Count;
|
|
// var table = this.GetPagedDataTable(Grid2, tb);
|
|
Grid2.DataSource = tb;
|
|
Grid2.DataBind();
|
|
}
|
|
|
|
protected void TextBox2_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid2();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid2();
|
|
}
|
|
protected void Grid2_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid2();
|
|
}
|
|
|
|
#region 导出
|
|
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut2_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("异常单位" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
this.Grid2.PageSize = Grid2.RecordCount;
|
|
this.BindGrid2();
|
|
Response.Write(GetGridTableHtml(Grid2));
|
|
Response.End();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 用户校验
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid3()
|
|
{
|
|
string strSql = @"SELECT UserID,UserName,IdentityCard,tba.Telephone,tbb.UnitName,
|
|
CASE
|
|
WHEN IdentityCard IS NULL OR LTRIM(RTRIM(IdentityCard)) = '' THEN '身份证号码为空'
|
|
WHEN LEN(LTRIM(RTRIM(IdentityCard))) <> 18 THEN '身份证号码不正确'
|
|
END AS Memo
|
|
FROM Sys_User AS tba LEFT JOIN Base_Unit AS tbb ON tbb.UnitId=tba.UnitId
|
|
WHERE LEN(LTRIM(RTRIM(ISNULL(IdentityCard,'')))) <> 18 AND UserName NOT IN ('JT','系统管理员') ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.txtUserName.Text.Trim()))
|
|
{
|
|
strSql += " AND UserName LIKE @UserName ";
|
|
listStr.Add(new SqlParameter("@UserName", "%" + this.txtUserName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtIdentityCard.Text.Trim()))
|
|
{
|
|
strSql += " AND IdentityCard LIKE @IdentityCard ";
|
|
listStr.Add(new SqlParameter("@IdentityCard", "%" + this.txtIdentityCard.Text.Trim() + "%"));
|
|
}
|
|
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND tba.UnitId = @UnitId2";
|
|
listStr.Add(new SqlParameter("@UnitId2", this.drpUnit.SelectedValue));
|
|
}
|
|
strSql += " ORDER BY UnitName,UserName ";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid3.RecordCount = tb.Rows.Count;
|
|
// var table = this.GetPagedDataTable(Grid3, tb);
|
|
Grid3.DataSource = tb;
|
|
Grid3.DataBind();
|
|
}
|
|
|
|
protected void TextBox3_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid3();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid3();
|
|
}
|
|
protected void Grid3_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid3();
|
|
}
|
|
|
|
#region 导出
|
|
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut3_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("异常用户" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
this.Grid3.PageSize = Grid3.RecordCount;
|
|
this.BindGrid3();
|
|
Response.Write(GetGridTableHtml(Grid3));
|
|
Response.End();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 项目人员校验
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid4()
|
|
{
|
|
string strSql = @"SELECT PersonId,PersonName,tba.ProjectId,tbc.ProjectName,tba.UnitId,tbb.UnitName,tba.IdcardType,tba.IdentityCard,tba.Telephone,
|
|
CASE
|
|
WHEN IdentityCard IS NULL OR LTRIM(RTRIM(IdentityCard)) = '' THEN '证件号码为空'
|
|
WHEN tba.IdcardType='SHENFEN_ZHENGJIAN' AND LEN(LTRIM(RTRIM(IdentityCard))) <> 18 THEN '身份证号码不正确'
|
|
WHEN LEN(LTRIM(RTRIM(IdentityCard))) < 9 THEN '证件号码不正确'
|
|
END AS Memo
|
|
FROM SitePerson_Person AS tba
|
|
LEFT JOIN Base_Unit AS tbb ON tbb.UnitId=tba.UnitId
|
|
LEFT JOIN Base_Project AS tbc ON tbc.ProjectId=tba.ProjectId
|
|
WHERE ((tba.IdcardType='SHENFEN_ZHENGJIAN' AND LEN(LTRIM(RTRIM(ISNULL(IdentityCard,'')))) <> 18)OR LEN(LTRIM(RTRIM(ISNULL(IdentityCard,'')))) < 9)
|
|
AND tba.IsUsed=1 AND ISNULL(tbc.isDelete,0)=0 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.txtProName.Text.Trim()))
|
|
{
|
|
strSql += " AND ProjectName LIKE @ProjectName ";
|
|
listStr.Add(new SqlParameter("@ProjectName", "%" + this.txtProName.Text.Trim() + "%"));
|
|
}
|
|
if (this.drpPersonUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND tba.UnitId = @UnitId2";
|
|
listStr.Add(new SqlParameter("@UnitId2", this.drpPersonUnit.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtIdentityCardNo.Text.Trim()))
|
|
{
|
|
strSql += " AND IdentityCard LIKE @IdentityCard ";
|
|
listStr.Add(new SqlParameter("@IdentityCard", "%" + this.txtIdentityCardNo.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim()))
|
|
{
|
|
strSql += " AND PersonName LIKE @PersonName ";
|
|
listStr.Add(new SqlParameter("@PersonName", "%" + this.txtPersonName.Text.Trim() + "%"));
|
|
}
|
|
strSql += " ORDER BY tbc.ProjectName,tbb.UnitName,PersonName ";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid4.RecordCount = tb.Rows.Count;
|
|
// var table = this.GetPagedDataTable(Grid4, tb);
|
|
Grid4.DataSource = tb;
|
|
Grid4.DataBind();
|
|
}
|
|
|
|
protected void TextBox4_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid4();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid4_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid4();
|
|
}
|
|
protected void Grid4_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid4();
|
|
}
|
|
|
|
#region 导出
|
|
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut4_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("异常项目人员" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
this.Grid4.PageSize = Grid4.RecordCount;
|
|
this.BindGrid4();
|
|
Response.Write(GetGridTableHtml(Grid4));
|
|
Response.End();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 导出方法
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
public static string GetGridTableHtml(Grid grid)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
sb.Append("<tr>");
|
|
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
sb.AppendFormat("<td x:str>{0}</td>", column.HeaderText);
|
|
}
|
|
sb.Append("</tr>");
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfNumber")
|
|
{
|
|
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "tfPageIndex")
|
|
{
|
|
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "tfPageNo")
|
|
{
|
|
html = (row.FindControl("lblPageNo") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "tfPageNum")
|
|
{
|
|
html = (row.FindControl("lblPageNum") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "tfNum")
|
|
{
|
|
html = (row.FindControl("lblNum") as AspNet.Label).Text;
|
|
}
|
|
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
|
// sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
} |