using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
namespace Models
{
public class DyelotsBulkedRecipeProvider : IProvider < DyelotsBulkedRecipe >
{
private readonly BatchDyeingCentralEntities db = new BatchDyeingCentralEntities ( ) ;
public int Delete ( DyelotsBulkedRecipe t )
{
if ( t = = null ) return 0 ;
var model = db . DyelotsBulkedRecipe . ToList ( ) . FirstOrDefault ( item = > t . Dyelot = = item . Dyelot ) ;
if ( model = = null ) return 0 ;
db . DyelotsBulkedRecipe . Remove ( model ) ;
int count = db . SaveChanges ( ) ;
return count ;
}
public int Insert ( DyelotsBulkedRecipe t )
{
throw new NotImplementedException ( ) ;
}
public List < DyelotsBulkedRecipe > Selectsql ( DyelotsBulkedRecipe t ) //以单号查询
{
string sqlselect = "select * from DyelotsBulkedRecipe Where Dyelot = " + "'" + t . Dyelot . ToString ( ) + "'" ;
return db . DyelotsBulkedRecipe . SqlQuery ( sqlselect ) . ToList ( ) ;
}
public List < DyelotsBulkedRecipe > SelectCode ( DyelotsBulkedRecipe t ) //以单号查询消耗
{
string sqlselect = "select * from DyelotsBulkedRecipe Where ProductCode = " + "'" + t . ProductCode . ToString ( )
+ "' and Created > '" + t . DispenseStartTime + "' and Created < '" + t . DispenseEndTime + "'" ;
return db . DyelotsBulkedRecipe . SqlQuery ( sqlselect ) . ToList ( ) ;
}
public List < DyelotsBulkedRecipe > SelectMachineSUM ( DyelotsBulkedRecipe t ) //以机台查询消耗
{
string sqlselect = "SELECT * FROM [BatchDyeingCentral].[dbo].[DyelotsBulkedRecipe] where Dyelot in (SELECT dyelot FROM [BatchDyeingCentral].[dbo].[Dyelots] where Machine = '"
+ t . Dispenser . ToString ( ) + "') and Created > '" + t . DispenseStartTime . ToString ( ) + "' and Created < '" + t . DispenseEndTime . ToString ( ) + "' and ProductCode = '" + t . ProductCode . ToString ( ) + "'" ;
return db . DyelotsBulkedRecipe . SqlQuery ( sqlselect ) . ToList ( ) ;
}
public List < DyelotsBulkedRecipe > Select ( ) //查询前500条
{
return db . DyelotsBulkedRecipe . SqlQuery ( "select TOP (500) * from DyelotsBulkedRecipe" ) . ToList ( ) ; //查询前500条
}
public int Update ( DyelotsBulkedRecipe t )
{
throw new NotImplementedException ( ) ;
}
}
}