198 lines
6.6 KiB
C#
198 lines
6.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.WeldMat.UsingPlan
|
|
{
|
|
public partial class ShowPlanWeld : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
|
|
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 weld.WeldId, weld.WeldCode, weld.WeldName, weld.WeldSpec,weld.WeldTypeId,weld.SteelType,
|
|
WeldType.WeldTypeName,WeldType.WeldUnit
|
|
FROM dbo.Weld_WeldInfo weld
|
|
LEFT JOIN Weld_WeldType AS weldType ON weldType.WeldTypeId =weld.WeldTypeId
|
|
WHERE 1 = 1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
|
if (drpWeldType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND weld.WeldTypeId = @WeldTypeId";
|
|
listStr.Add(new SqlParameter("@WeldTypeId", drpWeldType.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
|
{
|
|
strSql += " AND weld.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
|
|
|
|
|
|
#region 格式化字符串
|
|
/// <summary>
|
|
/// 获取剩余数量
|
|
/// </summary>
|
|
/// <param name="stockInId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertAmount(object WeldId)
|
|
{
|
|
decimal? sumUsingAmount = 0;//领用数量
|
|
decimal? sumRecycleAmount = 0;//回收数量
|
|
decimal? totalAmount = 0;//总领用数量
|
|
if (WeldId != null)
|
|
{
|
|
var usingMat = from x in Funs.DB.Weld_UsingMat where x.ProjectId == this.ProjectId && x.WeldId == WeldId.ToString() select x;
|
|
if (usingMat.Count()>0)
|
|
{
|
|
sumUsingAmount = usingMat.Sum(e => e.Amount);
|
|
}
|
|
|
|
var recycleMat = from x in Funs.DB.Weld_RecycleMat where x.ProjectId == this.ProjectId && x.WeldId == WeldId.ToString() select x;
|
|
if (recycleMat.Count()>0)
|
|
{
|
|
sumRecycleAmount = recycleMat.Sum(e => e.RecycleAmount);
|
|
}
|
|
|
|
totalAmount = sumUsingAmount ?? 0 - sumRecycleAmount ?? 0;
|
|
var weld = BLL.WeldInfoService.GetWeldInfoById(WeldId.ToString());
|
|
var weldType = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
|
|
if (weldType.WeldTypeName.Contains("焊条"))
|
|
{
|
|
totalAmount = (totalAmount ?? 0) / weld.ConvertValue;
|
|
}
|
|
}
|
|
return string.Format("{0:0.##}", totalAmount);
|
|
}
|
|
#endregion
|
|
}
|
|
} |