using System;
using System.Data;
using BLL;
namespace FineUIPro.Web.common.ProjectSet
{
public partial class ProjectPicture : PageBase
{
#region 加载
///
/// 加载页面
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
this.BindGrid();
}
}
#region 绑定数据
///
/// 绑定数据
///
private void BindGrid()
{
string strSql = @"SELECT * FROM dbo.Project_ProjectPicture";
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
///
/// 改变索引事件
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
///
/// 分页下拉选择事件
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
///
/// 关闭弹出窗口
///
///
///
protected void Window1_Close(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#endregion
#region 增加按钮事件
///
/// 增加按钮事件
///
///
///
protected void btnNew_Click(object sender, EventArgs e)
{
if (GetButtonPower(Const.BtnAdd))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPictureEdit.aspx", "新增 - ")));
}
else
{
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
}
#endregion
#region 编辑
///
/// 双击事件
///
///
///
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditData();
}
///
/// 右键编辑事件
///
///
///
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
this.EditData();
}
///
/// 编辑数据方法
///
private void EditData()
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning);
return;
}
////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
if (GetButtonPower(Const.BtnModify))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPictureEdit.aspx?ProjectPictureId={0}", Grid1.SelectedRowID, "编辑 - ")));
}
else if (GetButtonPower(Const.BtnSee))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPictureView.aspx?ProjectPictureId={0}", Grid1.SelectedRowID, "查看 - ")));
}
else
{
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
}
#endregion
#region 删除
///
/// 右键删除事件
///
///
///
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (GetButtonPower(Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
string strShowNotify = string.Empty;
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var projectPicture = BLL.Project_ProjectPictureService.GetProjectPictureById(rowID);
if (projectPicture != null)
{
string cont = judgementDelete(rowID);
if (string.IsNullOrEmpty(cont))
{
BLL.Project_ProjectPictureService.DeleteProjectPictureById(rowID);
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectPictureMenuId, Const.BtnDelete, rowID);
}
else
{
strShowNotify += Resources.Lan.ProjectPicture + ":" + projectPicture.ProjectPictureName + cont;
}
}
}
BindGrid();
if (!string.IsNullOrEmpty(strShowNotify))
{
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
}
else
{
ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success);
}
}
}
else
{
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
}
#region 判断是否可删除
///
/// 判断是否可以删除
///
///
private string judgementDelete(string id)
{
string content = string.Empty;
//if (Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.UserId == id) != null)
//{
// content += "已在【项目用户】中使用,不能删除!";
//}
return content;
}
#endregion
#endregion
#region 查询
///
/// 查询
///
///
///
//protected void btnQuery_Click(object sender, EventArgs e)
//{
// this.BindGrid();
//}
#endregion
#region 查看按钮
///
/// 查看按钮
///
///
///
protected void btnView_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPictureView.aspx?ProjectPictureId={0}", Grid1.SelectedRowID, "查看 - ")));
}
#endregion
#region 格式化字符串
///
/// 格式化是否显示
///
///
///
protected string ConvertIsShow(object isShow)
{
if (isShow != null)
{
if (isShow.ToString() == "True")
{
return Resources.Lan.Yes;
}
else
{
return Resources.Lan.No;
}
}
return null;
}
#endregion
#region 获取按钮权限
///
/// 获取按钮权限
///
///
///
private bool GetButtonPower(string button)
{
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectPictureMenuId, button);
}
#endregion
}
}