using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Stone.Entity;
using Stone.Common;
using grproLib;
using Gm_WMS.DataAccess.DataService;
using System.Windows.Forms;
using System.IO;
namespace Stone.WinBiz.JISAdmin
{
public class F_JIS5000_Print_ReOrder
{
///
/// 打印装配单
///
///
public static void PrintAssembly(DataSet dsData)
{
PrintAssembly(dsData, "");
}
public static void PrintAssembly(DataSet dsData, string SuperMarket)
{
/*
打印按 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("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["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[4];
obj[0] = ID;
obj[1] = SuperMarket == "" ? "" : " and [SuperMarket]='" + SuperMarket + "'";
strWhere = string.Format(strWhere, obj);
Entity_v_JIS_Tod_ReOrder v_JIS_Tod = new Entity_v_JIS_Tod_ReOrder();
DataSet dsTod = v_JIS_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
{
dsTod.Tables[0].Rows[i]["BarCodeCode2"] = "";
}
}
if (dsTod.Tables[0].Rows.Count == 0) return;
MyReport MyReport = new MyReport(MyIO.GetAppPath() + "\\Report\\ReOrderJIS装配单.grf", dtHead, dsTod.Tables[0].Copy());
MyReport.Report.Print(false);
#endregion
}
}
///
/// 打印装配不干胶标签
///
///
public static void PrintAssemblyLabel(DataSet dsData)
{
Entity_t_PartsFamily t_PartsFamily = new Entity_t_PartsFamily();
foreach (DataRow drBillHead in dsData.Tables["BillHead"].Rows)
{
string PartsFamily = drBillHead["PartsFamily"].ToString();
string Model = "";
DataTable dtPartsFamily = t_PartsFamily.GetData("[Code]='" + PartsFamily + "'").Tables[0];
if (dtPartsFamily.Rows.Count > 0) Model = dtPartsFamily.Rows[0]["CarModelCode"].ToString();
//if (Model != "")
//{
// if (Model.IndexOf("B") >= 0)
// {
// Model = Model.Substring(0, Model.Length - 1) + "-01";
// }
// else
// {
// Model = Model.Substring(0, Model.Length - 1) + "-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();
drHead["OrderNumber"] = drBillHead["OrderNumber"] = drBillHead["OrderNumber"].ToString().Substring(0, drBillHead["OrderNumber"].ToString().Length - 1); ;
drHead["VINNumber"] = drBillHead["VINNumber"].ToString();
drHead["Model"] = Model;
drHead["Description"] = F_JIS5000_Print.GetPartsFamilyDescription(drBillHead["partsFamily"].ToString());
drHead["FTime"] = MyDateTime.Format(MyDateTimeType.DateTime2);
drHead["中文描述"] = drBillHead["PackageGroupName"].ToString() != "" ? drBillHead["PackageGroupName"].ToString().Substring(0, 1) : "";
drHead["PartColor"] = drBillHead["PartColor"].ToString();
dtHead.Rows.Add(drHead);
MyReport MyReport = new MyReport(MyIO.GetAppPath() + "\\Report\\ReOrderJIS标签.grf", dtHead, null);
MyReport.Report.Printer.PrinterName = MyAppconfig.ReadValue("默认条码打印机");
MyReport.Report.Print(false);
}
}
///
/// 打印装箱单
///
///
public static void PrintPackingList(DataSet dsData, string BillNo, string PackageGroupName, string PageNumber)
{
Entity_v_JIS_Tod_ReOrder v_JIS_Tod = new Entity_v_JIS_Tod_ReOrder();
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");
string supplyGroup = "";
foreach (DataRow drData in dsData.Tables[0].Rows)
{
DataSet dsTod = v_JIS_Tod.GetData("orderNumber = '" + drData["OrderNumber"].ToString() + "' and partsFamily='" + drData["partsFamily"].ToString() + "' and[supplyGroup]='" + drData["supplyGroup"].ToString() + "' and [seqnum]=1");
if (dsTod.Tables[0].Rows.Count == 0)
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"] = dsTod.Tables[0].Rows[0]["Variant"].ToString();
drDetailNew["CallOffNumber"] = drData["CallOffNumber"].ToString();
drDetailNew["SwetTime"] = drData["SwetTime"].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 MyReport = new MyReport(MyIO.GetAppPath() + "\\Report\\ReOrderJIS装箱单.grf", dtHead, dtDetail);
MyReport.Report.Print(false);
}
///
/// 打印ASN
///
public static void PrintASNList(DataSet dsData, string AsnNumber)
{
DataTable dtHead = new DataTable();
dtHead.Columns.Add("Date");
dtHead.Columns.Add("Time");
dtHead.Columns.Add("Part");
dtHead.Columns.Add("ASNNo");
dtHead.Columns.Add("TotalBinQty");
DataRow drHead = dtHead.NewRow();
drHead["Date"] = MyDateTime.Format(MyDateTimeType.Date);
drHead["Time"] = MyDateTime.Format(MyDateTimeType.Time);
drHead["ASNNo"] = AsnNumber;
drHead["TotalBinQty"] = F_JIS5000_Print.GetPackingListNumberCount(dsData);
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("RunningBinNo");
dtDetail.Columns.Add("ModelCode");
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["RunningBinNo"] = drData["PackingListNumber"].ToString();
drDetailNew["ModelCode"] = drData["Variant"].ToString();
dtDetail.Rows.Add(drDetailNew);
}
MyReport MyReport = new MyReport(MyIO.GetAppPath() + "\\Report\\ReOrderASN.grf", dtHead, dtDetail);
MyReport.Report.Print(false);
}
#region 私有函数
//获取单据编号
public static string GetBillNo(string type, int len)
{
LocalDBService db = new LocalDBService();
string value = db.Exec_Object("exec p_GetBillNoReOrder '" + type + "'").ToString();
return type + MyStrings.PadLeftString(value, '0', len);
}
//获取两位数的编号,到了99自动变成1
public static string GetNumber(string type, int len)
{
LocalDBService db = new LocalDBService();
string value = db.Exec_Object("exec p_GetNumberReOrder '" + type + "'").ToString();
return MyStrings.PadLeftString(value, '0', len);
}
//获取装箱单订单编号
//PackageGroupName-前保(F) 后保(B) 左门槛条(L) 左门槛(R)
public static string GetPackingListNumber(string PackageGroupName)
{
string ret = "PR";
switch (PackageGroupName)
{
case "前保":
ret += "F";
break;
case "后保":
ret += "B";
break;
case "左门槛":
ret += "L";
break;
case "右门槛":
ret += "R";
break;
}
ret += MyDateTime.Format(MyDateTimeType.YearMonth);
ret = GetBillNo(ret, 4);
return ret;
}
//获取ASN单号
public static string GetASNNumber()
{
string ret = "SMH9";
ret += MyDateTime.GetServerDateTime().Year.ToString();
ret = GetBillNo(ret, 6);
return ret;
}
#endregion
}
}