所以我有一个存储过程,它给出了每小时打包的单位数量,所以当一个单位通过时,这会在我的表中更新..我需要将每分钟打包的数量传递给标签..并且一旦给定的时间段过去,标签应该刷新回0 ...所以时间是早上6点到下午2点 - 下午2点 - 晚上10点 - 晚上10点 - 下午6点..
我不确定如何使用我的存储过程更新标签..
我想我可能需要对我的存储过程进行计算?并将其归还给我的标签?我对此有点失落......
截图是我的存储过程..现在我需要知道如何使用这些结果更新我的标签,然后在8小时后重置...这是我的c#代码到目前为止。
protected void Page_Load(object sender,EventArgs e) { if(!IsPostBack) { Refreshdata(214,DateTime.Today,DateTime.Today.AddDays(1).AddMinutes(-1)); BindDropDownList();
}
}
private void BindDropDownList()
{
BizManager mgr = new BizManager();
DataView dv = mgr.GetItemSeriesMaster().DefaultView; //how to filter data
dv.RowFilter = ProductQueryFilter;
Dropdownlist1.DataSource = dv;
Dropdownlist1.DataTextField = "Description"; // the items to be displayed in the list items
Dropdownlist1.DataValueField = "Id"; // the id of the items displayed
Dropdownlist1.DataBind();
}
private string ProductQueryFilter
{
get { return ConfigurationManager.AppSettings["ProductQueryFilter"]; }
}
public void Refreshdata(int selectedProduct, DateTime shiftStart, DateTime shiftEnd)
{
BizManager biz = new BizManager();
GridView1.DataSource = biz.GetPacktstatisticsForShift(
shiftStart
, shiftEnd
, selectedProduct).DefaultView;
GridView1.DataBind();
}
public void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
{
DateTime shiftStart = DateTime.Today;
DateTime shiftEnd = DateTime.Today.AddDays(1).AddMinutes(-1);
int productId;
if (int.TryParse(Dropdownlist1.SelectedValue, out productId))
Refreshdata(productId, shiftStart, shiftEnd);
}
存储过程
USE [生产] 走 / ******对象:StoredProcedure [dbo]。[uspGetPackStatisticsPerShift]脚本日期:29/05/2018 13:07:04 ****** / SET ANSI_NULLS ON 走 SET QUOTED_IDENTIFIER ON GO
ALTER PROC [dbo]。[uspGetPackStatisticsPerShift]
@ShiftStart DateTime,
@ShiftEnd DateTime,
@SeriesMasterId int
AS
SET NOCOUNT ON;
--DECLARE @LogicalMachineId int
--DECLARE @WorkCellId int
--SELECT @LogicalMachineId = mr.LogicalMachineId, @WorkCellId = lm.WorkCellId
--FROM Shared.dbo.MachineRegistry mr
--INNER JOIN Shared.dbo.LogicalMachine lm on lm.Id = mr.LogicalMachineId and lm.Active=1
--WHERE mr.Active=1 AND mr.SystemId = 'Generic' AND mr.DnsName = @MachineName
--if (@WorkCellId is null)
--BEGIN
-- RAISERROR('uspGetBuildStatisticsPerShift() Workstation not defined',15,1)
-- RETURN
--END
-- Now get the data
select DateDiff(hour, @ShiftStart, psh.DtTmEnd) + 1 AS ShiftHour
, ifsm.[Id] as FrameSizeMasterId
, Count(ph.Id ) as TotalPacked
from Production.dbo.PackHistory ph
INNER JOIN Production.dbo.PackStageHistory psh on psh.PackHistoryId = ph.Id AND psh.PackScheduleStageID=2
INNER JOIN Production.dbo.ItemSerialNumber isn on isn.Id = ph.ItemSerialNumberId
INNER JOIN Production.dbo.ItemMaster im on im.Id = isn.ItemMasterId
INNER JOIN Production.dbo.ItemSeriesMaster ism on ism.Id = im.SeriesMasterId AND im.SeriesMasterId = @SeriesMasterId
INNER JOIN Production.dbo.ItemFrameSizeMaster ifsm on ifsm.Id = im.FrameSizeMasterId
where psh.DtTmEnd BETWEEN @ShiftStart AND @ShiftEnd AND psh.Successful = 1 AND psh.ReRun=0
group by DateDiff(hour, @ShiftStart, psh.DtTmEnd) + 1 , ifsm.[Id]
order by 1