249 lines
9.3 KiB
C#
249 lines
9.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.common.BaseInfo
|
|
{
|
|
public partial class ProjectWeldMat : 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>
|
|
private void BindGrid2(string weldId)
|
|
{
|
|
string strSql = @" SELECT StockIn.StockInId, StockIn.WeldId,StockIn.Warrantybook,supplier.SupplierName,
|
|
WeldInfo.WeldCode,WeldInfo.WeldName,WeldInfo.WeldSpec,WeldInfo.WeldTypeId,
|
|
(CASE StockIn.IsReview WHEN 1 THEN '是' WHEN 0 THEN '否' ELSE '' END) AS IsReview,
|
|
WeldType.WeldTypeName,(CASE WHEN weldType.WeldTypeName='焊条' THEN '根' ELSE 'Kg' END) AS WeldUnit,
|
|
(StockIn.Amount-ISNULL(StockIn.UsingAmount,0)) AS StockAmount,
|
|
StockIn.AttachUrl
|
|
FROM Weld_StockIn AS StockIn
|
|
LEFT JOIN Weld_WeldInfo AS WeldInfo ON WeldInfo.WeldId = StockIn.WeldId
|
|
LEFT JOIN Weld_WeldType AS WeldType ON WeldType.WeldTypeId = WeldInfo.WeldTypeId
|
|
LEFT JOIN dbo.Weld_Supplier supplier ON supplier.SupplierId=StockIn.SupplierId
|
|
WHERE (StockIn.Amount-ISNULL(StockIn.UsingAmount,0))>0 AND StockIn.WeldId=@WeldId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (weldId != null)
|
|
{
|
|
listStr.Add(new SqlParameter("@WeldId", weldId));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@WeldId", null));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
Grid2.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetSortTable(Grid2, tb);
|
|
|
|
Grid2.DataSource = table;
|
|
Grid2.DataBind();
|
|
|
|
for (int i = 0; i < Grid2.Rows.Count; i++)
|
|
{
|
|
System.Web.UI.WebControls.LinkButton lbtnUrl = ((System.Web.UI.WebControls.LinkButton)(this.Grid2.Rows[i].FindControl("lbtnUrl")));
|
|
string url = lbtnUrl.CommandArgument.ToString();
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
url = url.Replace('\\', '/');
|
|
lbtnUrl.Text = BLL.UploadAttachmentService.ShowAttachment("../../", url);
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
protected void Grid1_RowSelect(object sender, GridRowSelectEventArgs e)
|
|
{
|
|
string weldId = this.Grid1.SelectedRowID;
|
|
BindGrid2(weldId);
|
|
}
|
|
|
|
#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
|
|
|
|
#region 分页、排序
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid2.PageIndex = e.NewPageIndex;
|
|
BindGrid2(this.Grid1.SelectedRowID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize2_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue);
|
|
BindGrid2(this.Grid1.SelectedRowID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid2_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
Grid2.SortDirection = e.SortDirection;
|
|
Grid2.SortField = e.SortField;
|
|
BindGrid2(this.Grid1.SelectedRowID);
|
|
}
|
|
#endregion
|
|
}
|
|
} |