You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

672 lines
32 KiB

1 year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
11 months ago
using System.Data.Entity.Infrastructure;
1 year ago
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
using CK.SCP.Models.ScpEntity.ExcelImportEntity;
using CK.SCP.Utils;
namespace CK.SCP.Controller
{
public class SCP_EXCEL_CONTROLLER
{
public static DataSet GET_PO_EXECEL(List<string> p_lst,bool p_IsDetail=false)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
if (p_IsDetail == false)
{
var _ls = db.V_TB_PO.Where(p => p_lst.Contains(p.PoBillNum)).ToList();
var _exportList = new List<SCP_PO_EXPORT>();
_ls.ForEach(itm =>
{
SCP_PO_EXPORT _export = new SCP_PO_EXPORT();
_export. = itm.State_DESC;
_export. = itm.ModType_DESC;
_export. = itm.PoBillNum;
_export.Erp订单编号 = itm.ErpBillNum;
_export. = itm.VendId;
_export. = itm.VendName;
_export. = itm.BeginTime == null ? string.Empty : ((DateTime)itm.BeginTime).ToString("yyyyMMdd");
_export. = itm.Site;
_export. = itm.Buyer;
_export. = itm.BuyerPhone;
_export. = itm.Remark;
_exportList.Add(_export);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
}
var _detailList = db.V_TB_PO_DETAIL.Where(p => p_lst.Contains(p.PoBillNum)).ToList();
_detailList = SCP_PO_CONTROLLER.LOAD_PO_DETAIL_SUM(_detailList);
var _exportDetailList = new List<SCP_PO_DETAIL_EXPORT>();
_detailList.ForEach(itm =>
{
var po_detail = new SCP_PO_DETAIL_EXPORT();
po_detail. = itm.PoBillNum;
1 year ago
po_detail. = itm.VendId;
po_detail. = itm.VendName;
1 year ago
po_detail. = itm.State_DESC;
po_detail. = itm.PoLine.ToString();
po_detail. = itm.PartDesc1;
po_detail. = itm.PartCode;
po_detail. = itm.PlanQty.ToString();
po_detail. = itm.TempQty == null ? string.Empty : itm.TempQty.ToString();
po_detail. = itm.ShippedQty.ToString();
po_detail. = itm.ReceivedQty.ToString();
po_detail.退 = itm.RejectQty;
po_detail. = itm.EndTime == null ? string.Empty : ((DateTime)itm.BeginTime).ToString("yyyyMMdd"); ;
po_detail. = itm.PoUnit;
_exportDetailList.Add(po_detail);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static List<SCP_PO_DETAIL_EXPORT_MODEL> GET_PO_EXECEL_Model(List<string> p_lst, bool p_IsDetail = false)
{
DataSet _ds = new DataSet();
var _exportDetailList = new List<SCP_PO_DETAIL_EXPORT_MODEL>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _detailList = db.V_TB_PO_DETAIL.Where(p => p_lst.Contains(p.UID.ToString())).ToList();
var polist=_detailList.Select(p => p.PoBillNum);
var _po = db.V_TB_PO.Where(p =>polist.Contains(p.PoBillNum)).FirstOrDefault();
_detailList.ForEach(itm =>
{
var po_detail = new SCP_PO_DETAIL_EXPORT_MODEL();
po_detail. = itm.PoBillNum;
po_detail. = itm.PoLine.ToString();
po_detail. = itm.PartDesc1;
if (!string.IsNullOrEmpty(itm.PartDesc2))
{
po_detail. += itm.PartDesc2;
}
po_detail. = itm.PartCode;
po_detail. = "0";
po_detail. = itm.VendName;
po_detail. = itm.VendId;
po_detail. =DateTime.Now.ToShortDateString();
po_detail. = DateTime.Now.ToShortDateString();
po_detail. = itm.PoUnit;
po_detail. = _po.Site;
po_detail. = _po.SubSite;
po_detail. = _po.Buyer;
po_detail. = _po.BuyerPhone;
po_detail. = itm.Price.ToString();
po_detail. = itm.Currency;
po_detail. = itm.DockCode;
po_detail. = itm.ProjectId;
_exportDetailList.Add(po_detail);
});
//var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
//_ds.Tables.Add(_list_dt);/
}
return _exportDetailList;
}
public static DataSet GET_PALLET_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_PALLET_DETAIL.Where(p => p_lst.Contains(p.AsnBillNum)).ToList();
var _exportList = new List<SCP_PALLET_EXPORT>();
_ls.ForEach(itm =>
{
SCP_PALLET_EXPORT _entity = new SCP_PALLET_EXPORT();
_entity. = itm.PoBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.PalletNum;
_entity. = itm.PlateNumber;
_entity. = itm.PartCode;
_entity. = itm.PartDesc1 + itm.PartDesc2;
_entity. = itm.Qty.ToString();
_entity. = itm.PackQty.ToString();
_entity. = itm.VendName;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
}
return _ds;
}
public static DataSet GET_ASK_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_ASK.Where(p => p_lst.Contains(p.AskBillNum)).ToList();
var _exportList = new List<SCP_ASK_EXPORT>();
_ls.ForEach(itm =>
{
SCP_ASK_EXPORT _entity = new SCP_ASK_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.ModType_DESC;
_entity. = itm.AskBillNum;
_entity. = itm.PoBillNum;
_entity.ERP订单号 = itm.ErpBillNum;
_entity. = itm.VendName;
_entity. = itm.BeginTime == null ? string.Empty : itm.BeginTime.Value.ToString("yyyyMMdd");
_entity. = itm.Site_Desc;
_entity. = itm.EndTime == null ? string.Empty : itm.EndTime.Value.ToString("yyyyMMdd");
_entity. = itm.Buyer;
_entity. = itm.BuyerPhone;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _detailList = db.V_TB_ASK_DETAIL.Where(p => p_lst.Contains(p.AskBillNum)).ToList();
var _exportDetailList = new List<SCP_ASK_DETAIL_EXPORT>();
_detailList.ForEach(itm =>
{
SCP_ASK_DETAIL_EXPORT _entity = new SCP_ASK_DETAIL_EXPORT();
1 year ago
_entity. = itm.AskBillNum;
1 year ago
_entity. = itm.PoLine.ToString();
_entity. = itm.PartDesc1;
_entity. = itm.PartCode;
_entity. = itm.PoUnit;
_entity. = itm.PackQty.ToString();
_entity. = itm.CurrencyDesc;
_entity. = itm.Price.ToString();
_entity. = itm.AskQty.ToString();
_entity. = string.IsNullOrEmpty(itm.Remark)?string.Empty:itm.Remark.ToString();
1 year ago
_entity. = itm.BeginTime == null ? string.Empty : itm.BeginTime.Value.ToString("yyyyMMdd");
1 year ago
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static DataSet GET_ASN_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_ASN.Where(p => p_lst.Contains(p.AsnBillNum)).ToList();
var _exportList = new List<SCP_ASN_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_ASN_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.AsnBillNum;
_entity. = itm.PlateNumber;
_entity. = itm.VendName;
_entity. = itm.PoBillNum;
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.Value.ToString("yyyyMMdd");
_entity. = itm.ShipUser;
_entity. = itm.ReceiveTime == null ? string.Empty : itm.ReceiveTime.Value.ToString("yyyyMMdd");
_entity. = itm.ReceiveUser;
_entity. = itm.Site_Desc;
_entity. = itm.Remark;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_ASN_DETAIL_EXPORT>();
var _detailList = db.V_TB_ASN_DETAIL.Where(p => p_lst.Contains(p.AsnBillNum)).ToList();
_detailList.ForEach(itm =>{
var _entity = new SCP_ASN_DETAIL_EXPORT();
_entity. = itm.AsnBillNum;
_entity. = itm.PackQty.ToString();
_entity. = itm.Qty.ToString();
_entity. = itm.PartCode;
_entity. = itm.PartDesc1;
_entity. = itm.CurrencyDesc;
_entity. = itm.Batch;
_entity. = itm.VendBatch;
_entity. = itm.ProduceDate==null?string.Empty: itm.ProduceDate.Value.ToString("yyyyMMdd");
_entity. = itm.PoUnit;
_entity. = itm.Price.ToString();
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static List<SCP_PRICE_EXPORT> GET_PRICE_EXECEL_Mode2(List<string> p_lst, bool p_IsDetail = false)
{
DataSet _ds = new DataSet();
var _exportDetailList = new List<SCP_PRICE_EXPORT>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _po = db.TB_PRICE.Where(p => p_lst.Contains(p.UID.ToString())).ToList();
1 year ago
1 year ago
_po.ForEach(itm =>
{
var po_detail = new SCP_PRICE_EXPORT();
po_detail. = itm.UID.ToString();
po_detail. = itm.Curr;
po_detail. = itm.Unit;
po_detail. = itm.Remarks;
po_detail. = itm.Site;
po_detail. = itm.PartCode;
po_detail. = itm.VendId;
po_detail. = itm.SubSite;
po_detail. = itm.TemporaryPrice.ToString();
po_detail. = itm.Amt.ToString();
po_detail. = itm.StartTime.ToString();
po_detail. = itm.EndTime.ToString();
po_detail. = "";
po_detail. = "";
_exportDetailList.Add(po_detail);
});
//var _dt = ConvertHelper.ToDataTable(_exportList);
//_ds.Tables.Add(_dt);
}
return _exportDetailList;
}
public static DataSet GET_INVOICE_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_INVOICE.Where(p => p_lst.Contains(p.InvcBillNum)).ToList();
var _exportList = new List<SCP_INVOICE_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_INVOICE_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.InvcBillNum;
_entity. = itm.InvoiceNum;
_entity. = itm.VendName;
_entity. = itm.Amount.ToString();
_entity. = itm.Tax.ToString();
_entity. = itm.TaxAmount.ToString();
_entity. = itm.ContractPrice.ToString();
_entity. = itm.BlancePrice.ToString();
_entity. = itm.Total.ToString();
_entity. = itm.CreateTime == null ? string.Empty : itm.CreateTime.Value.ToString("yyyyMMdd");
_entity. = itm.ExpressNum;
_entity. = itm.Remark;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_INVOICE_DETAIL_EXPORT>();
var _detailList = db.V_TB_INVOICE_DETAIL.Where(p => p_lst.Contains(p.InvcBillNum)).ToList();
_detailList.ForEach(itm => {
var _entity = new SCP_INVOICE_DETAIL_EXPORT();
_entity. = itm.InvcBillNum;
_entity. = itm.InvoiceNum;
_entity. = !string.IsNullOrEmpty(itm.ProjectId)?itm.ProjectId:string.Empty;
_entity. = itm.PoBillNum;
_entity. = itm.PoLineNum.ToString();
_entity. = itm.AsnBillNum;
_entity. = itm.PartDesc1;
_entity. = itm.PartCode;
_entity. = itm.Currency;
_entity. = itm.Price.ToString();
_entity. = itm.BeginTime == null ? string.Empty : itm.BeginTime.Value.ToString("yyyyMMdd");
_entity. = itm.DiscountPrice.ToString();
_entity. = itm.DiscountRemark;
_entity. = itm.Qty.ToString();
_entity. = itm.Remark;
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static DataSet GET_ARRIVE_EXECEL(List<string> p_lst,string p_vendid="")
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
List<V_TB_ARRIVE> _ls = new List<V_TB_ARRIVE>();
if (!string.IsNullOrEmpty(p_vendid))
{ _ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum) && p.VendId == p_vendid).ToList(); }
else
{
_ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum) ).ToList();
}
var str=JsonHelper.GetJson(_ls);
var _exportList = new List<SCP_ARRIVE_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_ARRIVE_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.BillType_DESC;
_entity. = itm.ArrvBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.AskBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.VendName;
_entity. = itm.VendId;
_entity. = itm.SubSite;
_entity. = itm.Site_Desc;
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.ToString("yyyyMMdd");
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_ARRIVE_DETAIL_EXPORT>();
List<V_TB_ARRIVE_DETAIL> _detailList = new List<V_TB_ARRIVE_DETAIL>();
if (!string.IsNullOrEmpty(p_vendid))
{
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum) && p.VendId == p_vendid).ToList();
}
else
{
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum) ).ToList();
}
_detailList.ForEach(itm => {
var _entity = new SCP_ARRIVE_DETAIL_EXPORT();
_entity. =itm.ArrvBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.PoLine.ToString();
_entity. = itm.PartCode;
_entity. = itm.PartDesc1;
_entity. = itm.Unit;
_entity. = itm.Qty.ToString();
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.Value.ToString("yyyyMMdd");
_entity. = itm.Remark;
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
// 分地点导出
public static DataSet GET_ARRIVE_EXECELBySite(List<string> p_lst, string p_vendid = "",string site ="")
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.Database.CommandTimeout = 300;
List<V_TB_ARRIVE> _ls = new List<V_TB_ARRIVE>();
if (!string.IsNullOrEmpty(p_vendid))
{
if (!string.IsNullOrWhiteSpace(site))
{
_ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum) && (p.VendId == p_vendid) && (p.SubSite == site)).ToList();
}
else
{
_ls = db.V_TB_ARRIVE.Where(p => (p_lst.Contains(p.ArrvBillNum)) && (p.VendId == p_vendid)).ToList();
}
}
else
{
if (!string.IsNullOrWhiteSpace(site))
{
_ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum) && (p.SubSite == site)).ToList();
}
else
{
_ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum)).ToList();
}
}
var str = JsonHelper.GetJson(_ls);
var _exportList = new List<SCP_ARRIVE_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_ARRIVE_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.BillType_DESC;
_entity. = itm.ArrvBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.AskBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.VendName;
_entity. = itm.VendId;
_entity. = itm.SubSite;
_entity. = itm.Site_Desc;
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.ToString("yyyyMMdd");
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_ARRIVE_DETAIL_EXPORT>();
List<V_TB_ARRIVE_DETAIL> _detailList = new List<V_TB_ARRIVE_DETAIL>();
if (!string.IsNullOrEmpty(p_vendid))
{
if (!string.IsNullOrWhiteSpace(site))
{
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum) && (p.VendId == p_vendid) && (p.SubSite == site)).ToList();
}
else
{
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum) && (p.VendId == p_vendid)).ToList();
}
}
else
{
if (!string.IsNullOrWhiteSpace(site))
{
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum)&& (p.SubSite == site)).ToList();
}
else
{
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum)).ToList();
}
}
_detailList.ForEach(itm => {
var _entity = new SCP_ARRIVE_DETAIL_EXPORT();
_entity. = itm.ArrvBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.PoLine.ToString();
_entity. = itm.PartCode;
var partModel = db.TA_PART.FirstOrDefault(p => p.PartCode == itm.PartCode && p.Site == itm.Site);
if (partModel != null)
{
_entity. = partModel.PartDesc1;
_entity. = partModel.Unit;
}
_entity. = itm.Qty.ToString();
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.Value.ToString("yyyyMMdd");
_entity. = itm.Remark;
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
11 months ago
/// <summary>
/// 到货单按条件导出excel
/// </summary>
/// <param name="p_lst"></param>
/// <param name="p_vendid"></param>
/// <param name="site"></param>
/// <returns></returns>
public static DataSet GET_ARRIVE_EXECELBycondition(V_TB_ARRIVE enty)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
string sql = "SELECT * FROM V_TB_ARRIVE where IsDeleted = '0'";
string sql1 = "select a.* from V_TB_ARRIVE_DETAIL as a left join V_TB_ARRIVE as b on a.ArrvBillNum = b.ArrvBillNum and a.VendId = b.VendId and a.SubSite = b.SubSite where b.IsDeleted = '0'";
if (enty.BeginTime != null)
{
sql += " and ShipTime >= " + "'"+enty.BeginTime+"'";
sql1 += " and b.ShipTime >= " + "'" + enty.BeginTime + "'";
}
if (enty.EndTime != null)
{
sql += " and ShipTime <= " + "'" + enty.EndTime + "'";
sql1 += " and b.ShipTime <= " + "'" + enty.EndTime + "'";
}
if (!string.IsNullOrEmpty(enty.ArrvBillNum))
{
sql += " and ArrvBillNum = " + "'" + enty.ArrvBillNum + "'";
sql1 += " and b.ArrvBillNum = " + "'" + enty.ArrvBillNum + "'";
}
if (!string.IsNullOrEmpty(enty.PoBillNum))
{
sql += " and PoBillNum = " + "'" + enty.PoBillNum + "'";
sql1 += " and b.PoBillNum = " + "'" + enty.PoBillNum + "'";
}
if (!string.IsNullOrEmpty(enty.AsnBillNum))
{
sql += " and AsnBillNum = " + "'" + enty.AsnBillNum + "'";
sql1 += " and b.AsnBillNum = " + "'" + enty.AsnBillNum + "'";
}
if (!string.IsNullOrEmpty(enty.AskBillNum))
{
sql += " and AskBillNum = " + "'" + enty.AskBillNum + "'";
sql1 += " and b.AskBillNum = " + "'" + enty.AskBillNum + "'";
}
if (!string.IsNullOrEmpty(enty.Site))
{
sql += " and Site = " + "'" + enty.Site + "'";
sql1 += " and b.Site = " + "'" + enty.Site + "'";
}
if (!string.IsNullOrEmpty(enty.SubSite))
{
sql += " and SubSite = " + "'" + enty.SubSite + "'";
sql1 += " and b.SubSite = " + "'" + enty.SubSite + "'";
}
else if (enty.UserInSubSite != null && enty.UserInSubSite.Count > 0)
{
string UserInSubSite = String.Join(",", enty.UserInSubSite);
UserInSubSite = $"'{UserInSubSite.Replace(",", "', '")}'";
sql += " and SubSite in " + "("+ UserInSubSite + ")";
sql1 += " and b.SubSite in " + "(" + UserInSubSite + ")";
}
if (!string.IsNullOrEmpty(enty.VendId))
{
sql += " and VendId = " + "'" + enty.VendId + "'";
sql1 += " and b.VendId = " + "'" + enty.VendId + "'";
}
if (!string.IsNullOrEmpty(enty.BillType_DESC))
{
sql += " and BillType_DESC = " + "'" + enty.BillType_DESC + "'";
sql1 += " and b.BillType_DESC = " + "'" + enty.BillType_DESC + "'";
}
if (!string.IsNullOrEmpty(enty.Remark))
{
sql += " and Remark like " + "'%"+enty.Remark +"%'";
sql1 += " and b.Remark like " + "'%" + enty.Remark + "%'";
}
if (!string.IsNullOrEmpty(enty.CreateUser))
{
sql += " and CreateUser like " + "'%" + enty.CreateUser + "%'";
sql1 += " and b.CreateUser like " + "'%" + enty.CreateUser + "%'";
}
if (!string.IsNullOrEmpty(enty.VendName))
{
sql += " and VendName like " + "'%" + enty.VendName + "%'";
sql1 += " and b.VendName like " + "'%" + enty.VendName + "%'";
}
if (!string.IsNullOrEmpty(enty.OperName))
{
sql += " and OperName like " + "'%" + enty.OperName + "%'";
sql1 += " and b.OperName like " + "'%" + enty.OperName + "%'";
}
if (!string.IsNullOrEmpty(enty.Site_Desc))
{
sql += " and Site_Desc like " + "'%" + enty.Site_Desc + "%'";
sql1 += " and b.Site_Desc like " + "'%" + enty.Site_Desc + "%'";
}
if (enty.UserInVendIds != null && enty.UserInVendIds.Count > 0)
{
string UserInVendIds = String.Join(",", enty.UserInVendIds);
UserInVendIds = $"'{UserInVendIds.Replace(",", "', '")}'";
sql += " and VendId in " + "(" + UserInVendIds + ")";
sql1 += " and b.VendId in " + "(" + UserInVendIds + ")";
}
DbRawSqlQuery<V_TB_ARRIVE> result = db.Database.SqlQuery<V_TB_ARRIVE>(sql);
DbRawSqlQuery<V_TB_ARRIVE_DETAIL> result1 = db.Database.SqlQuery<V_TB_ARRIVE_DETAIL>(sql1);
List < V_TB_ARRIVE > _ls = result.ToList();
List<V_TB_ARRIVE_DETAIL> _detailList = result1.ToList();
var _exportList = new List<SCP_ARRIVE_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_ARRIVE_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.BillType_DESC;
_entity. = itm.ArrvBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.AskBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.VendName;
_entity. = itm.VendId;
_entity. = itm.SubSite;
_entity. = itm.Site_Desc;
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.ToString("yyyyMMdd");
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_ARRIVE_DETAIL_EXPORT>();
_detailList.ForEach(itm => {
var _entity = new SCP_ARRIVE_DETAIL_EXPORT();
_entity. = itm.ArrvBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.PoLine.ToString();
_entity. = itm.PartCode;
_entity. = itm.PartDesc1;
_entity. = itm.Unit;
_entity. = itm.Qty.ToString();
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.Value.ToString("yyyyMMdd");
_entity. = itm.Remark;
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
1 year ago
}
}