注塑喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

366 lines
18 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.painting
{
public class StockInDAL
{
public DataTable SearchInfoA()
{
try
{
string sql = @"IF OBJECT_ID('TEMPDB..#a') IS NOT NULL
DROP TABLE #a
create table #a (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50), )
INSERT into #a SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE (dbo.tb_StockIn.createTime BETWEEN CONVERT(DATETIME, SUBSTRING(CONVERT(NVARCHAR(50), GETDATE(), 120), 1, 10) + ' 08:00:00')
AND CONVERT(DATETIME, SUBSTRING(CONVERT(NVARCHAR(50), GETDATE(), 120), 1, 10) + ' 20:00:00')) AND (dbo.tb_StockIn.pass = 1)
SELECT COUNT(*) AS c1 ,
(SELECT COUNT(*) FROM #a WHERE productInfo LIKE '%槛%' ) c2
FROM #a WHERE productInfo LIKE '%保%'";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoB()
{
try
{
string sql = "";
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 20:00:00") && GetDateTime() < DateTime.Parse(GetDateTime().ToShortDateString() + " 23:59:59"))
{
sql = @"IF OBJECT_ID('TEMPDB..#c') IS NOT NULL
DROP TABLE #c
create table #c (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50))
INSERT into #c SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00')
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:59:59') AND pass=1
SELECT COUNT(*) AS c1 ,
(SELECT COUNT(*) FROM #c WHERE productInfo LIKE '%槛%' ) c2
FROM #c WHERE productInfo LIKE '%保%'";
}
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 00:00:00") && GetDateTime() < DateTime.Parse(GetDateTime().ToShortDateString() + " 08:00:00"))
{
sql = @"IF OBJECT_ID('TEMPDB..#c') IS NOT NULL
DROP TABLE #c
create table #c (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50))
INSERT into #c SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN DATEADD(day,-1, CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00'))
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:00:00') AND pass=1
SELECT COUNT(*) AS c1 ,
(SELECT COUNT(*) FROM #c WHERE productInfo LIKE '%槛%' ) c2
FROM #c WHERE productInfo LIKE '%保%'";
}
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAByB()
{
try
{
string sql = "";
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 20:00:00") && GetDateTime() <= DateTime.Parse(GetDateTime().ToShortDateString() + " 23:59:59"))
{
sql = @"IF OBJECT_ID('TEMPDB..#d') IS NOT NULL
DROP TABLE #d
create table #d (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50))
INSERT into #d SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:30:00')
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00') AND pass=1
SELECT COUNT(*) AS c1 ,
(SELECT COUNT(*) FROM #d WHERE productInfo LIKE '%槛%' ) c2
FROM #d WHERE productInfo LIKE '%保%'";
}
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 00:00:00") && GetDateTime() < DateTime.Parse(GetDateTime().ToShortDateString() + " 08:00:00"))
{
sql = @"IF OBJECT_ID('TEMPDB..#d') IS NOT NULL
DROP TABLE #d
create table #d (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50))
INSERT into #d SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN DATEADD(day,-1, CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:00:00'))
AND DATEADD(day,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00')) AND pass=1
SELECT COUNT(*) AS c1 ,
(SELECT COUNT(*) FROM #d WHERE productInfo LIKE '%槛%' ) c2
FROM #d WHERE productInfo LIKE '%保%'";
}
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoBByA()
{
try
{
string sql = "";
sql = @"IF OBJECT_ID('TEMPDB..#b') IS NOT NULL
DROP TABLE #b
create table #b (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50))
INSERT into #b SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN DATEADD(day,-1, CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00'))
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:00:00') AND pass=1
SELECT COUNT(*) AS c1 ,
(SELECT COUNT(*) FROM #b WHERE productInfo LIKE '%槛%' ) c2
FROM #b WHERE productInfo LIKE '%保%'";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchDetailA()
{
try
{
string sql = @"IF OBJECT_ID('TEMPDB..#a') IS NOT NULL
DROP TABLE #a
create table #a (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50),paintCode NVARCHAR(100))
INSERT INTO #a SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des,paintCode
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:00:00')
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00') AND pass=1
IF OBJECT_ID('TEMPDB..#b') IS NOT NULL
DROP TABLE #b
create table #b (paintCode NVARCHAR(100),productInfo nvarchar(100),color NVARCHAR(50),total INT )
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%槛%'
GROUP BY productInfo,color,paintCode
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%保%'
GROUP BY productInfo,color,paintCode
SELECT * FROM #b ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchDetailB()
{
try
{
string sql = "";
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 20:00:00") && GetDateTime() < DateTime.Parse(GetDateTime().ToShortDateString() + " 23:59:59"))
{
sql = @"IF OBJECT_ID('TEMPDB..#a') IS NOT NULL
DROP TABLE #a
create table #a (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50),paintCode NVARCHAR(100))
INSERT INTO #a SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des,paintCode
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00')
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:59:59') AND pass=1
IF OBJECT_ID('TEMPDB..#b') IS NOT NULL
DROP TABLE #b
create table #b (paintCode NVARCHAR(100),productInfo nvarchar(100),color NVARCHAR(50),total INT )
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%槛%'
GROUP BY productInfo,color,paintCode
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%保%'
GROUP BY productInfo,color,paintCode
SELECT * FROM #b ";
}
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 00:00:00") && GetDateTime() < DateTime.Parse(GetDateTime().ToShortDateString() + " 08:00:00"))
{
sql = @"IF OBJECT_ID('TEMPDB..#a') IS NOT NULL
DROP TABLE #a
create table #a (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50),paintCode NVARCHAR(100))
INSERT INTO #a SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des,paintCode
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE createTime BETWEEN DATEADD(day,-1, CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00'))
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:00:00') AND pass=1
IF OBJECT_ID('TEMPDB..#b') IS NOT NULL
DROP TABLE #b
create table #b (paintCode NVARCHAR(100),productInfo nvarchar(100),color NVARCHAR(50),total INT )
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%槛%'
GROUP BY productInfo,color,paintCode
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%保%'
GROUP BY productInfo,color,paintCode
SELECT * FROM #b ";
}
if (GetDateTime() > DateTime.Parse(GetDateTime().ToShortDateString() + " 08:00:00") && GetDateTime() < DateTime.Parse(GetDateTime().ToShortDateString() + " 20:00:00"))
{
sql = @"IF OBJECT_ID('TEMPDB..#a') IS NOT NULL
DROP TABLE #a
create table #a (BarCode nvarchar(100),productInfo nvarchar(100),color NVARCHAR(50),paintCode NVARCHAR(100))
INSERT INTO #a SELECT dbo.tb_StockIn.barcode, dbo.tb_Product.ProductName,dbo.View_Color.Des,paintCode
FROM dbo.tb_Product RIGHT OUTER JOIN
dbo.tb_StockIn ON dbo.tb_Product.StockNo = SUBSTRING(dbo.tb_StockIn.barcode, 1, 10) LEFT OUTER JOIN
dbo.View_Color ON SUBSTRING(dbo.tb_StockIn.paintCode, LEN(dbo.tb_StockIn.paintCode) - 3, 4) = dbo.View_Color.ColorNo
WHERE[createTime] BETWEEN DATEADD(day,-1, CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:00:00'))
AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:00:00') AND pass=1
IF OBJECT_ID('TEMPDB..#b') IS NOT NULL
DROP TABLE #b
create table #b (paintCode NVARCHAR(100),productInfo nvarchar(100),color NVARCHAR(50),total INT )
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%槛%'
GROUP BY productInfo,color,paintCode
INSERT INTO #b SELECT paintCode,productInfo,color,COUNT(*) total FROM #a
WHERE productInfo LIKE '%保%'
GROUP BY productInfo,color,paintCode
SELECT * FROM #b ";
}
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchColor(string barCode)
{
try
{
string sql = @"select top 1 * from dbo.tb_StockIn where barcode=@barcode order by createTime desc";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@barcode", SqlDbType.VarChar);
param[0].Value = barCode;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DateTime GetDateTime()
{
string sql = "";
DateTime time;
DataTable dt;
try
{
sql = @"select convert(char(23),getdate(),120) as time";
dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
//time = Convert.ToDateTime(dt.Rows[0]["time"].ToString());
time = DateTime.ParseExact(dt.Rows[0]["time"].ToString(), "yyyy-MM-dd HH:mm:ss.fff",
System.Globalization.CultureInfo.CurrentCulture);
}
else
{
time = DateTime.Now;
}
return time;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return DateTime.Now;
}
}
}
}