328 lines
11 KiB
C#
328 lines
11 KiB
C#
|
|
using BLL;
|
||
|
|
using Newtonsoft.Json;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Data;
|
||
|
|
using System.Data.SqlClient;
|
||
|
|
using System.Linq;
|
||
|
|
|
||
|
|
namespace FineUIPro.Web.SanKu
|
||
|
|
{
|
||
|
|
public partial class AdminPenalty : PageBase
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 加载页面
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void Page_Load(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
if (!IsPostBack)
|
||
|
|
{
|
||
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
||
|
|
////权限按钮方法
|
||
|
|
this.GetButtonPower();
|
||
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
||
|
|
{
|
||
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
|
|
// 绑定表格
|
||
|
|
this.BindGrid();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 绑定数据
|
||
|
|
/// </summary>
|
||
|
|
private void BindGrid()
|
||
|
|
{
|
||
|
|
string strSql = @"SELECT tba.PENALTY_ID,tba.RECORD_ID,tba.PROJECT_CODE,tba.PROJECT_NAME,tba.SUBCONTRACTOR_ID,tba.SUBCONTRACTOR_NAME,tba.PENALTY_DATE,tba.PENALTY_TYPE,tba.PENALTY_CONTENT,tba.PENALTY_STATUS,tba.PENALTY_AMOUNT,tba.PENALTY_AUTHORITY,tba.ReportDate
|
||
|
|
FROM SANKU_ADMIN_PENALTY AS tba WITH(NOLOCK)
|
||
|
|
WHERE 1=1 ";
|
||
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
|
|
if (!string.IsNullOrEmpty(this.txtProjectName.Text.Trim()))
|
||
|
|
{
|
||
|
|
strSql += " AND tba.PROJECT_NAME LIKE @ProjectName";
|
||
|
|
listStr.Add(new SqlParameter("@ProjectName", "%" + this.txtProjectName.Text.Trim() + "%"));
|
||
|
|
}
|
||
|
|
if (!string.IsNullOrEmpty(this.txtContent.Text.Trim()))
|
||
|
|
{
|
||
|
|
strSql += " AND tba.PENALTY_CONTENT LIKE @Content";
|
||
|
|
listStr.Add(new SqlParameter("@Content", "%" + this.txtContent.Text.Trim() + "%"));
|
||
|
|
}
|
||
|
|
if (this.rbIsReport.SelectedValue == "0")
|
||
|
|
{//未上报
|
||
|
|
strSql += " AND tba.ReportDate IS NULL";
|
||
|
|
}
|
||
|
|
else if (this.rbIsReport.SelectedValue == "1")
|
||
|
|
{//已上报
|
||
|
|
strSql += " AND tba.ReportDate IS NOT NULL";
|
||
|
|
}
|
||
|
|
string type = this.drpPenaltyType.SelectedValue.Trim();
|
||
|
|
string status = this.drpPenaltyStatus.SelectedValue.Trim();
|
||
|
|
if (!string.IsNullOrWhiteSpace(type))
|
||
|
|
{
|
||
|
|
strSql += " AND PenaltyType = @Type";
|
||
|
|
listStr.Add(new SqlParameter("@Type", type));
|
||
|
|
}
|
||
|
|
if (!string.IsNullOrWhiteSpace(status))
|
||
|
|
{
|
||
|
|
strSql += " AND PenaltyStatus = @Status";
|
||
|
|
listStr.Add(new SqlParameter("@Status", status));
|
||
|
|
}
|
||
|
|
|
||
|
|
SqlParameter[] parameter = listStr.ToArray();
|
||
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
|
|
||
|
|
Grid1.RecordCount = tb.Rows.Count;
|
||
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
||
|
|
Grid1.DataSource = table;
|
||
|
|
Grid1.DataBind();
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 查询
|
||
|
|
/// <summary>
|
||
|
|
/// 查询
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
this.BindGrid();
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 数据收集、清空
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 数据收集
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void btnCollect_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
DataOp("1");
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 数据清空
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void btnDelAll_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
DataOp("0");
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 数据操作
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="op"></param>
|
||
|
|
private void DataOp(string op)
|
||
|
|
{
|
||
|
|
var db = Funs.DB;
|
||
|
|
string resultStr = string.Empty;
|
||
|
|
string msg = string.Empty;
|
||
|
|
try
|
||
|
|
{
|
||
|
|
var result = Funs.DB.SP_SANKU_DATA_INIT("SANKU_ADMIN_PENALTY", int.Parse(op));
|
||
|
|
resultStr = "成功";
|
||
|
|
msg = $"{(op == "1" ? "收集" : "清空所有")}行政处罚数据";
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
resultStr = "失败";
|
||
|
|
msg = JsonConvert.SerializeObject(ex);
|
||
|
|
}
|
||
|
|
|
||
|
|
//记录上报结果日志
|
||
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
||
|
|
newModel.OPTYPE = "数据操作";
|
||
|
|
newModel.CONTENT = $"{(op == "1" ? "收集" : "清空所有")}行政处罚数据";
|
||
|
|
newModel.RESULT = resultStr;
|
||
|
|
newModel.DETAIL = msg;
|
||
|
|
newModel.OPERATOR = this.CurrUser.UserName;
|
||
|
|
newModel.CREATE_TIME = DateTime.Now;
|
||
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
||
|
|
db.SubmitChanges();
|
||
|
|
|
||
|
|
if (resultStr == "成功")
|
||
|
|
{
|
||
|
|
this.BindGrid();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 汇总上报
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 汇总上报
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void btnReport_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
string message = string.Empty;
|
||
|
|
string code = SanKuDataSummaryReportService.ReportAdminPenaltyRecords(this.CurrUser.UserName, ref message);
|
||
|
|
if (code == "1")
|
||
|
|
{
|
||
|
|
this.BindGrid();
|
||
|
|
ShowNotify(message, MessageBoxIcon.Success);
|
||
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Alert.ShowInParent(message, MessageBoxIcon.Error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#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 = this.Grid1.RecordCount;
|
||
|
|
this.BindGrid();
|
||
|
|
Response.Write(GetGridTableHtml(Grid1));
|
||
|
|
Response.End();
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 获取按钮权限
|
||
|
|
/// <summary>
|
||
|
|
/// 获取按钮权限
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="button"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private void GetButtonPower()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 删除数据
|
||
|
|
/// <summary>
|
||
|
|
/// 右键删除事件
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
this.DeleteData();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 删除方法
|
||
|
|
/// </summary>
|
||
|
|
private void DeleteData()
|
||
|
|
{
|
||
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||
|
|
{
|
||
|
|
var db = Funs.DB;
|
||
|
|
string strShowNotify = string.Empty;
|
||
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
|
|
{
|
||
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
|
|
var item = db.SANKU_ADMIN_PENALTY.Where(x => x.PENALTY_ID == long.Parse(rowID)).FirstOrDefault();
|
||
|
|
if (item != null)
|
||
|
|
{
|
||
|
|
if (item.ReportDate != null)
|
||
|
|
{
|
||
|
|
ShowNotify("数据已上报,无法删除!", MessageBoxIcon.Warning);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db.SANKU_ADMIN_PENALTY.DeleteOnSubmit(item);
|
||
|
|
db.SubmitChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
BindGrid();
|
||
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 分页
|
||
|
|
/// <summary>
|
||
|
|
/// 分页
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
|
|
{
|
||
|
|
BindGrid();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 分页显示条数下拉框
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
|
|
BindGrid();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 排序
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
||
|
|
{
|
||
|
|
BindGrid();
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Grid行双击事件
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
|
|
{
|
||
|
|
//this.EditData();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 右键编辑事件
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sender"></param>
|
||
|
|
/// <param name="e"></param>
|
||
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
//this.EditData();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
|
|
{
|
||
|
|
BindGrid();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void MenuView_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
//string url = "AccidentRecordView.aspx?Id={0}";
|
||
|
|
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format(url, Id, "操作 - ")));
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|