using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSSoft.Common
{
///
/// 公共验证方法
///
public class VerificationMethod
{
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
///
/// 库存验证物料
///
/// 条码
/// 站点
/// 源头单据
///
public string HouseLotInvCode(string LotNo, string WorkPoint,string TransCode)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
//验证条码物料是否相同
string sql = @"select * from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{2}' and InvCode in (select A.InvCode from ICSMOPick a left join ICSMO b on b.id=a.MODetailID where b.MOCode='{1}' AND B.WorkPoint='{2}')";
sql = string.Format(sql, LotNo, TransCode, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("条码对应物料不符!");
}
else
{
//验证仓库
// HouseLotWHCode(LotNo, WorkPoint);
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
return null;
}
///
/// 库存验证仓库
///
/// 条码
/// 站点
/// 源头单据
///
public string HouseLotWHCode(string LotNo, string WorkPoint)
{
// conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
//验证条码仓库是否相同
string sql = @"select * from ICSWarehouse where WorkPoint='{1}' and WarehouseCode in (select WarehouseCode from ICSWareHouseLotInfo where LotNo='{0}' AND WorkPoint='{1}')";
sql = string.Format(sql, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("条码对应仓库不符!");
}
else
{
//验证项目号
HouseLotProjectCode(LotNo, WorkPoint);
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
return null;
}
///
/// 库存验证项目号
///
/// 条码
/// 站点
/// 源头单据
///
public string HouseLotProjectCode(string LotNo, string WorkPoint)
{
// conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
//验证条码项目号是否相同
string sql = @"select ProjectCode from ICSExtension where WorkPoint='{1}' and id in (select ExtensionID from ICSInventoryLot where WorkPoint='{1}' and LotNo='{0}' )";
sql = string.Format(sql, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("条码对应项目号不符!");
}
else
{
//验证批次
HouseLotBatchCode(LotNo, WorkPoint);
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
return null;
}
///
/// 库存验证批次
///
/// 条码
/// 站点
/// 源头单据
///
public string HouseLotBatchCode(string LotNo, string WorkPoint)
{
// conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
//验证条码批次是否相同
string sql = @"select BatchCode from ICSExtension where WorkPoint='{1}' and id in (select ExtensionID from ICSInventoryLot where WorkPoint='{1}' and LotNo='{0}' )";
sql = string.Format(sql, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("条码对应批次不符!");
}
else
{
//验证自由项
HouseLotcFree(LotNo, WorkPoint);
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
return null;
}
///
/// 库存验证自由项
///
/// 条码
/// 站点
/// 源头单据
///
public string HouseLotcFree(string LotNo, string WorkPoint)
{
//conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
//验证条码自由项是否相同
string sql = @"select ProjectCode from ICSExtension where WorkPoint='{1}' and id in (select ExtensionID from ICSInventoryLot where WorkPoint='{1}' and LotNo='{0}' )";
sql = string.Format(sql, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("条码对应自由项不符!");
}
else
{
//验证批次
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
return null;
}
///
/// 入库条码验证
///
///
///
///
///
public string HouseLotoOut(string LotNo, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
string sqllist = @" select * from ICSWareHouseLotInfo where lotno ='{0}' and WorkPoint='{1}'";
sqllist = string.Format(sqllist, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sqllist, cmd);
if (table.Rows.Count >0)
{
throw new Exception("条码已入库!");
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
return null;
}
///
/// 检验物料是否需要检验
///
/// 物料
/// 站点
///
public Double LotoTest(string Lotno, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string Info;
int InvIQC = 0;
///根据物料+站点查询数据
string sql = @"select InvIQC from ICSInventory where InvCode=(SELECT InvCode FROM ICSInventoryLot WHERE LOTNO='{0}' and WorkPoint='{1}') and WorkPoint='{1}' ";
sql = string.Format(sql, Lotno, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count > 0)
{
foreach (DataRow item in table.Rows)
{
InvIQC = Convert.ToInt32(item["InvIQC"]);
}
if (InvIQC == 1)
{
Double num = QualifiedQuantity(Lotno, WorkPoint);
return num;
}
else
{
//查询条码数量
return 0.0;
}
}
else
{
throw new Exception("该物料没有数据!");
}
}
///
/// 需要检验的取检验表的数量
///
///
///
///
///
public double QualifiedQuantity(string Lotno, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
double qualifiedQuantity = 0;//合格数量
double waiveQuantity = 0;//特采数量
double totalQuantity = 0;//总数量
string sql = @"select * from ICSInspection where Lotno='{0}' and WorkPoint='{1}' and InvCode=(SELECT InvCode FROM ICSInventoryLot WHERE LOTNO='{0}' and WorkPoint='{1}')";
sql = string.Format(sql, Lotno, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("该条码没有检验!");
}
else
{
foreach (DataRow item in table.Rows)
{
qualifiedQuantity = Convert.ToDouble(item["QualifiedQuantity"]);
waiveQuantity = Convert.ToDouble(item["WaiveQuantity"]);
totalQuantity = qualifiedQuantity + waiveQuantity;
}
return totalQuantity;
}
}
///
/// 验证是否到货
///
///
///
///
public bool DeliveryNotice(string LOTNO, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string sql = @"select
a.ID,
H.ContainerCODE,
H.ContainerName,
A.InvCode,
F.InvName,
F.InvStd,
a.Quantity,
F.InvUnit,
F.AmountUnit,
E.ProjectCode,
E.BatchCode,
E.Version,
E.Brand,
c.POCode as TransCode,--来源单据
c.Sequence as TransSequence,--来源行号
A.LotNo,
E.cFree1,
E.cFree2,
E.cFree3,
E.cFree4,
E.cFree5,
E.cFree6,
E.cFree7,
E.cFree8,
E.cFree9,
E.cFree10
FROM ICSInventoryLot A
LEFT JOIN ICSInventoryLotDetail B ON A.LotNo =B.LotNo
LEFT JOIN ICSPurchaseOrder C ON b.TransCode=C.POCode AND C.Sequence=B.TransSequence
LEFT JOIN ICSExtension E ON E.ID=A.ExtensionID
LEFT JOIN ICSInventory F ON A.InvCode=F.InvCode
LEFT JOIN ICSContainerLot G ON A.LotNo =G.LotNo
LEFT JOIN ICSContainer H ON H.ContainerID=G.ID where a.lotno='{0}' and a.WorkPoint ='{1}'";
sql = string.Format(sql, LOTNO, WorkPoint);
DataTable dataTable = DBHelper.SQlReturnData(sql, cmd);
if (dataTable.Rows.Count <= 0)
{
throw new Exception("请先到货" + LOTNO);
}
else
{
bool ttt = true;
return ttt;
}
}
///
/// 查询送货单是否存在
///
///
///
///
public bool SNDetail(string LotNo, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string sql = @"select * from ICSASNDetail where LotNo='{0}' and WorkPoint='{1}'";
sql = string.Format(sql, LotNo, WorkPoint);
DataTable data = DBHelper.SQlReturnData(sql, cmd);
if (data.Rows.Count <= 0)
{
throw new Exception("送货单不存在!");
}
else
{
bool num = DeliveryNotice(LotNo, WorkPoint);
return num;
}
}
#region 验证库存是否存在
///
/// 验证库存是否存在
///
///
///
///
public bool HouseLotInfo(string LotNo, string WorkPoint, string type)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string sql = @"select * from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'";
sql = string.Format(sql, LotNo, WorkPoint);
DataTable data = DBHelper.SQlReturnData(sql, cmd);
if (data.Rows.Count < 0) {
switch (type)
{
case "退货":
throw new Exception("该条码已入库!");
case "发货":
throw new Exception("该条码无库存!");
case "其它入库":
throw new Exception("该条码已入库!");
case "委外发料":
throw new Exception("该条码不存在!");
}
}
//else
//{
// throw new Exception("该条码不存在!");
//}
return true;
}
#endregion
public bool PurchaseOrder(string LotNo, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string sql = @"select* from ICSPurchaseOrder where POCode=( select TransCode from ICSInventoryLotDetail where lotno='{0}' and WorkPoint='{1}')
and Sequence=( select TransSequence from ICSInventoryLotDetail where lotno='{0}' and WorkPoint='{1}') and Status=1";
sql = string.Format(sql, LotNo, WorkPoint);
DataTable data = DBHelper.SQlReturnData(sql, cmd);
if (data.Rows.Count > 0)
{
throw new Exception("该条码没有审核,请先审核!");
}
return true;
}
///
/// 库存是否存在/是否审核
///
///
///
public bool isCheck(string CheckCode, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
int num;
try
{
string sql = @"select * from ICSCheck where CheckCode='{0}' and WorkPoint='{1}'";
sql = string.Format(sql, CheckCode, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count > 0)
{
string sqlInfro = @"select * from ICSCheck where CheckCode='{0}' and WorkPoint='{1}' and Status='2'";
sqlInfro = string.Format(sqlInfro, CheckCode, WorkPoint);
DataTable dataTable = DBHelper.SQlReturnData(sqlInfro, cmd);
if (dataTable.Rows.Count <= 0)
{
throw new Exception("该盘点没有审核,请先审核!");
}
}
else
{
throw new Exception("该盘点不存在!");
}
return true;
}
catch (Exception)
{
throw;
}
}
///
/// 目标仓库是否一致
///
///
public bool iSLocationCode(string lotno, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
int num;
try
{
//库存仓库库位和调拨单是否一致
string sql = @"select * from ICSTransfer where fromWarehouseCode in (select WarehouseCode from ICSWareHouseLotInfo where lotno='{0}' and WorkPoint='{1}')";
sql = string.Format(sql, lotno, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
string sqliNFO = @"select * from ICSTransfer where InvCode in (select InvCode from ICSWareHouseLotInfo where lotno='{0}' and WorkPoint='{1}')";
sqliNFO = string.Format(sqliNFO, lotno, WorkPoint);
DataTable tableiNFO = DBHelper.SQlReturnData(sqliNFO, cmd);
if (table.Rows.Count > 0)
{
if (tableiNFO.Rows.Count > 0)
{
string sqlInfro = @"select * from ICSWareHouseLotInfo where lotno='{0}' and WorkPoint='{1}' and Quantity>0";
sqlInfro = string.Format(sqlInfro, lotno, WorkPoint);
DataTable dataTable = DBHelper.SQlReturnData(sqlInfro, cmd);
if (dataTable.Rows.Count <= 0)
{
throw new Exception("调拨单库存为0!");
}
else
{
return true;
}
}
else
{
throw new Exception("物料不一致!");
}
}
else
{
throw new Exception("仓库不一致!");
}
}
catch (Exception)
{
throw;
}
return true;
}
///
/// 调拨单
///
///
///
///
///
///
public bool isTransfer(string TransCode, string TransSequence, double CurrentQuantity, string LotNo, string WarehouseCode, string LocationCode, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
int num;
///调拨单是否关闭
string sql = @"select * from ICSTransfer where TransferNO='{0}' and Sequence='{1}' and Status='3'";
sql = string.Format(sql, TransCode, TransSequence);
DataTable dataTable = DBHelper.SQlReturnData(sql, cmd);
if (dataTable.Rows.Count <= 0)
{
string sqlInfo = @" select * from ICSWareHouseLotInfo where {0}<=Quantity and LotNo='{1}' ";
sqlInfo = string.Format(sqlInfo, CurrentQuantity, LotNo);
DataTable data = DBHelper.SQlReturnData(sqlInfo, cmd);
if (data.Rows.Count <= 0)
{
throw new Exception("输入数量大于库存数量!");
}
else
{
string sqlInfoList = @" select * from ICSWareHouseLotInfo where WarehouseCode='{0}' and LocationCode='{1}' and LotNo='{2}' and WorkPoint='{3}'";
sqlInfoList = string.Format(sqlInfoList, WarehouseCode, LocationCode, LotNo, WorkPoint);
DataTable dataList = DBHelper.SQlReturnData(sqlInfoList, cmd);
if (dataList.Rows.Count > 0)
{
throw new Exception("调拨库位/仓库 跟目标库位/仓库一致无需调拨");
}
}
}
else
{
throw new Exception("调拨单已关闭,不可提交!");
}
return true;
}
///
/// 条码验证
///
///
///
///
///
public string LotoOut(string LotNo, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
string sqllist = @" select * from ICSInventoryLot where lotno ='{0}' and WorkPoint='{1}'";
sqllist = string.Format(sqllist, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sqllist, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("条码不存在!");
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
//conn.Dispose();
}
return null;
}
///
/// 其它入库单据是否存在
///
///
///
///
public bool IsOtherOut(string TransCode, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
string sqllist = @" select * from ICSOtherOut where OutCode ='{0}' and WorkPoint='{1}'";
sqllist = string.Format(sqllist, TransCode, WorkPoint);
table = DBHelper.SQlReturnData(sqllist, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("单据不存在!");
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
//conn.Dispose();
}
return true;
}
///
/// 库存是否为0
///
///
public bool isStockZero(string LotNo, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
try
{
string sqllist = @" select * from ICSWareHouseLotInfo where LotNo ='{0}' and WorkPoint='{1}' and Quantity>0";
sqllist = string.Format(sqllist, LotNo, WorkPoint);
table = DBHelper.SQlReturnData(sqllist, cmd);
if (table.Rows.Count <= 0)
{
throw new Exception("库存数量为0!");
}
}
catch (Exception ex)
{
//cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
//conn.Dispose();
}
return true;
}
///
/// 其它出库验证
///
///
public bool iSNullLocationCode(string lotno, string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
int num;
try
{
//库存仓库库位和调拨单是否一致
string sql = @"select * from ICSOtherOut where WHCode in (select WarehouseCode from ICSWareHouseLotInfo where lotno='{0}' and WorkPoint='{1}')";
sql = string.Format(sql, lotno, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
string sqliNFO = @"select * from ICSOtherOut where InvCode in (select InvCode from ICSWareHouseLotInfo where lotno='{0}' and WorkPoint='{1}')";
sqliNFO = string.Format(sqliNFO, lotno, WorkPoint);
DataTable tableiNFO = DBHelper.SQlReturnData(sqliNFO, cmd);
if (table.Rows.Count > 0)
{
if (tableiNFO.Rows.Count > 0)
{
string sqlInfro = @"select * from ICSWareHouseLotInfo where lotno='{0}' and WorkPoint='{1}' and Quantity>0";
sqlInfro = string.Format(sqlInfro, lotno, WorkPoint);
DataTable dataTable = DBHelper.SQlReturnData(sqlInfro, cmd);
if (dataTable.Rows.Count <= 0)
{
throw new Exception("库存为0!");
}
else
{
return true;
}
}
else
{
throw new Exception("物料不一致!");
}
}
else
{
throw new Exception("仓库不一致!");
}
}
catch (Exception)
{
throw;
}
}
///
/// 验证拆卸单是否存在
///
///
public bool isBoolDisassemblyDoc(string DABDOCCode ,string WorkPoint)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
bool num = true;
try
{
string sql = @"select * from ICSDisassemblyDoc where DABDOCCode ='{0}' and WorkPoint='{1}')";
sql = string.Format(sql, DABDOCCode, WorkPoint);
table = DBHelper.SQlReturnData(sql, cmd);
if (table.Rows.Count>0)
{
return num;
}
else
{
throw new Exception("拆卸单不存在!");
}
}
catch (Exception ex)
{
}
return false;
}
///
/// 委外发料
///
///
///
///
public bool Outsourcing(string LotNo, string WorkPoint, string TransCode)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string sql = @"select * from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' and InvCode in (select A.InvCode from ICSOOPick a where LotNo='{0}')";
///*left join ICSOutsourcingOrder b on a.OODetailID =b.OODetailID where OOcode='{1}' AND a.WorkPoint='{2}'*/)
sql = string.Format(sql, LotNo, WorkPoint);
DataTable data = DBHelper.SQlReturnData(sql, cmd);
if (data.Rows.Count <0)
{
throw new Exception("条码与物料不符!");
}
return true;
}
///
/// 委外到货
///
///
///
///
///
public bool OutsourcingChre(string LotNo, string WorkPoint, string TransCode)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
DataTable table;
string sql = @"select * from ICSODeliveryNotice where OASNCode='{0}' and WorkPoint='{1}' ";
sql = string.Format(sql, TransCode, WorkPoint);
DataTable data = DBHelper.SQlReturnData(sql, cmd);
if (data.Rows.Count > 0)
{
throw new Exception("条码与物料不符!");
}
return true;
}
}
}