using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace BLL
|
{
|
public class ClsKf_MateOutBackBill
|
{
|
/// <summary>
|
/// 根据过滤条件,返回源单信息-生产领料单-蓝字(红字领料源单)
|
/// </summary>
|
/// <param name="sWhere">过滤条件</param>
|
/// <returns></returns>
|
public DataSet GetKf_MateOutBillList(string sWhere, ref string sErr)
|
{
|
try
|
{
|
DAL.Cls_S_IF_MateOutBill_Lite dal = new DAL.Cls_S_IF_MateOutBill_Lite();
|
return dal.DisSourceBillList(sWhere);
|
}
|
catch (Exception e)
|
{
|
sErr = sErr + "," + e.Message;
|
return null;
|
}
|
}
|
|
/// <summary>
|
/// 根据过滤条件,返回源单信息-生产任务单(投料单)-退料列表(红字领料源单)
|
/// </summary>
|
/// <param name="sWhere">过滤条件</param>
|
/// <param name="sErr"></param>
|
/// <returns></returns>
|
public DataSet GetSc_PPBomBackBillList(string sWhere, ref string sErr)
|
{
|
try
|
{
|
DAL.Cls_S_IF_PPBomBackList_Lite dal = new DAL.Cls_S_IF_PPBomBackList_Lite();
|
return dal.DisSourceBillList(sWhere);
|
}
|
catch (Exception e)
|
{
|
sErr = sErr + "," + e.Message;
|
return null;
|
}
|
}
|
|
|
|
|
//生成生产退料单
|
public bool set_SaveMateOutBackBill_New(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, ref string sErrMsg)
|
{
|
//获取系统参数
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
if (oSystemParameter.ShowBill(ref sErrMsg) == false)
|
{
|
sErrMsg = "获取系统参数失败! " + sErrMsg;
|
return false;
|
}
|
//
|
if (oSystemParameter.omodel.Kf_MateOutBackBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE
|
{
|
if (SaveMateOutBackBill_K3(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg))
|
{
|
//"保存成功!";
|
sErrMsg = "保存成功!" + oMain.HBillNo;
|
return true;
|
}
|
else
|
{
|
//"保存失败!";
|
sErrMsg = sErrMsg;
|
return false;
|
}
|
}
|
if (oSystemParameter.omodel.Kf_MateOutBackBill_ERPMode.ToUpper() == "CLOUD") //判断同步模式是金蝶CLOUD
|
{
|
|
}
|
|
sErrMsg = "保存生产退料单失败!" + sErrMsg;
|
return false;
|
}
|
|
|
|
/// <summary>
|
/// 生成生产退料单K3
|
/// </summary>
|
/// <param name="oMain"></param>
|
/// <param name="sErrMsg"></param>
|
/// <returns></returns>
|
public bool SaveMateOutBackBill_K3(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DAL.ClsKf_MateOutBackBill dal = new DAL.ClsKf_MateOutBackBill();
|
dal.omodel = oMain;
|
//上传前必填项判断
|
if (oMain.HDeptID == 0)
|
{
|
sErrMsg = "部门没有选择!";
|
return false;
|
}
|
if (oMain.HSecManagerID == 0)
|
{
|
sErrMsg = "收料没有选择!";
|
return false;
|
}
|
if (oMain.HKeeperID == 0)
|
{
|
sErrMsg = "保管没有选择!";
|
return false;
|
}
|
|
try
|
{
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oMain.HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
sErrMsg = s;
|
return false;
|
}
|
oMain.HYear = sYear;
|
oMain.HPeriod = sPeriod;
|
|
DataSet Ds;
|
oCn.BeginTran();
|
//生成出入库单据
|
//插入子表
|
oCn.RunProc("EXEC h_p_Kf_MateOutBackBillSub_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
|
//插入主表
|
oCn.RunProc("Insert Into Kf_ICStockBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
|
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
|
",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
|
",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
|
") " +
|
" values('1244','1244'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
|
", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
|
", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
|
", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
|
") ");
|
|
//新增K3子表、主表
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'," + oMain.HBillerID.ToString() + ",'" + sHSourceType + "'");
|
|
//更新关联数量
|
if (sHSourceType == "3720") //生产任务单-投料
|
{
|
oCn.RunProc("exec h_p_Sc_UpDateRelation_PPBomToMateOutBack_Add " + oMain.HInterID.ToString());
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateBillRelateData_PPBom " + oMain.HInterID.ToString());
|
}
|
else if (sHSourceType == "1204") //生产领料单-蓝字
|
{
|
oCn.RunProc("exec h_p_Kf_UpDateRelation_MateOutToMateOutBack_Add " + oMain.HInterID.ToString());
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateBillRelateData_Blue " + oMain.HInterID.ToString());
|
}
|
else //无源单
|
{
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateBillRelateData " + oMain.HInterID.ToString());
|
}
|
|
//审核单据
|
if (oSystemParameterMain.Kf_MateOutBackBill_AutoCheck == "Y") //系统参数 自动审核
|
{
|
//审核单据
|
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
|
|
//审核K3单据
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_Check " + oMain.HInterID.ToString() + "," + oMain.HBillerID.ToString());
|
//更新K3库存
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateStock " + oMain.HInterID.ToString());
|
oCn.RunProc("exec h_p_IFK3_ToERP_MateOutBackBill_UpdateOrderStock " + oMain.HInterID.ToString());
|
}
|
|
sErrMsg = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sErrMsg = "生成生产退料单失败!" + e.Message;
|
oCn.RollBack();
|
return false;
|
}
|
}
|
|
|
|
|
|
}
|
}
|