using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace BLL
|
{
|
public class ClsSc_AssemblyBill
|
{
|
/// <summary>
|
/// 扫描成品条码 并返回相关信息,判断是否有效条码
|
/// </summary>
|
/// <param name="sCPCode">成品编码</param>
|
/// <param name="HBillType">单据类型</param>
|
/// <param name="sICMOBillNo">任务单号</param>
|
/// <param name="sCPBarCode">成品条码</param>
|
/// <param name="sCPMaterID">成品内码</param>
|
/// <param name="sCPMaterName">成品名称</param>
|
/// <param name="sBillNo">单据号</param>
|
/// <param name="sInterID">单据内码</param>
|
/// <param name="sErrMsg">错误信息</param>
|
/// <returns></returns>
|
public bool Get_Assembly_CPBarCode(string sCPCode, string HBillType, ref string sICMOBillNo, ref string sCPBarCode, ref Int64 sCPMaterID, ref string sCPMaterName, ref string sBillNo, ref Int64 sInterID, ref string sErrMsg)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
|
//
|
try
|
{
|
//判断所扫描条码是否有效
|
if (dal.GetInfoByNumber_View(sCPCode))
|
{
|
//判断成品条码是否存在组装单记录
|
DataSet ds = oCn.RunProcReturn("exec h_p_Sc_AssemblyBill_CPBarCode '" + sCPCode + "'", "h_p_Sc_AssemblyBill_CPBarCode");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
sErrMsg = "扫描成品条码信息,未知错误!";
|
return false;
|
}
|
else
|
{
|
//已存在组装单记录,编辑状态,获取原组装单单据内码、单据号
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "Modify")
|
{
|
sICMOBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HICMOBillNo"]);
|
sCPBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPBarCode"]);
|
sCPMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCPMaterID"]);
|
sCPMaterName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPMaterName"]);
|
sInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]);
|
sBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
|
return true;
|
}
|
else if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "AddNew")
|
//不存在组装单记录,新增状态,获取最大组装单单据内码、单据号
|
{
|
sICMOBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HICMOBillNo"]);
|
sCPBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPBarCode"]);
|
sCPMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCPMaterID"]);
|
sCPMaterName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPMaterName"]);
|
sInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref sErrMsg);
|
sBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref sErrMsg, true);
|
return true;
|
}
|
else
|
{
|
sErrMsg = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]);
|
return false;
|
}
|
}
|
}
|
else
|
{
|
sErrMsg = "无效条码";
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
sErrMsg = "扫描成品条码失败!" + e.Message;
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 扫描配件条码 并返回相关信息,判断是否有效条码
|
/// </summary>
|
/// <param name="sPJCode">配件代码</param>
|
/// <param name="sCPCode">成品代码</param>
|
/// <param name="sInterID">内码</param>
|
/// <param name="sBillNo">单据号</param>
|
/// <param name="sMaker">制单人</param>
|
/// <param name="HWorkerID">操作员</param>
|
/// <param name="HSNNumber">SN号</param>
|
/// <param name="sErrMsg">错误信息</param>
|
/// <returns></returns>
|
public bool Get_Assembly_PJBarCode(string sPJCode, string sCPCode, long sInterID, string sBillNo, string sMaker, long HWorkerID, string HSNNumber, ref string sErrMsg)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
|
//
|
try
|
{
|
if (dal.GetInfoByNumber_View(sPJCode))
|
{
|
if (sPJCode == sCPCode)
|
{
|
sErrMsg = "所扫描配件条码与成品条码不允许相同!";
|
return false;
|
}
|
|
DataSet ds = oCn.RunProcReturn("exec h_p_Sc_AssemblyBill_PJBarCode '" + sPJCode + "','" + sCPCode + "'," + sInterID.ToString() + ",'" + sBillNo + "','" + sMaker + "'," + HWorkerID.ToString() + ",'" + HSNNumber + "'", "h_p_Sc_AssemblyBill_PJBarCode");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
sErrMsg = "扫描配件条码信息,未知错误!";
|
return false;
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 0)
|
{
|
return true;
|
}
|
else
|
{
|
sErrMsg = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
|
return false;
|
}
|
}
|
}
|
else
|
{
|
sErrMsg = "无效条码";
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
sErrMsg = "扫描配件条码失败!" + e.Message;
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 根据内码 返回组装单信息
|
/// </summary>
|
/// <param name="HInterID">内码</param>
|
/// <param name="sBillType">单据类型</param>
|
/// <param name="sWhere">过滤条件</param>
|
/// <returns></returns>
|
public DataSet GetSc_AssemblyBill(long HInterID, string sBillType, string sWhere,ref string sErr)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//
|
try
|
{
|
DataSet DS = oCn.RunProcReturn("exec h_p_Sc_AssemblyBillList " + HInterID, "h_p_Sc_AssemblyBillList");
|
//DataSet DS = oCn.RunProcReturn("Select * from h_v_Sc_AssemblyBill Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_Sc_AssemblyBill", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS == null || DS.Tables[0].Rows.Count == 0)
|
{
|
return null;
|
}
|
else
|
{
|
return DS;
|
}
|
}
|
catch (Exception e)
|
{
|
sErr = sErr + "," + e.Message;
|
throw (e);
|
}
|
}
|
|
/// <summary>
|
/// 根据内码及条形码,删除对应数据
|
/// </summary>
|
/// <param name="HInterID"></param>
|
/// <param name="HBarCode"></param>
|
/// <param name="sErrMsg"></param>
|
/// <returns></returns>
|
public bool set_DelSc_AssemblyBill(long HInterID, string HBarCode, ref string sErrMsg)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.RunProc("Delete from Sc_AssemblyBillSub where HInterID=" + HInterID.ToString() + " and HBarCode='" + HBarCode + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
sErrMsg = "删除失败!" + e.Message;
|
return false;
|
}
|
}
|
|
|
}
|
}
|