212 lines
9.1 KiB
C#
212 lines
9.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.common
|
|
{
|
|
public partial class MainWeldMat : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
// 绑定表格
|
|
BindGrid1();
|
|
BindGrid2();
|
|
BindGrid3();
|
|
BindGrid4();
|
|
}
|
|
}
|
|
|
|
#region
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid1()
|
|
{
|
|
string strSql = @"SELECT v.WeldId,v.WeldName,v.WeldSpec,v.WeldTypeName, v.StockAmount
|
|
FROM
|
|
(SELECT weld.WeldId,weld.WeldName,weld.WeldSpec,wtype.WeldTypeName,weld.WarnAmount,
|
|
(SELECT ISNULL(SUM(ISNULL(stockIn.Amount,0)-ISNULL(stockIn.UsingAmount,0)),0)
|
|
FROM dbo.Weld_StockIn stockIn
|
|
WHERE stockIn.WeldId=weld.WeldId) AS StockAmount
|
|
FROM dbo.Weld_WeldInfo weld
|
|
LEFT JOIN dbo.Weld_WeldType wtype ON wtype.WeldTypeId = weld.WeldTypeId
|
|
WHERE weld.WarnAmount IS NOT NULL
|
|
) v
|
|
WHERE v.StockAmount<v.WarnAmount
|
|
ORDER BY v.WeldName";
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
|
|
|
//Grid1.RecordCount = tb.Rows.Count;
|
|
//var table = this.GetSortTable(Grid1, tb);
|
|
gvStock.DataSource = tb;
|
|
gvStock.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid2()
|
|
{
|
|
string strSql = @"SELECT v.WeldId,v.WeldName,v.WeldSpec,v.WeldTypeName,v.StockAmount,v.PlanAmount
|
|
FROM
|
|
(SELECT weld.WeldId,weld.WeldName,weld.WeldSpec,wtype.WeldTypeName,weld.WarnAmount,
|
|
(SELECT ISNULL(SUM(ISNULL(stockIn.Amount,0)-ISNULL(stockIn.UsingAmount,0)),0) FROM dbo.Weld_StockIn stockIn
|
|
WHERE stockIn.WeldId=weld.WeldId) AS StockAmount,
|
|
(SELECT ISNULL(SUM(ISNULL(usingPlan.Amount,0)),0)
|
|
FROM dbo.Weld_UsingPlan usingPlan
|
|
LEFT JOIN dbo.Weld_UsingMat us ON us.UsingPlanId = usingPlan.UsingPlanId
|
|
WHERE usingPlan.WeldId=weld.WeldId AND us.UsingMatId IS NULL AND usingPlan.IsCancel=0) AS PlanAmount
|
|
FROM dbo.Weld_WeldInfo weld
|
|
LEFT JOIN dbo.Weld_WeldType wtype ON wtype.WeldTypeId = weld.WeldTypeId
|
|
) v
|
|
WHERE (v.StockAmount-v.PlanAmount)<0
|
|
ORDER BY v.WeldName";
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
|
|
|
//Grid1.RecordCount = tb.Rows.Count;
|
|
//var table = this.GetSortTable(Grid1, tb);
|
|
gvStockPlan.DataSource = tb;
|
|
gvStockPlan.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid3()
|
|
{
|
|
string projectIds = BLL.Project_UserService.GetStrProjectIds(this.CurrUser.UserId);
|
|
string strSql = @"SELECT UsingPlan.UsingPlanId, Project.ProjectCode,UsingPlan.WeldId,Weld.WeldName,
|
|
Weld.WeldSpec,UsingPlan.Amount,man.UserName AS InPutMan,
|
|
UsingPlan.OrderDate,UsingPlan.OrderTime, WeldType.WeldTypeName,
|
|
Welder.WED_Name AS UsingMan,Welder.WED_Code
|
|
FROM dbo.Weld_UsingPlan AS UsingPlan
|
|
LEFT JOIN dbo.Weld_WeldInfo AS Weld ON Weld.WeldId=UsingPlan.WeldId
|
|
LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId =UsingPlan.ProjectId
|
|
LEFT JOIN dbo.Weld_WeldType AS WeldType ON WeldType.WeldTypeId = Weld.WeldTypeId
|
|
LEFT JOIN dbo.HJGL_BS_Welder AS Welder ON Welder.WED_ID = UsingPlan.UsingManOne
|
|
LEFT JOIN dbo.Sys_User AS man ON man.UserId=UsingPlan.InPutMan
|
|
LEFT JOIN dbo.Weld_UsingMat us ON us.UsingPlanId = UsingPlan.UsingPlanId
|
|
WHERE convert(char(10),UsingPlan.OrderDate,120)=convert(char(10),GetDate(),120)";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (CurrUser.Account != Const.Gly)
|
|
{
|
|
if (CurrUser.RoleId == Const.cgbgyId)
|
|
{
|
|
strSql += " AND UsingPlan.UsingUnit = @UsingUnit AND CHARINDEX(UsingPlan.ProjectId,@ProjectId)>0";
|
|
listStr.Add(new SqlParameter("@UsingUnit", CurrUser.UnitId));
|
|
listStr.Add(new SqlParameter("@ProjectId", projectIds));
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND CHARINDEX(UsingPlan.ProjectId,@ProjectId)>0";
|
|
listStr.Add(new SqlParameter("@ProjectId", projectIds));
|
|
}
|
|
}
|
|
if (rblIsUsing.SelectedValue != "2")
|
|
{
|
|
if (rblIsUsing.SelectedValue == "0")
|
|
{
|
|
strSql += " AND us.UsingMatId IS NULL";
|
|
}
|
|
|
|
if (rblIsUsing.SelectedValue == "1")
|
|
{
|
|
strSql += " AND us.UsingMatId IS NOT NULL";
|
|
}
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
//Grid1.RecordCount = tb.Rows.Count;
|
|
//var table = this.GetSortTable(Grid1, tb);
|
|
gvSupPlanUse.DataSource = tb;
|
|
gvSupPlanUse.DataBind();
|
|
}
|
|
|
|
private void BindGrid4()
|
|
{
|
|
string strSql = @"SELECT v.WeldId,v.PlanAmount,v.OrderTime,weld.WeldName,weld.WeldSpec,weldType.WeldTypeName,v.UsingUnit,unit.UnitName,
|
|
(CASE WHEN weldType.WeldTypeName='焊条' THEN '根' ELSE 'Kg' END) AS Unit
|
|
FROM
|
|
(SELECT WeldId,SUM(Amount) AS PlanAmount,OrderTime,UsingUnit
|
|
FROM dbo.Weld_UsingPlan
|
|
WHERE OrderDate=convert(char(10),GetDate(),120) AND IsCancel=0
|
|
GROUP BY WeldId,OrderTime,UsingUnit) v
|
|
LEFT JOIN Weld_WeldInfo AS weld ON weld.WeldId = v.WeldId
|
|
LEFT JOIN dbo.Weld_WeldType weldType ON weldType.WeldTypeId = weld.WeldTypeId
|
|
LEFT JOIN dbo.Base_Unit AS unit ON unit.UnitId=v.UsingUnit";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (CurrUser.Account != Const.Gly)
|
|
{
|
|
strSql += " WHERE v.UsingUnit = @UsingUnit";
|
|
listStr.Add(new SqlParameter("@UsingUnit", CurrUser.UnitId));
|
|
}
|
|
|
|
strSql += " ORDER BY weldType.WeldTypeName,weld.WeldName,v.OrderTime";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
|
|
//Grid1.RecordCount = tb.Rows.Count;
|
|
//var table = this.GetSortTable(Grid1, tb);
|
|
gvUsingPlan.DataSource = tb;
|
|
gvUsingPlan.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
protected void rblIsUsing_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid3();
|
|
}
|
|
|
|
protected void gvStock_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
if (e.CommandName == "WeldId")
|
|
{
|
|
string weldId = gvStock.DataKeys[e.RowIndex][0].ToString();
|
|
if (!string.IsNullOrEmpty(weldId))
|
|
{
|
|
//Response.Redirect("~/Common/Notice/NoticeSignParticular.aspx?noticeId=" + weldId);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
protected void gvStockPlan_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void gvSupPlanUse_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
}
|
|
|
|
protected void gvUsingPlan_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
}
|
|
|
|
#region 关闭弹出窗
|
|
/// <summary>
|
|
/// 关闭弹出窗
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
} |