221 lines
8.2 KiB
C#
221 lines
8.2 KiB
C#
namespace FineUIPro.Web.HJGL.MaterialManage
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using BLL;
|
|
|
|
public partial class EMaterialRegist : PageBase
|
|
{
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
else if (GetRequestEventArgument() == "reloadGrid")
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT EMaterialRegist.EMaterialRegistId,EMaterialRegist.EMaterialRegistCode,EMaterialRegist.EMaterialRegistDate,EMaterialRegist.DeliveryMan,EMaterialRegist.UnitName,EMaterialRegist.CompileDate,CompileManUser.UserName AS CompileManName,Project.ProjectId,Project.ProjectName"
|
|
+ @" FROM HJGL_EMaterialRegist AS EMaterialRegist"
|
|
+ @" LEFT JOIN Sys_User AS CompileManUser ON EMaterialRegist.CompileMan=CompileManUser.UserId"
|
|
+ @" LEFT JOIN Base_Project AS Project ON EMaterialRegist.ProjectId=Project.ProjectId"
|
|
+ @" WHERE EMaterialRegist.ProjectId= @ProjectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
if (!string.IsNullOrEmpty(this.txtEMaterialRegistCode.Text.Trim()))
|
|
{
|
|
strSql += " AND EMaterialRegist.EMaterialRegistCode LIKE @EMaterialRegistCode";
|
|
listStr.Add(new SqlParameter("@EMaterialRegistCode", "%" + this.txtEMaterialRegistCode.Text.Trim() + "%"));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
|
|
{
|
|
strSql += " AND EMaterialRegist.EMaterialRegistDate >= @EMaterialRegistDate";
|
|
listStr.Add(new SqlParameter("@EMaterialRegistDate", Funs.GetNewDateTime(this.txtStartTime.Text.Trim())));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
|
|
{
|
|
strSql += " AND EMaterialRegist.EMaterialRegistDate <= @EMaterialRegistDate";
|
|
listStr.Add(new SqlParameter("@EMaterialRegistDate", Funs.GetNewDateTime(this.txtEndTime.Text.Trim())));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 增加材料到货登记及验收记录
|
|
/// <summary>
|
|
/// 增加材料到货登记及验收记录
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_EMaterialRegistMenuId, Const.BtnAdd))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("EMaterialRegistEdit.aspx?EMaterialRegistId={0}", string.Empty, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#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 (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_EMaterialRegistMenuId, Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string EMaterialRegistId = Grid1.DataKeys[rowIndex][0].ToString();
|
|
BLL.HJGL_EMaterialRegistService.DeleteEMaterialRegistItem(this.CurrUser.LoginProjectId, EMaterialRegistId);
|
|
BLL.HJGL_EMaterialRegistService.DeleteEMaterialRegist(EMaterialRegistId);
|
|
this.BindGrid();
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊丝烘烤记录!");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据编辑事件
|
|
/// <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 (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_EMaterialRegistMenuId, Const.BtnSave))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("EMaterialRegistEdit.aspx?EMaterialRegistId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
}
|
|
} |