You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
5.6 KiB
179 lines
5.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Web;
|
|
using System.Web.Configuration;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using CK.SCP.Models.AppBoxEntity;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Utils;
|
|
using CK.SCP.Controller;
|
|
using FineUI;
|
|
using WebGrease.Css.Extensions;
|
|
|
|
namespace SCP.BasicData
|
|
{
|
|
public partial class PublicData : PageBase
|
|
{
|
|
public List<TB_PublicData> _list;
|
|
public int num;
|
|
public TB_PublicData ModelPublicData;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CheckPowerWithButton("CoreMAdd", btnadd);
|
|
|
|
|
|
this.btnadd.OnClientClick = Window1.GetShowReference("../BasicData/PublicDataEdit.aspx", "新增");
|
|
|
|
|
|
BindData();
|
|
}
|
|
}
|
|
public void BindData()
|
|
{
|
|
Expression<Func<TB_PublicData, dynamic>> select = c => c;
|
|
|
|
Expression<Func<TB_PublicData, bool>> where = c => true;
|
|
|
|
Expression<Func<TB_PublicData, int>> order = c => c.ID;
|
|
|
|
int total;
|
|
|
|
var list = EntitiesHelper.GetPagedDataDesc(SCPDB,
|
|
select,
|
|
where,
|
|
order,
|
|
Grid1.PageIndex,
|
|
Grid1.PageSize,
|
|
out total).ToList();
|
|
Grid1.RecordCount = total;
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
|
|
protected void btnClose_OnClick(object sender, EventArgs e)
|
|
{
|
|
gp1.Hidden = true;
|
|
}
|
|
//查寻
|
|
protected void Button1_OnClick(object sender, EventArgs e)
|
|
{
|
|
// _list = SearchData(out num);
|
|
Grid1.RecordCount = num;
|
|
Grid1.DataSource = _list;
|
|
Grid1.DataBind();
|
|
}
|
|
public List<V_INFO> SearchData(out int num)
|
|
{
|
|
Expression<Func<V_INFO, bool>> where = c => true;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txtTitle.Text))
|
|
{
|
|
where = where.And(p => p.Title.Contains(txtTitle.Text));
|
|
}
|
|
if (!string.IsNullOrEmpty(txtInfoType.Text))
|
|
{
|
|
where = where.And(p => p.InfoType.Contains(txtInfoType.Text));
|
|
}
|
|
if (!string.IsNullOrEmpty(txtSupplierName.Text))
|
|
{
|
|
where = where.And(p => p.VendName.Contains(txtSupplierName.Text));
|
|
}
|
|
if (!string.IsNullOrEmpty(txtUserName.Text))
|
|
{
|
|
where = where.And(p => p.UserName.Contains(txtUserName.Text));
|
|
}
|
|
List<V_INFO> list = SCPDB.V_INFO.Where(where.Compile()).ToList();
|
|
num = SCPDB.V_INFO.Where(where.Compile()).Count();
|
|
return list;
|
|
}
|
|
|
|
protected void btnShow_OnClick(object sender, EventArgs e)
|
|
{
|
|
gp1.Hidden = false;
|
|
}
|
|
|
|
|
|
//删除
|
|
protected void btnDelete_OnClick(object sender, EventArgs e)
|
|
{
|
|
string name = GetIdentityName();
|
|
ResolveDeleteButtonForGrid(btnDelete, Grid1);
|
|
|
|
int id = GetSelectedDataKeyID(Grid1);
|
|
ModelPublicData = PublicDataController.GetlistByBillNo(id);
|
|
if (ModelPublicData != null)
|
|
{
|
|
if (ModelPublicData.UserName != name)
|
|
{
|
|
// CheckPowerFailWithAlert1();
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("只能删除自己发布的信息"));
|
|
return;
|
|
}
|
|
}
|
|
PublicDataController.DeleteById(id);
|
|
PageContext.Refresh();
|
|
|
|
}
|
|
|
|
|
|
//不用的
|
|
protected void Grid1_OnRowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
object[] values = Grid1.DataKeys[e.RowIndex];
|
|
int userID = Convert.ToInt32(values[0]);
|
|
|
|
if (e.ColumnID == "Edit")
|
|
{
|
|
// 在操作之前进行权限检查
|
|
if (!CheckPower("用户"))
|
|
{
|
|
CheckPowerFailWithAlert1();
|
|
return;
|
|
}
|
|
|
|
int roleID = GetSelectedDataKeyID(Grid1);
|
|
|
|
Role role = DB.Roles.Include(r => r.Users)
|
|
.Where(r => r.ID == roleID)
|
|
.FirstOrDefault();
|
|
|
|
User tobeRemovedUser = role.Users.Where(u => u.ID == userID).FirstOrDefault();
|
|
if (tobeRemovedUser != null)
|
|
{
|
|
role.Users.Remove(tobeRemovedUser);
|
|
DB.SaveChanges();
|
|
}
|
|
|
|
// BindGrid2();
|
|
Grid1.RecordCount = num;
|
|
Grid1.DataSource = _list;
|
|
Grid1.DataBind();
|
|
}
|
|
}
|
|
|
|
protected void btnEdit_OnClick(object sender, EventArgs e)
|
|
{
|
|
|
|
string roleID = GetSelectedDataKey(Grid1, 0);
|
|
string name = GetIdentityName();
|
|
int id = Convert.ToInt32(roleID);
|
|
TB_PublicData modelPublicData = PublicDataController.GetlistByBillNo(id);
|
|
if (modelPublicData.UserName != name)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("只能修改自己发布的信息"));
|
|
return;
|
|
}
|
|
string url = String.Format("../BasicData/PublicDataEdit.aspx?ID={0}", roleID);
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
|
|
}
|
|
}
|
|
}
|