272 lines
9.9 KiB
C#
272 lines
9.9 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.QualityActivity.QCManage
|
|
{
|
|
public partial class QCGroupRegistration : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
|
|
this.ucTree.UnitId = this.CurrUser.UnitId;
|
|
this.ucTree.ProjectId = this.ProjectId;
|
|
// if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId) )
|
|
// {
|
|
this.panelLeftRegion.Hidden = true;
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
// }
|
|
btnNew.OnClientClick = Window1.GetShowReference("QCGroupRegistrationEdit.aspx") + "return false;";
|
|
BindGrid();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 公司级树加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void changeTree(object sender, EventArgs e)
|
|
{
|
|
this.ProjectId = this.ucTree.ProjectId;
|
|
this.GetButtonPower();
|
|
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
btnNew.Hidden = true;
|
|
}
|
|
this.BindGrid();
|
|
}
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
|
|
public void BindGrid()
|
|
{
|
|
// if (string.IsNullOrEmpty(this.ProjectId))
|
|
// {
|
|
// return;
|
|
// }
|
|
DataTable tb = ChecklistData();
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
protected DataTable ChecklistData()
|
|
{
|
|
string strSql =
|
|
@"select C.*,p.UserName,u.UnitName, (case C.AwardType when '1' then '创优' when '2' then 'QC' end) as AwardTypeName,
|
|
(case C.AwardLevel when '1' then '鲁班奖'
|
|
when '2' then '国优奖'
|
|
when '3' then '省部级'
|
|
when '4' then '市级'
|
|
when '5' then '省部级'
|
|
when '6' then '集团级'
|
|
when '7' then '企业级' end) as AwardLevelName
|
|
from [dbo].[QCManage_QCGroupRegistration] C
|
|
left join Sys_User p on p.UserId=C.CompileMan
|
|
left join Base_Unit u on u.UnitId = c.UnitId
|
|
where 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
// strSql += " AND C.ProjectId = @ProjectId";
|
|
// listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return tb;
|
|
}
|
|
/// <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 Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
//右键编辑
|
|
protected void btnMenuModify_Click(object sender, EventArgs e)
|
|
{
|
|
EditData();
|
|
}
|
|
//双击编辑
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
EditData();
|
|
}
|
|
//分页
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QCGroupRegistrationEdit.aspx?QCGroupRegistrationId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
|
|
}
|
|
//右键查看
|
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QCGroupRegistrationView.aspx?QCGroupRegistrationId={0}", Grid1.SelectedRowID, "查看 - ")));
|
|
}
|
|
//右键删除
|
|
protected void btnMenuDel_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var QCGroupRegistration = BLL.QCManage_QCGroupRegistrationService.GetQCGroupRegistrationByQCGroupRegistrationId(rowID);
|
|
|
|
if (QCGroupRegistration != null)
|
|
{
|
|
if (QCGroupRegistration.IsUpdate == true)
|
|
{
|
|
var returndata = Project_CQMSDataService.DeleteQCRegistrationData(rowID);
|
|
if (returndata.code == 1)
|
|
{
|
|
////删除附件表
|
|
BLL.CommonService.DeleteAttachFileById(rowID);
|
|
BLL.QCManage_QCGroupRegistrationService.DeleteQCGroupRegistrationById(rowID);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("记录已上报集团,集团删除失败,无法删除本地数据!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
////删除附件表
|
|
BLL.CommonService.DeleteAttachFileById(rowID);
|
|
BLL.QCManage_QCGroupRegistrationService.DeleteQCGroupRegistrationById(rowID);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 搜索
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
/// <summary>
|
|
/// 重置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnRset_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProjectQCGroupRegistrationListMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuModify.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDel.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
object[] keys = Grid1.DataKeys[e.RowIndex];
|
|
string fileId = string.Empty;
|
|
if (keys == null)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
fileId = keys[0].ToString();
|
|
}
|
|
if (e.CommandName.Equals("download"))
|
|
{
|
|
string menuId = Const.ProjectQCGroupRegistrationListMenuId;
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
|
|
String.Format("../../../AttachFile/webuploader.aspx?type=-1&source=1&toKeyId={0}&path=FileUpload/QCGroupRegistration&menuId={1}", fileId, menuId)));
|
|
}
|
|
}
|
|
}
|
|
} |