227 lines
6.9 KiB
C#
227 lines
6.9 KiB
C#
namespace FineUIPro.Web.InformationProject
|
|
{
|
|
using BLL;
|
|
using Org.BouncyCastle.Asn1.Cms;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
public partial class ConstructionLog : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("ConstructionLogEdit.aspx") + "return false;";
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string personId = string.Empty;
|
|
if (this.rdlType.SelectedValue == "0")
|
|
{
|
|
personId = this.CurrUser.UserId;
|
|
}
|
|
var getData = ConstructionLogNewService.getListData(this.CurrUser.LoginProjectId, null, personId, this.txtName.Text, Funs.GetNewDateTime(this.txtStartDate.Text)
|
|
, Funs.GetNewDateTime(this.txtEndDate.Text), Grid1);
|
|
Grid1.RecordCount = ConstructionLogNewService.count;
|
|
Grid1.DataSource = getData;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.rdlType.SelectedValue == "1")
|
|
{
|
|
this.txtName.Hidden = false;
|
|
}
|
|
else
|
|
{
|
|
this.txtName.Hidden = true;
|
|
}
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
var buttonList = CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ConstructionLogMenuId1);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(Const.BtnModify))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#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)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
if (judgementDelete(rowID, false))
|
|
{
|
|
var getD = ConstructionLogNewService.GetConstructionLogById(rowID);
|
|
if (getD != null)
|
|
{
|
|
BLL.ConstructionLogNewService.DeleteConstructionLogById(rowID);
|
|
}
|
|
}
|
|
}
|
|
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!");
|
|
}
|
|
}
|
|
#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)
|
|
{
|
|
this.Grid1.PageSize = Funs.GetNewIntOrZero(this.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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string Id = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionLogEdit.aspx?ConstructionLogId={0}", Id, "编辑 - ")));
|
|
}
|
|
|
|
#region 判断是否可删除
|
|
/// <summary>
|
|
/// 判断是否可以删除
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private bool judgementDelete(string id, bool isShow)
|
|
{
|
|
string content = string.Empty;
|
|
//if (Funs.DB.Project_ProjectConstructionLog.FirstOrDefault(x => x.ConstructionLogId == id) != null)
|
|
//{
|
|
// content = "该用户已在【项目用户】中使用,不能删除!";
|
|
//}
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (isShow)
|
|
{
|
|
Alert.ShowInTop(content);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |