using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Windows.Forms ;
using System.IO ;
using System.Data ;
using Stone.Common ;
using Stone.Entity ;
using Gm_WMS.DataAccess.DataService ;
using grproLib ;
using Stone.WinBiz.Standard ;
namespace Stone.WinBiz.JISAdmin
{
public class F_JIS5000_Print
{
/// <summary>
/// JIS打印领料单
/// </summary>
public static void PrintCallShip ( )
{
string PackageGroupName = MyAppconfig . ReadValue ( "JIS打印领料单类型" ) . Trim ( ) ;
string SuperMarket = MyAppconfig . ReadValue ( "JIS打印领料单种类" ) . Trim ( ) ;
if ( PackageGroupName = = "" ) return ;
if ( SuperMarket = = "" ) return ;
Entity_t_JIS_PrintAssemble t_JIS_PrintAssemble = new Entity_t_JIS_PrintAssemble ( ) ;
DataSet dsData = t_JIS_PrintAssemble . GetData ( "top 1 *" , "[PackageGroupName]='" + PackageGroupName + "' and [SuperMarket]='" + SuperMarket + "' and [IsPrint]=0" , "[ID] asc" ) ;
if ( dsData . Tables [ 0 ] . Rows . Count > 0 )
{
t_JIS_PrintAssemble . Edit ( "[IsPrint]=1, [PrintTime]=getdate()" , "[ID]=" + dsData . Tables [ 0 ] . Rows [ 0 ] [ "ID" ] . ToString ( ) ) ;
string OrderNumber = dsData . Tables [ 0 ] . Rows [ 0 ] [ "OrderNumber" ] . ToString ( ) ;
if ( Convert . ToInt32 ( dsData . Tables [ 0 ] . Rows [ 0 ] [ "IsReOrder" ] ) = = 0 )
{
//正常排序数据
Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000 ( ) ;
DataSet dsPrint = t_JIS_Seq5000 . GetData ( "top 1 *" , "[OrderNumber]='" + OrderNumber + "' and [PackageGroupName]='" + PackageGroupName + "'" , "[ID] asc" ) ;
if ( dsPrint . Tables [ 0 ] . Rows . Count > 0 )
{
dsPrint . Tables [ 0 ] . TableName = "BillHead" ;
dsPrint . Tables [ 0 ] . Rows [ 0 ] [ "OrderNumber" ] = "PL" + OrderNumber ;
F_JIS5000_Print . PrintAssembly ( dsPrint , SuperMarket ) ;
}
}
else
{
//ReOrder排序数据
Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder ( ) ;
DataSet dsPrint = t_JIS_Seq5000_ReOrder . GetData ( "top 1 *" , "[OrderNumber]='" + OrderNumber + "' and [PackageGroupName]='" + PackageGroupName + "'" , "[ID] asc" ) ;
if ( dsPrint . Tables [ 0 ] . Rows . Count > 0 )
{
dsPrint . Tables [ 0 ] . TableName = "BillHead" ;
dsPrint . Tables [ 0 ] . Rows [ 0 ] [ "OrderNumber" ] = "PL" + OrderNumber ;
F_JIS5000_Print_ReOrder . PrintAssembly ( dsPrint , SuperMarket ) ;
}
}
}
}
public static void PrintCallShipRe ( string ID , string SuperMarket )
{
Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000 ( ) ;
DataSet dsPrint = t_JIS_Seq5000 . GetData ( "top 1 *" , "[ID]='" + ID + "'" , "[ID] asc" ) ;
if ( dsPrint . Tables [ 0 ] . Rows . Count > 0 )
{
if ( Convert . ToInt32 ( dsPrint . Tables [ 0 ] . Rows [ 0 ] [ "IsPrintAssemble" ] ) = = 0 ) throw new Exception ( "请先打印装配单,然后才能补打" ) ;
string OrderNumber = dsPrint . Tables [ 0 ] . Rows [ 0 ] [ "OrderNumber" ] . ToString ( ) ;
dsPrint . Tables [ 0 ] . TableName = "BillHead" ;
dsPrint . Tables [ 0 ] . Rows [ 0 ] [ "OrderNumber" ] = "PL" + OrderNumber ;
F_JIS5000_Print . PrintAssembly ( dsPrint , SuperMarket ) ;
}
else
{
throw new Exception ( "补打记录不存在" ) ;
}
}
/// <summary>
/// 打印装配单
/// </summary>
/// <param name="dsData"></param>
public static void PrintAssembly ( DataSet dsData )
{
PrintAssembly ( dsData , "" ) ;
}
public static void PrintAssembly ( DataSet dsData , string SuperMarket )
{
if ( MyAppconfig . ReadValue ( "是否打印装配单" ) ! = "是" ) return ;
/ *
打 印 按 PartsFamily ( 3 台 电 脑 前 、 后 、 左 右 门 槛 , 按 SupplyGroup打印4张单据 前 后 左 右 )
* /
foreach ( DataRow drBillHead in dsData . Tables [ "BillHead" ] . Rows )
{
#region 表头
string PrintTime = MyDateTime . Format ( MyDateTimeType . DateTime ) ;
DataTable dtHead = new DataTable ( ) ;
dtHead . Columns . Add ( "OrderNumber" ) ;
dtHead . Columns . Add ( "CallOffNumber" ) ;
dtHead . Columns . Add ( "CheckSequence" ) ;
dtHead . Columns . Add ( "PrintTime" ) ;
dtHead . Columns . Add ( "SwetTime" ) ;
dtHead . Columns . Add ( "SwetTacho" ) ;
dtHead . Columns . Add ( "PartsFamily" ) ;
dtHead . Columns . Add ( "SupplyGroup" ) ;
dtHead . Columns . Add ( "Variant" ) ;
DataRow drHead = dtHead . NewRow ( ) ;
drHead [ "OrderNumber" ] = drBillHead [ "OrderNumber" ] . ToString ( ) . Substring ( 0 , drBillHead [ "OrderNumber" ] . ToString ( ) . Length - 1 ) ;
drHead [ "CallOffNumber" ] = drBillHead [ "CallOffNumber" ] . ToString ( ) ;
drHead [ "CheckSequence" ] = drBillHead [ "CheckSequence" ] . ToString ( ) ;
drHead [ "PrintTime" ] = PrintTime ;
drHead [ "SwetTime" ] = MyDateTime . Format ( Convert . ToDateTime ( drBillHead [ "SwetTime" ] ) , MyDateTimeType . DateTime ) ;
drHead [ "SwetTacho" ] = drBillHead [ "SwetTacho" ] ! = DBNull . Value ? MyDateTime . Format ( Convert . ToDateTime ( drBillHead [ "SwetTacho" ] ) , MyDateTimeType . DateTime ) : "" ;
drHead [ "PartsFamily" ] = drBillHead [ "PartsFamily" ] . ToString ( ) ;
drHead [ "SupplyGroup" ] = drBillHead [ "supplyGroup" ] . ToString ( ) ;
drHead [ "Variant" ] = drBillHead [ "Variant" ] . ToString ( ) ;
dtHead . Rows . Add ( drHead ) ;
#endregion
#region 明细
//string orderNumber = drBillHead["orderNumber"].ToString().Trim();
//string partsFamily = drBillHead["partsFamily"].ToString().Trim();
//string strWhere = "[orderNumber]='{0}' and [partsFamily]='{1}' and [supplyGroup]='{2}' {3}";
//object[] obj = new object[4];
//obj[0] = orderNumber;
//obj[1] = partsFamily;
//obj[2] = drHead["SupplyGroup"].ToString();
//obj[3] = SuperMarket == "" ? "" : " and [SuperMarket]='" + SuperMarket + "'";
//strWhere = string.Format(strWhere, obj);
string ID = drBillHead [ "ID" ] . ToString ( ) ;
string strWhere = "[SeqID]={0} {1}" ;
object [ ] obj = new object [ 2 ] ;
obj [ 0 ] = ID ;
obj [ 1 ] = SuperMarket = = "" ? "" : " and [SuperMarket]='" + SuperMarket + "'" ;
strWhere = string . Format ( strWhere , obj ) ;
Entity_v_JIS_Tod v_Tod = new Entity_v_JIS_Tod ( ) ;
DataSet dsTod = v_Tod . GetData ( "*, barcodeCode as BarCodeCode2" , strWhere , "seqnum asc" ) ;
for ( int i = 0 ; i < dsTod . Tables [ 0 ] . Rows . Count ; i + + )
{
if ( dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode2" ] . ToString ( ) = = "1" )
{
dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode2" ] = "*" ;
dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode" ] = "" ;
}
else if ( dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode2" ] . ToString ( ) = = "2" )
{
dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode2" ] = "**" ;
dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode" ] = "" ;
}
else
{
dsTod . Tables [ 0 ] . Rows [ i ] [ "BarCodeCode2" ] = "" ;
}
}
MyReport f_GridReport = new MyReport ( MyIO . GetAppPath ( ) + "\\Report\\JIS装配单.grf" , dtHead , dsTod . Tables [ 0 ] . Copy ( ) ) ;
if ( drBillHead [ "PackageGroupName" ] . ToString ( ) = = "左门槛" )
{
f_GridReport . Report . Printer . PaperOrientation = GRPaperOrientation . grpoLandscape ;
}
else
{
f_GridReport . Report . Printer . PaperOrientation = GRPaperOrientation . grpoPortrait ;
}
f_GridReport . Report . Print ( false ) ;
if ( MyAppconfig . ReadValue ( "JIS打印两份装配单" ) = = "是" )
{
f_GridReport . Report . Print ( false ) ;
}
#endregion
}
}
/// <summary>
/// 打印装配不干胶标签
/// </summary>
/// <param name="dsData"></param>
public static void PrintAssemblyLabel ( DataSet dsData )
{
if ( MyAppconfig . ReadValue ( "是否打印装配标签" ) ! = "是" ) return ;
foreach ( DataRow drBillHead in dsData . Tables [ "BillHead" ] . Rows )
{
string Model = drBillHead [ "Variant" ] . ToString ( ) ;
if ( Model . IndexOf ( "B" ) > = 0 )
{
//Model = Model.Substring(0, Model.Length - 1) + "-01";
Model = Model . Substring ( 0 , Model . Length ) + "-01" ;
}
else
{
//Model = Model.Substring(0, Model.Length - 1) + "-02";
Model = Model . Substring ( 0 , Model . Length ) + "-02" ;
}
DataTable dtHead = new DataTable ( ) ;
dtHead . Columns . Add ( "SequenceNumber" ) ;
dtHead . Columns . Add ( "OrderNumber" ) ;
dtHead . Columns . Add ( "VINNumber" ) ;
dtHead . Columns . Add ( "Model" ) ;
dtHead . Columns . Add ( "Description" ) ;
dtHead . Columns . Add ( "FTime" ) ;
dtHead . Columns . Add ( "中文描述" ) ;
dtHead . Columns . Add ( "PartColor" ) ;
DataRow drHead = dtHead . NewRow ( ) ;
drHead [ "SequenceNumber" ] = drBillHead [ "SequenceNumber" ] . ToString ( ) ; //JIS5000中貌似没有
drHead [ "OrderNumber" ] = drBillHead [ "OrderNumber" ] . ToString ( ) . Substring ( 0 , drBillHead [ "OrderNumber" ] . ToString ( ) . Length - 1 ) ;
drHead [ "VINNumber" ] = drBillHead [ "VINNumber" ] . ToString ( ) ; //JIS5000没有
drHead [ "Model" ] = Model ;
drHead [ "Description" ] = GetPartsFamilyDescription ( drBillHead [ "partsFamily" ] . ToString ( ) ) ;
drHead [ "FTime" ] = MyDateTime . Format ( MyDateTimeType . DateTime2 ) ;
drHead [ "中文描述" ] = drBillHead [ "PackageGroupName" ] . ToString ( ) . Substring ( 0 , 1 ) ;
drHead [ "PartColor" ] = drBillHead [ "PartColor" ] . ToString ( ) ;
dtHead . Rows . Add ( drHead ) ;
MyReport f_GridReport = new MyReport ( MyIO . GetAppPath ( ) + "\\Report\\JIS标签.grf" , dtHead , null ) ;
f_GridReport . Report . Printer . PrinterName = MyAppconfig . ReadValue ( "默认条码打印机" ) ;
f_GridReport . Report . Print ( false ) ;
}
}
/// <summary>
/// 打印装箱单
/// </summary>
/// <param name="dsData"></param>
public static void PrintPackingList ( DataSet dsData , string BillNo , string PackageGroupName , string PageNumber )
{
Entity_v_JIS_Tod v_JIS_Tod = new Entity_v_JIS_Tod ( ) ;
DataTable dtDetail = new DataTable ( ) ;
dtDetail . Columns . Add ( "OrderNumber" ) ;
dtDetail . Columns . Add ( "BarCode" ) ;
dtDetail . Columns . Add ( "Color" ) ;
dtDetail . Columns . Add ( "Model" ) ;
dtDetail . Columns . Add ( "CallOffNumber" ) ;
dtDetail . Columns . Add ( "SwetTime" ) ;
dtDetail . Columns . Add ( "SwetTacho" ) ;
dtDetail . Columns . Add ( "SequenceNumber" ) ;
dtDetail . Columns . Add ( "PartName" ) ;
string supplyGroup = "" ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
DataSet dsTod = v_JIS_Tod . GetData ( "[SeqID]=" + drData [ "ID" ] . ToString ( ) + " and [JisMajor]=1" ) ;
if ( dsTod . Tables [ 0 ] . Rows . Count = = 0 )
{
//throw new Exception(drData["OrderNumber"].ToString() + " " + drData["partsFamily"].ToString() + " 未设置主要零件,请在基础资料中设置");
continue ;
}
DataRow drDetailNew = dtDetail . NewRow ( ) ;
drDetailNew [ "OrderNumber" ] = drData [ "OrderNumber" ] . ToString ( ) . Substring ( 0 , drData [ "OrderNumber" ] . ToString ( ) . Length - 1 ) ;
drDetailNew [ "BarCode" ] = dsTod . Tables [ 0 ] . Rows [ 0 ] [ "BarCodeCode" ] . ToString ( ) ;
drDetailNew [ "Color" ] = dsTod . Tables [ 0 ] . Rows [ 0 ] [ "ColorName" ] . ToString ( ) ;
drDetailNew [ "Model" ] = drData [ "Variant" ] . ToString ( ) ; // dsTod.Tables[0].Rows[0]["Variant"].ToString();
drDetailNew [ "CallOffNumber" ] = drData [ "CallOffNumber" ] . ToString ( ) ;
drDetailNew [ "SwetTime" ] = drData [ "SwetTime" ] . ToString ( ) ;
drDetailNew [ "SwetTacho" ] = drData [ "SwetTacho" ] ! = DBNull . Value ? MyDateTime . Format ( Convert . ToDateTime ( drData [ "SwetTacho" ] ) , MyDateTimeType . DateTime ) : "" ;
drDetailNew [ "SequenceNumber" ] = drData [ "SequenceNumber" ] . ToString ( ) ;
drDetailNew [ "PartName" ] = drData [ "PartName" ] . ToString ( ) ;
dtDetail . Rows . Add ( drDetailNew ) ;
PackageGroupName = dsTod . Tables [ 0 ] . Rows [ 0 ] [ "PackageGroupName" ] . ToString ( ) ;
supplyGroup = dsTod . Tables [ 0 ] . Rows [ 0 ] [ "supplyGroup" ] . ToString ( ) ;
}
DataTable dtHead = new DataTable ( ) ;
dtHead . Columns . Add ( "BillNo" ) ;
dtHead . Columns . Add ( "PageNumber" ) ;
dtHead . Columns . Add ( "Part" ) ;
dtHead . Columns . Add ( "SwetTimeTop" ) ;
DataRow drHead = dtHead . NewRow ( ) ;
drHead [ "BillNo" ] = BillNo ;
drHead [ "PageNumber" ] = PageNumber ;
drHead [ "Part" ] = PackageGroupName ;
drHead [ "SwetTimeTop" ] = MyDateTime . Format ( Convert . ToDateTime ( dtDetail . Rows [ 0 ] [ "SwetTime" ] ) , MyDateTimeType . DateTime ) ;
dtHead . Rows . Add ( drHead ) ;
MyReport f_GridReport = new MyReport ( MyIO . GetAppPath ( ) + "\\Report\\JIS装箱单.grf" , dtHead , dtDetail ) ;
//f_GridReport.Report.Printer.PaperOrientation = GRPaperOrientation.grpoLandscape;
f_GridReport . Report . Printer . PaperOrientation = GRPaperOrientation . grpoPortrait ;
f_GridReport . Report . Print ( false ) ;
f_GridReport . Report . Print ( false ) ;
f_GridReport . Report . Print ( false ) ;
}
/// <summary>
/// 打印ASN
/// </summary>
public static void PrintASNList ( DataSet dsData , string AsnNumber , bool RePrint )
{
DataTable dtHead = new DataTable ( ) ;
dtHead . Columns . Add ( "Date" ) ;
dtHead . Columns . Add ( "Time" ) ;
dtHead . Columns . Add ( "Part" ) ;
dtHead . Columns . Add ( "ASNNo" ) ;
dtHead . Columns . Add ( "TotalBinQty" ) ;
dtHead . Columns . Add ( "TachoSwet" ) ;
dtHead . Columns . Add ( "TachoTime" ) ;
//dtHead.Columns.Add("Tacho");
DataRow [ ] drs = dsData . Tables [ 0 ] . Select ( "1=1" , "[SwetTime] asc" ) ;
//TimeSpan ts = Convert.ToDateTime(dsData.Tables[0].Rows[0]["SwetTacho"]) - Convert.ToDateTime(dsData.Tables[0].Rows[0]["SwetTime"]);
TimeSpan ts = Convert . ToDateTime ( drs [ 0 ] [ "SwetTacho" ] ) - Convert . ToDateTime ( drs [ 0 ] [ "SwetTime" ] ) ;
int TachoTime = Convert . ToInt32 ( Math . Round ( ts . TotalMinutes , 0 ) ) ;
string sTachoTime = "" ;
if ( TachoTime > 0 )
{
//sTachoTime = "+" + MyStrings.PadLeftString(TachoTime.ToString(), '0', 5);
sTachoTime = "-" + MyStrings . PadLeftString ( TachoTime . ToString ( ) , '0' , 5 ) ;
}
else
{
//sTachoTime = "-" + MyStrings.PadLeftString((-TachoTime).ToString(), '0', 5);
sTachoTime = "+" + MyStrings . PadLeftString ( ( - TachoTime ) . ToString ( ) , '0' , 5 ) ;
}
DataRow drHead = dtHead . NewRow ( ) ;
drHead [ "Date" ] = MyDateTime . Format ( MyDateTimeType . Date ) ;
drHead [ "Time" ] = MyDateTime . Format ( MyDateTimeType . Time ) ;
drHead [ "ASNNo" ] = AsnNumber ;
drHead [ "TotalBinQty" ] = GetPackingListNumberCount ( dsData ) ;
drHead [ "TachoSwet" ] = Convert . ToDateTime ( drs [ 0 ] [ "SwetTacho" ] ) . ToString ( "HH:mm" ) ;
//drHead["TachoTime"] = TachoTime >= 0 ? "+" + TachoTime : TachoTime.ToString();
drHead [ "TachoTime" ] = sTachoTime ;
//drHead["Tacho"] = GetTacho();
dtHead . Rows . Add ( drHead ) ;
DataTable dtDetail = new DataTable ( ) ;
dtDetail . Columns . Add ( "LineItem" ) ;
dtDetail . Columns . Add ( "CallOff" ) ;
dtDetail . Columns . Add ( "OrderNo" ) ;
dtDetail . Columns . Add ( "PartFamily" ) ;
dtDetail . Columns . Add ( "SupplyGroup" ) ;
dtDetail . Columns . Add ( "SWET" ) ;
dtDetail . Columns . Add ( "SwetTacho" ) ;
dtDetail . Columns . Add ( "RunningBinNo" ) ;
dtDetail . Columns . Add ( "ModelCode" ) ;
dtDetail . Columns . Add ( "SequenceNumber" ) ;
dtDetail . Columns . Add ( "partNumber" ) ;
dtDetail . Columns . Add ( "PartName" ) ;
dtDetail . Columns . Add ( "PagerNumber" ) ;
int i = 0 ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
i + + ;
DataRow drDetailNew = dtDetail . NewRow ( ) ;
drDetailNew [ "LineItem" ] = MyStrings . PadLeftString ( i . ToString ( ) , '0' , 3 ) + "0" ;
drDetailNew [ "CallOff" ] = drData [ "CallOffNumber" ] . ToString ( ) ;
drDetailNew [ "OrderNo" ] = drData [ "OrderNumber" ] . ToString ( ) ;
drDetailNew [ "PartFamily" ] = drData [ "PartsFamily" ] . ToString ( ) ;
drDetailNew [ "SupplyGroup" ] = drData [ "SupplyGroup" ] . ToString ( ) ;
drDetailNew [ "SWET" ] = MyDateTime . Format ( Convert . ToDateTime ( drData [ "SwetTime" ] . ToString ( ) ) , MyDateTimeType . DateTime3 ) ;
drDetailNew [ "SwetTacho" ] = drData [ "SwetTacho" ] ! = DBNull . Value ? MyDateTime . Format ( Convert . ToDateTime ( drData [ "SwetTacho" ] . ToString ( ) ) , MyDateTimeType . DateTime3 ) : "" ;
drDetailNew [ "RunningBinNo" ] = drData [ "PackingListNumber" ] . ToString ( ) ;
drDetailNew [ "ModelCode" ] = drData [ "Variant" ] . ToString ( ) ;
drDetailNew [ "SequenceNumber" ] = drData [ "SequenceNumber" ] . ToString ( ) ;
drDetailNew [ "partNumber" ] = drData [ "partNumber" ] . ToString ( ) ;
drDetailNew [ "PartName" ] = drData [ "PartName" ] . ToString ( ) ;
drDetailNew [ "PagerNumber" ] = drData [ "PagerNumber" ] . ToString ( ) ;
dtDetail . Rows . Add ( drDetailNew ) ;
}
MyReport f_GridReport = new MyReport ( MyIO . GetAppPath ( ) + "\\Report\\ASN.grf" , dtHead , dtDetail ) ;
f_GridReport . Report . Print ( false ) ;
if ( ! RePrint )
{
f_GridReport . Report . Print ( false ) ;
f_GridReport . Report . Print ( false ) ;
f_GridReport . Report . Print ( false ) ;
f_GridReport . Report . Print ( false ) ;
}
}
public static int GetPackingListNumberCount ( DataSet dsData )
{
List < string > temp = new List < string > ( ) ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
if ( temp . Count = = 0 )
{
temp . Add ( drData [ "PackingListNumber" ] . ToString ( ) . Trim ( ) ) ;
}
else
{
if ( temp . IndexOf ( drData [ "PackingListNumber" ] . ToString ( ) . Trim ( ) ) = = - 1 )
{
temp . Add ( drData [ "PackingListNumber" ] . ToString ( ) . Trim ( ) ) ;
}
}
}
return temp . Count ;
}
public static void WriteASN ( DataSet dsData , string AsnNumber , bool isftp )
{
string text = GetASNTemp ( ) ;
text = text . Replace ( "{DATE}" , MyDateTime . Format ( MyDateTimeType . Batch ) ) ;
text = text . Replace ( "{TIME}" , MyDateTime . Format ( MyDateTimeType . Time2 ) ) ;
text = text . Replace ( "{ASNNUMBER}" , AsnNumber ) ;
text = text . Replace ( "{DNNUMBER}" , AsnNumber . Substring ( AsnNumber . Length - 9 , 9 ) ) ;
text = text . Replace ( "{SEGQTY}" , ( dsData . Tables [ 0 ] . Rows . Count + 5 ) + "" ) ;
string detail = "" ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
//ARD+::MIKKBR4:MIKFLG4 :4076174:6707067+0+00000000000000000'
string line = "ARD+::{0}:{1}:{2}:{3}+0+00000000000000000'" ;
object [ ] obj = new object [ 4 ] ;
obj [ 0 ] = drData [ "PartsFamily" ] . ToString ( ) . Trim ( ) ;
obj [ 1 ] = drData [ "supplyGroup" ] . ToString ( ) . Trim ( ) ;
obj [ 2 ] = drData [ "CallOffNumber" ] . ToString ( ) . Trim ( ) ;
obj [ 3 ] = drData [ "OrderNumber" ] . ToString ( ) . Trim ( ) . Substring ( 0 , drData [ "OrderNumber" ] . ToString ( ) . Trim ( ) . Length - 1 ) ;
line = string . Format ( line , obj ) ;
detail + = line ;
}
text = text . Replace ( "{DETAIL}" , detail ) ;
string filename = WriteANSFile ( text ) ;
if ( isftp )
{
FtpASN ( filename ) ;
}
WriteQAD ( dsData , AsnNumber , isftp ) ;
}
public static void WriteQAD ( DataSet dsData , string AsnNumber , bool isftp )
{
string filename = Application . StartupPath + "\\QAD_BAK\\" ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename + = MyDateTime . Format ( MyDateTimeType . Date ) ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename = filename + "\\asn" + AsnNumber + ".txt" ;
StreamWriter sw = null ;
try
{
sw = new StreamWriter ( filename , false ) ;
DataTable dtOut = new DataTable ( ) ;
dtOut . Columns . Add ( "SwetTime" , typeof ( System . DateTime ) ) ;
dtOut . Columns . Add ( "SequenceNumber" ) ;
dtOut . Columns . Add ( "OrderNumber" ) ;
dtOut . Columns . Add ( "PartsFamily" ) ;
dtOut . Columns . Add ( "supplyGroup" ) ;
dtOut . Columns . Add ( "PartName" ) ;
dtOut . Columns . Add ( "PartColor" ) ;
dtOut . Columns . Add ( "partNumber" ) ;
dtOut . Columns . Add ( "qty" , typeof ( System . Int32 ) ) ;
Entity_v_JIS_Tod v_JIS_Tod = new Entity_v_JIS_Tod ( ) ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
string OrderNumber = drData [ "OrderNumber" ] . ToString ( ) ;
string PartsFamily = drData [ "PartsFamily" ] . ToString ( ) ;
string SupplyGroup = drData [ "SupplyGroup" ] . ToString ( ) ;
string strWhere = "[SeqID]=" + drData [ "ID" ] . ToString ( ) ;
if ( dsData . Tables [ 0 ] . TableName = = "ReOrder" )
{
strWhere = "[OrderNumber]='" + OrderNumber + "' and [PartsFamily]='" + PartsFamily + "' and [SupplyGroup]='" + SupplyGroup + "'" ;
}
DataSet dsTod = v_JIS_Tod . GetData ( "*" , strWhere , "partNumber asc" ) ;
foreach ( DataRow drTod in dsTod . Tables [ 0 ] . Rows )
{
string partNumber = drTod [ "partNumber" ] . ToString ( ) ;
int qty = Convert . ToInt32 ( drTod [ "quantity" ] . ToString ( ) ) ;
DataRow [ ] drs = dtOut . Select ( "[partNumber]='" + partNumber + "'" ) ;
if ( drs . Length = = 0 )
{
DataRow drNew = dtOut . NewRow ( ) ;
drNew [ "SwetTime" ] = drData [ "SwetTime" ] ;
drNew [ "SequenceNumber" ] = drData [ "SequenceNumber" ] . ToString ( ) ;
drNew [ "OrderNumber" ] = drData [ "OrderNumber" ] . ToString ( ) ;
drNew [ "PartsFamily" ] = drData [ "PartsFamily" ] . ToString ( ) ;
drNew [ "supplyGroup" ] = drData [ "supplyGroup" ] . ToString ( ) ;
drNew [ "PartName" ] = drTod [ "description" ] . ToString ( ) ;
drNew [ "PartColor" ] = drTod [ "ColorName" ] . ToString ( ) ;
drNew [ "partNumber" ] = partNumber ;
drNew [ "qty" ] = qty ;
dtOut . Rows . Add ( drNew ) ;
}
else
{
drs [ 0 ] [ "qty" ] = Convert . ToInt32 ( drs [ 0 ] [ "qty" ] ) + qty ;
}
//DataRow drASN = t_JIS_ASN.Table.NewRow();
//drASN["SwetTime"] = Convert.ToDateTime(drData["SwetTime"]);
//drASN["AsnNumber"] = AsnNumber;
//drASN["SequenceNumber"] = drData["SequenceNumber"].ToString();
//drASN["OrderNumber"] = drData["OrderNumber"].ToString();
//drASN["PartsFamily"] = drData["PartsFamily"].ToString();
//drASN["supplyGroup"] = drData["supplyGroup"].ToString();
//drASN["partNumber"] = drData["partNumber"].ToString();
//drASN["PartName"] = drTod["description"].ToString();
//drASN["PartColor"] = drTod["ColorName"].ToString();
//drASN["quantity"] = drTod["quantity"].ToString();
//t_JIS_ASN.Add(drASN);
}
}
Entity_t_JIS_ASN t_JIS_ASN = new Entity_t_JIS_ASN ( ) ;
t_JIS_ASN . Del ( "[AsnNumber]='" + AsnNumber + "'" ) ;
string text_temp = GetMESTemp ( ) ;
int rownumber = 1 ;
foreach ( DataRow drData in dtOut . Rows )
{
string text_line = text_temp ;
text_line = text_line . Replace ( "{ASNNUMBER}" , AsnNumber ) ;
text_line = text_line . Replace ( "{DATE}" , MyDateTime . Format ( MyDateTimeType . Date3 ) ) ;
text_line = text_line . Replace ( "{ROWNO}" , rownumber . ToString ( ) ) ;
text_line = text_line . Replace ( "{PARTNO}" , drData [ "partNumber" ] . ToString ( ) ) ;
text_line = text_line . Replace ( "{QTY}" , drData [ "qty" ] . ToString ( ) ) ;
rownumber + + ;
sw . WriteLine ( text_line ) ;
DataRow drNew = t_JIS_ASN . Table . NewRow ( ) ;
drNew [ "SwetTime" ] = Convert . ToDateTime ( drData [ "SwetTime" ] ) ;
drNew [ "AsnNumber" ] = AsnNumber ;
drNew [ "SequenceNumber" ] = drData [ "SequenceNumber" ] . ToString ( ) ;
drNew [ "OrderNumber" ] = drData [ "OrderNumber" ] . ToString ( ) ;
drNew [ "PartsFamily" ] = drData [ "PartsFamily" ] . ToString ( ) ;
drNew [ "supplyGroup" ] = drData [ "supplyGroup" ] . ToString ( ) ;
drNew [ "partNumber" ] = drData [ "partNumber" ] . ToString ( ) ;
drNew [ "PartName" ] = drData [ "PartName" ] . ToString ( ) ;
drNew [ "PartColor" ] = drData [ "PartColor" ] . ToString ( ) ;
drNew [ "quantity" ] = drData [ "qty" ] . ToString ( ) ;
t_JIS_ASN . Add ( drNew ) ;
}
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sw ! = null ) sw . Close ( ) ;
}
if ( isftp )
{
FtpQAD ( filename ) ;
}
}
public static void WriteASN_ReOrder ( DataSet dsData , string AsnNumber )
{
string text = GetASNTemp ( ) ;
text = text . Replace ( "{DATE}" , MyDateTime . Format ( MyDateTimeType . Batch ) ) ;
text = text . Replace ( "{TIME}" , MyDateTime . Format ( MyDateTimeType . Time2 ) ) ;
text = text . Replace ( "{ASNNUMBER}" , AsnNumber ) ;
text = text . Replace ( "{DNNUMBER}" , AsnNumber . Substring ( AsnNumber . Length - 9 , 9 ) ) ;
text = text . Replace ( "{SEGQTY}" , ( dsData . Tables [ 0 ] . Rows . Count + 5 ) + "" ) ;
string detail = "" ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
//ARD+::MIKKBR4:MIKFLG4 :4076174:6707067+0+00000000000000000'
string line = "ARD+::{0}:{1}:{2}:{3}+0+00000000000000000'" ;
object [ ] obj = new object [ 4 ] ;
obj [ 0 ] = drData [ "PartsFamily" ] . ToString ( ) . Trim ( ) ;
obj [ 1 ] = drData [ "supplyGroup" ] . ToString ( ) . Trim ( ) ;
obj [ 2 ] = drData [ "CallOffNumber" ] . ToString ( ) . Trim ( ) ;
obj [ 3 ] = drData [ "OrderNumber" ] . ToString ( ) . Trim ( ) . Substring ( 0 , drData [ "OrderNumber" ] . ToString ( ) . Trim ( ) . Length - 1 ) ;
line = string . Format ( line , obj ) ;
detail + = line ;
}
text = text . Replace ( "{DETAIL}" , detail ) ;
string filename = WriteANSFile ( text ) ;
FtpASN ( filename ) ;
WriteQAD_ReOrder ( dsData , AsnNumber ) ;
}
public static void WriteQAD_ReOrder ( DataSet dsData , string AsnNumber )
{
string filename = Application . StartupPath + "\\QAD_BAK\\" ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename + = MyDateTime . Format ( MyDateTimeType . Date ) ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename = filename + "\\asn" + AsnNumber + ".txt" ;
StreamWriter sw = null ;
try
{
sw = new StreamWriter ( filename , false ) ;
DataTable dtOut = new DataTable ( ) ;
dtOut . Columns . Add ( "SwetTime" , typeof ( System . DateTime ) ) ;
dtOut . Columns . Add ( "SequenceNumber" ) ;
dtOut . Columns . Add ( "OrderNumber" ) ;
dtOut . Columns . Add ( "PartsFamily" ) ;
dtOut . Columns . Add ( "supplyGroup" ) ;
dtOut . Columns . Add ( "PartName" ) ;
dtOut . Columns . Add ( "PartColor" ) ;
dtOut . Columns . Add ( "partNumber" ) ;
dtOut . Columns . Add ( "qty" , typeof ( System . Int32 ) ) ;
Entity_t_JIS_ASN_ReOrder t_JIS_ASN = new Entity_t_JIS_ASN_ReOrder ( ) ;
t_JIS_ASN . Del ( "[AsnNumber]='" + AsnNumber + "'" ) ;
Entity_v_JIS_Tod_ReOrder v_JIS_Tod = new Entity_v_JIS_Tod_ReOrder ( ) ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
string OrderNumber = drData [ "OrderNumber" ] . ToString ( ) ;
string PartsFamily = drData [ "PartsFamily" ] . ToString ( ) ;
string SupplyGroup = drData [ "SupplyGroup" ] . ToString ( ) ;
string strWhere = "[SeqID]=" + drData [ "ID" ] . ToString ( ) ;
if ( dsData . Tables [ 0 ] . TableName = = "ReOrder" )
{
strWhere = "[OrderNumber]='" + OrderNumber + "' and [PartsFamily]='" + PartsFamily + "' and [SupplyGroup]='" + SupplyGroup + "'" ;
}
DataSet dsTod = v_JIS_Tod . GetData ( "*" , strWhere , "partNumber asc" ) ;
foreach ( DataRow drTod in dsTod . Tables [ 0 ] . Rows )
{
string partNumber = drTod [ "partNumber" ] . ToString ( ) ;
int qty = Convert . ToInt32 ( drTod [ "quantity" ] . ToString ( ) ) ;
DataRow [ ] drs = dtOut . Select ( "[partNumber]='" + partNumber + "'" ) ;
if ( drs . Length = = 0 )
{
DataRow drNew = dtOut . NewRow ( ) ;
drNew [ "SwetTime" ] = drData [ "SwetTime" ] ;
drNew [ "partNumber" ] = partNumber ;
drNew [ "qty" ] = qty ;
dtOut . Rows . Add ( drNew ) ;
}
else
{
drs [ 0 ] [ "qty" ] = Convert . ToInt32 ( drs [ 0 ] [ "qty" ] ) + qty ;
}
//DataRow drASN = t_JIS_ASN.Table.NewRow();
//drASN["SwetTime"] = Convert.ToDateTime(drData["SwetTime"]);
//drASN["AsnNumber"] = AsnNumber;
//drASN["SequenceNumber"] = drData["SequenceNumber"].ToString();
//drASN["OrderNumber"] = drData["OrderNumber"].ToString();
//drASN["PartsFamily"] = drData["PartsFamily"].ToString();
//drASN["supplyGroup"] = drData["supplyGroup"].ToString();
//drASN["partNumber"] = drData["partNumber"].ToString();
//drASN["PartName"] = drTod["description"].ToString();
//drASN["PartColor"] = drTod["ColorName"].ToString();
//drASN["quantity"] = drTod["quantity"].ToString();
//t_JIS_ASN.Add(drASN);
}
}
string text_temp = GetMESTemp ( ) ;
int rownumber = 1 ;
foreach ( DataRow drData in dtOut . Rows )
{
string text_line = text_temp ;
text_line = text_line . Replace ( "{ASNNUMBER}" , AsnNumber ) ;
text_line = text_line . Replace ( "{DATE}" , MyDateTime . Format ( MyDateTimeType . Date ) ) ;
text_line = text_line . Replace ( "{ROWNO}" , rownumber . ToString ( ) ) ;
text_line = text_line . Replace ( "{PARTNO}" , drData [ "partNumber" ] . ToString ( ) ) ;
text_line = text_line . Replace ( "{QTY}" , drData [ "qty" ] . ToString ( ) ) ;
rownumber + + ;
sw . WriteLine ( text_line ) ;
DataRow drNew = t_JIS_ASN . Table . NewRow ( ) ;
drNew [ "SwetTime" ] = Convert . ToDateTime ( drData [ "SwetTime" ] ) ;
drNew [ "AsnNumber" ] = AsnNumber ;
drNew [ "SequenceNumber" ] = drData [ "SequenceNumber" ] . ToString ( ) ;
drNew [ "OrderNumber" ] = drData [ "OrderNumber" ] . ToString ( ) ;
drNew [ "PartsFamily" ] = drData [ "PartsFamily" ] . ToString ( ) ;
drNew [ "supplyGroup" ] = drData [ "supplyGroup" ] . ToString ( ) ;
drNew [ "partNumber" ] = drData [ "partNumber" ] . ToString ( ) ;
drNew [ "PartName" ] = drData [ "PartName" ] . ToString ( ) ;
drNew [ "PartColor" ] = drData [ "PartColor" ] . ToString ( ) ;
drNew [ "quantity" ] = drData [ "qty" ] . ToString ( ) ;
t_JIS_ASN . Add ( drNew ) ;
}
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sw ! = null ) sw . Close ( ) ;
}
FtpQAD ( filename ) ;
}
#region VDA小件
public static string WriteASN_VDA ( LocalDBService db , DataSet dsData , string AsnNumber )
{
DateTime dtNow = MyDateTime . GetServerDateTime ( ) ;
string fileType = dsData . Tables [ 0 ] . Rows [ 0 ] [ "fileType" ] . ToString ( ) ;
DateTime Date = Convert . ToDateTime ( dsData . Tables [ 0 ] . Rows [ 0 ] [ "Date" ] ) ;
string text = GetASNTemp_Standard ( ) ;
string LocationCode = dsData . Tables [ 0 ] . Rows [ 0 ] [ "LocationCode" ] . ToString ( ) ;
if ( LocationCode = = "" )
throw new Exception ( "卸货点代码不能为空" ) ;
text = text . Replace ( "{DATE}" , dtNow . ToString ( "yyMMdd" ) ) ;
text = text . Replace ( "{TIME}" , dtNow . ToString ( "HHmm" ) ) ;
text = text . Replace ( "{ASNNUMBER}" , AsnNumber ) ;
text = text . Replace ( "{DNNUMBER}" , AsnNumber . Replace ( "ADT" , "" ) ) ;
text = text . Replace ( "{SEGQTY}" , ( dsData . Tables [ 0 ] . Rows . Count + 7 ) + "" ) ;
text = text . Replace ( "{ASNLIUSHUI}" , F_JIS_VDA_ASN . GetVDA_AsnLiushui ( db , "00" , 8 ) ) ;
text = text . Replace ( "{DATE1}" , Date . ToString ( "yyMMddHHmm" ) ) ; //预计到达时间(发货时间+600分钟)
text = text . Replace ( "{DATE2}" , dtNow . ToString ( "yyMMdd:HHmm" ) ) ; //发货时间
text = text . Replace ( "{LINE}" , dsData . Tables [ 0 ] . Rows . Count . ToString ( ) ) ;
text = text . Replace ( "{TOTAL}" , dsData . Tables [ 0 ] . Compute ( "SUM(Qty)" , "1=1" ) . ToString ( ) ) ;
text = text . Replace ( "{CUSTOMERCODE}" , LocationCode ) ;
string detail = "" ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
//ARD+9169691-03+24+L723190709++90000841838'
//金杯李尔不换行
//string line = "ARD+{0}+{1}+{2}:000000++{3}'\r\n";
string line = "ARD+{0}+{1}+{2}:000000++{3}:00000'" ;
object [ ] obj = new object [ 4 ] ;
obj [ 0 ] = drData [ "PartNumber" ] . ToString ( ) . Trim ( ) ; //零件号
obj [ 1 ] = drData [ "Qty" ] . ToString ( ) . Trim ( ) ; //数量
obj [ 2 ] = drData [ "OrderNumber" ] . ToString ( ) ;
obj [ 3 ] = drData [ "PackageNo" ] . ToString ( ) . Trim ( ) ;
line = string . Format ( line , obj ) ;
detail + = line ;
}
text = text . Replace ( "{DETAIL}" , detail ) ;
List < string > lstName = WriteANSFile_Standard ( text , fileType , AsnNumber ) ;
FtpASN ( lstName [ 0 ] ) ;
#region 增加待生成报文数据 金杯李尔不使用FTP服务器 由服务器监听程序进行报文生成
var strsql = "" ;
strsql = "Insert into t_ASN_UPLOAD (AsnNum) values ('" + AsnNumber + "')" ;
db . Exec_NonQuery ( strsql ) ;
#endregion
return lstName [ 1 ] ;
}
public static void WriteQAD_VDA ( DataSet dsData , string AsnNumber )
{
string filename = Application . StartupPath + "\\QAD_BAK\\" ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename + = MyDateTime . Format ( MyDateTimeType . Date ) ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename = filename + "\\asn" + AsnNumber + ".txt" ;
StreamWriter sw = null ;
try
{
sw = new StreamWriter ( filename , false ) ;
DataTable dtOut = new DataTable ( ) ;
dtOut . Columns . Add ( "partNumber" ) ;
dtOut . Columns . Add ( "qty" , typeof ( System . Int32 ) ) ;
foreach ( DataRow drData in dsData . Tables [ 0 ] . Rows )
{
string partNumber = drData [ "partNumber" ] . ToString ( ) ;
int qty = Convert . ToInt32 ( drData [ "qty" ] . ToString ( ) ) ;
DataRow [ ] drs = dtOut . Select ( "[partNumber]='" + partNumber + "'" ) ;
if ( drs . Length = = 0 )
{
DataRow drNew = dtOut . NewRow ( ) ;
drNew [ "partNumber" ] = partNumber ;
drNew [ "qty" ] = qty ;
dtOut . Rows . Add ( drNew ) ;
}
else
{
drs [ 0 ] [ "qty" ] = Convert . ToInt32 ( drs [ 0 ] [ "qty" ] ) + qty ;
}
}
string text_temp = GetMESTemp ( ) ;
int rownumber = 1 ;
foreach ( DataRow drData in dtOut . Rows )
{
string text_line = text_temp ;
text_line = text_line . Replace ( "{ASNNUMBER}" , AsnNumber ) ;
text_line = text_line . Replace ( "{DATE}" , MyDateTime . Format ( MyDateTimeType . Date3 ) ) ;
text_line = text_line . Replace ( "{ROWNO}" , rownumber . ToString ( ) ) ;
text_line = text_line . Replace ( "{PARTNO}" , drData [ "partNumber" ] . ToString ( ) ) ;
text_line = text_line . Replace ( "{QTY}" , drData [ "qty" ] . ToString ( ) ) ;
rownumber + + ;
sw . WriteLine ( text_line ) ;
}
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sw ! = null ) sw . Close ( ) ;
}
FtpQAD ( filename ) ;
}
#endregion
#region 私有函数
//根据产品族代码取描述
public static string GetPartsFamilyDescription ( string PartsFamily )
{
string ret = string . Empty ;
Entity_v_PartsFamily v_PartsFamily = new Entity_v_PartsFamily ( ) ;
DataSet dsData = v_PartsFamily . GetData ( "[Code]='" + PartsFamily + "'" ) ;
if ( dsData . Tables [ 0 ] . Rows . Count > 0 )
{
ret = dsData . Tables [ 0 ] . Rows [ 0 ] [ "Name" ] . ToString ( ) ;
}
return ret ;
}
//根据产品族名称取供应组
public static DataSet GetSupplyGroup ( string PartsFamily )
{
Entity_t_SupplyGroup t_SupplyGroup = new Entity_t_SupplyGroup ( ) ;
return t_SupplyGroup . GetData ( "[PartsFamilyCode]='" + PartsFamily + "'" ) ;
}
//获取单据编号
public static string GetBillNo ( LocalDBService db , string type , int len )
{
string value = db . Exec_Object ( "exec p_GetBillNo '" + type + "'" ) . ToString ( ) ;
return type + MyStrings . PadLeftString ( value , '0' , len ) ;
}
//获取两位数的编号,到了99自动变成1
public static string GetNumber ( LocalDBService db , string type , int len )
{
//string value = db.Exec_Object("exec p_GetBillNo '" + type + "'").ToString();
string value = db . Exec_Object ( "exec p_GetNumber '" + type + "'" ) . ToString ( ) ;
return MyStrings . PadLeftString ( value , '0' , len ) ;
}
//获取装箱单订单编号
//PackageGroupName-前保(F) 后保(B) 左门槛条(L) 左门槛(R)
public static string GetPackingListNumber ( LocalDBService db , string PackageGroupName )
{
string ret = "PL" ;
switch ( PackageGroupName )
{
case "前保" :
ret + = "F" ;
break ;
case "后保" :
ret + = "B" ;
break ;
case "左门槛" :
ret + = "L" ;
break ;
case "右门槛" :
ret + = "R" ;
break ;
case "扰流板" :
ret + = "S" ;
break ;
}
ret + = MyDateTime . Format ( MyDateTimeType . YearMonth ) ;
ret = GetBillNo ( db , ret , 4 ) ;
return ret ;
}
#region old asn
//获取ASN单号
/ *
public static string GetASNNumber ( LocalDBService db )
{
string ret = "SMH3" ;
ret + = MyDateTime . GetServerDateTime ( ) . Year . ToString ( ) ;
ret = GetBillNo ( db , ret , 6 ) ;
return ret ;
}
* /
#endregion
//获取ASN单号
public static string GetASNNumber ( LocalDBService db , string PackageGroupName )
{
//string ret = "SMH3";
//ret += MyDateTime.GetServerDateTime().Year.ToString();
//ret = GetBillNo(db, ret, 6);
//return ret;
string ret = "SMH3" ;
ret + = MyDateTime . GetServerDateTime ( ) . Year . ToString ( ) ;
switch ( PackageGroupName )
{
case "前保" :
ret + = "1" ;
ret = GetBillNo ( db , ret , 5 ) ;
break ;
case "后保" :
ret + = "2" ;
ret = GetBillNo ( db , ret , 5 ) ;
break ;
case "左门槛" :
ret + = "3" ;
ret = GetBillNo ( db , ret , 4 ) + "A" ;
break ;
case "右门槛" :
ret + = "3" ;
ret = GetBillNo ( db , ret , 4 ) + "A" ;
break ;
case "扰流板" :
ret + = "3" ;
ret = GetBillNo ( db , ret , 4 ) + "A" ;
break ;
}
//ret = GetBillNo(db, ret, 5);
return ret ;
}
#region 写ASN文件
private static string WriteANSFile ( string text )
{
//string filename = MyAppconfig.ReadValue("接口文件生成路径");
string filename = Application . StartupPath + "\\ASN_BAK\\" ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename + = MyDateTime . Format ( MyDateTimeType . Date ) ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
filename = filename + "\\SY78.JIS." + MyDateTime . Format ( MyDateTimeType . Time1 ) + ".txt" ;
StreamWriter sw = null ;
try
{
sw = new StreamWriter ( filename , false ) ;
sw . Write ( text ) ;
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sw ! = null ) sw . Close ( ) ;
}
return filename ;
}
private static string GetASNTemp ( )
{
string asn_temp_file = Application . StartupPath + "\\ASN接口模板.txt" ;
if ( ! File . Exists ( asn_temp_file ) ) throw new Exception ( asn_temp_file + " 文件不存在!" ) ;
StreamReader sr = null ;
try
{
sr = new StreamReader ( asn_temp_file , Encoding . Default ) ;
return sr . ReadToEnd ( ) ;
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sr ! = null ) sr . Close ( ) ;
}
}
private static List < string > WriteANSFile_Standard ( string text , string fileType , string AsnNumber )
{
string filename = Application . StartupPath + "\\ASN_OUT\\" ;
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
// filename += MyDateTime.Format(MyDateTimeType.Date);
if ( ! Directory . Exists ( filename ) )
{
Directory . CreateDirectory ( filename ) ;
}
//金杯李尔不要后缀名
// string name = "BMW." + fileType + ".JIT.AVIEXP." + AsnNumber + ".txt";
string name = "BMW." + fileType + ".JIT.AVIEXP." + AsnNumber + "" ;
filename = filename + "\\" + name ;
//金杯李尔 不在客户端生成ASN报文,统一由服务器生成
// StreamWriter sw = null;
// try
// {
// sw = new StreamWriter(filename, false);
// sw.Write(text);
// }
// catch (Exception ex)
// {
// throw ex;
// }
// finally
// {
// if (sw != null) sw.Close();
// }
List < string > ret = new List < string > ( ) ;
ret . Add ( filename ) ;
ret . Add ( name ) ;
return ret ;
}
private static string GetASNTemp_Standard ( )
{
string asn_temp_file = Application . StartupPath + "\\ASN接口模板STD.txt" ;
if ( ! File . Exists ( asn_temp_file ) ) throw new Exception ( asn_temp_file + " 文件不存在!" ) ;
StreamReader sr = null ;
try
{
sr = new StreamReader ( asn_temp_file , Encoding . Default ) ;
return sr . ReadToEnd ( ) ;
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sr ! = null ) sr . Close ( ) ;
}
}
private static void FtpASN ( string filename )
{
try
{
string ASN_FTP_AutoSend = MyAppconfig . ReadValue ( "ASN_FTP_AutoSend" ) . Trim ( ) ;
string ASN_FTP_Server = MyAppconfig . ReadValue ( "ASN_FTP_Server" ) . Trim ( ) ;
string ASN_FTP_Server_Path = MyAppconfig . ReadValue ( "ASN_FTP_Server_Path" ) . Trim ( ) ;
string ASN_FTP_UserName = MyAppconfig . ReadValue ( "ASN_FTP_UserName" ) . Trim ( ) ;
string ASN_FTP_Password = MyAppconfig . ReadValue ( "ASN_FTP_Password" ) . Trim ( ) ;
if ( ASN_FTP_AutoSend = = "是" )
{
MyFTP . FTPUploadFile ( ASN_FTP_Server , ASN_FTP_UserName , ASN_FTP_Password , filename , ASN_FTP_Server_Path ) ;
}
}
catch ( Exception ex )
{
MyLogger . Write ( ex . Message ) ;
throw new Exception ( "ASN文件上传失败" ) ;
}
}
#endregion
#region 写MES文件
private static string GetMESTemp ( )
{
string qad_temp_file = Application . StartupPath + "\\QAD接口模板.txt" ;
if ( ! File . Exists ( qad_temp_file ) ) throw new Exception ( qad_temp_file + " 文件不存在!" ) ;
StreamReader sr = null ;
try
{
sr = new StreamReader ( qad_temp_file , Encoding . Default ) ;
return sr . ReadToEnd ( ) ;
}
catch ( Exception ex )
{
throw ex ;
}
finally
{
if ( sr ! = null ) sr . Close ( ) ;
}
}
private static void FtpQAD ( string filename )
{
try
{
string QAD_FTP_AutoSend = MyAppconfig . ReadValue ( "QAD_FTP_AutoSend" ) . Trim ( ) ;
string QAD_FTP_Server = MyAppconfig . ReadValue ( "QAD_FTP_Server" ) . Trim ( ) ;
string QAD_FTP_Server_Path = MyAppconfig . ReadValue ( "QAD_FTP_Server_Path" ) . Trim ( ) ;
string QAD_FTP_UserName = MyAppconfig . ReadValue ( "QAD_FTP_UserName" ) . Trim ( ) ;
string QAD_FTP_Password = MyAppconfig . ReadValue ( "QAD_FTP_Password" ) . Trim ( ) ;
if ( QAD_FTP_AutoSend = = "是" )
{
MyFTP . FTPUploadFile ( QAD_FTP_Server , QAD_FTP_UserName , QAD_FTP_Password , filename , QAD_FTP_Server_Path ) ;
}
}
catch ( Exception ex )
{
MyLogger . Write ( ex . Message ) ;
MyMessageBox . ShowErrorMessage ( ex . Message ) ;
}
}
#endregion
#endregion
}
}