154 lines
5.4 KiB
C#
154 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.WeldMat.Stock
|
|
{
|
|
public partial class ShowWeldInfo : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
this.drpWeldType.DataTextField = "WeldTypeName";
|
|
this.drpWeldType.DataValueField = "WeldTypeId";
|
|
this.drpWeldType.DataSource = BLL.WeldTypeService.GetWeldTypeList();
|
|
this.drpWeldType.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpWeldType);
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT WeldInfo.WeldId, WeldInfo.WeldCode, WeldInfo.WeldName, WeldInfo.WeldSpec,WeldInfo.WeldTypeId,
|
|
WeldType.WeldTypeName,WeldType.WeldUnit,v.StockAmount
|
|
FROM Weld_WeldInfo AS WeldInfo
|
|
LEFT JOIN Weld_WeldType AS WeldType ON WeldType.WeldTypeId =WeldInfo.WeldTypeId
|
|
LEFT JOIN (SELECT WeldId, sum(ISNULL(Amount,0)-ISNULL(UsingAmount,0)) AS StockAmount
|
|
FROM dbo.Weld_StockIn
|
|
WHERE (ISNULL(Amount,0)-ISNULL(UsingAmount,0))>0
|
|
GROUP BY WeldId) v ON v.WeldId = WeldInfo.WeldId
|
|
WHERE 1=1";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (drpWeldType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND WeldInfo.WeldTypeId = @WeldTypeId";
|
|
listStr.Add(new SqlParameter("@WeldTypeId", drpWeldType.SelectedValue));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
|
{
|
|
if (this.txtName.Text.Contains("*"))
|
|
{
|
|
string[] weldNames = this.txtName.Text.Trim().Split('*');
|
|
strSql += " AND WeldName LIKE @WeldName1 AND WeldName LIKE @WeldName2 ";
|
|
listStr.Add(new SqlParameter("@WeldName1", "%" + weldNames[0] + "%"));
|
|
listStr.Add(new SqlParameter("@WeldName2", "%" + weldNames[1] + "%"));
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND WeldName LIKE @WeldName";
|
|
listStr.Add(new SqlParameter("@WeldName", "%" + this.txtName.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 Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <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 Grid1_FilterChange(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
protected void drpWeldType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region Grid双击事件
|
|
/// <summary>
|
|
/// Grid双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
string itemsString = this.Grid1.SelectedRowID;
|
|
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString)
|
|
+ ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
}
|
|
} |