diff --git a/北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs b/北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs
index eae7724..cb5e9cd 100644
--- a/北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs
+++ b/北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs
@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
+using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
@@ -516,5 +517,152 @@ namespace CK.SCP.Controller
}
return _ds;
}
+
+ ///
+ /// 到货单按条件导出excel
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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 result = db.Database.SqlQuery(sql);
+ DbRawSqlQuery result1 = db.Database.SqlQuery(sql1);
+ List < V_TB_ARRIVE > _ls = result.ToList();
+ List _detailList = result1.ToList();
+ var _exportList = new List();
+ _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();
+ _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;
+ }
}
}
diff --git a/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx b/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx
index fcb7f86..df62ae0 100644
--- a/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx
+++ b/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx
@@ -47,7 +47,7 @@
-
+
diff --git a/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx.cs b/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx.cs
index 79b2e17..cb73514 100644
--- a/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx.cs
+++ b/北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx.cs
@@ -30,24 +30,31 @@ namespace SCP.Views.PlanData
return;
}
BindFactory();
- BindArrive();
+ BindArrive("1");
+ DP_StartDate.MaxDate = DateTime.Now;
+ DP_StartDate.MinDate = DateTime.Now.AddYears(-1);
}
private void BindFactory()
{
var _ls = ScpCache.FactoryList;
+ _ls = _ls.Where(q => CurrentUser.FactoryList.Contains(q.FactoryId)).ToList();
_ls.Insert(0, new TB_FACTORY() { FactoryId = "", FactoryName = "" });
factoryList.DataSource = _ls;
factoryList.DataBind();
}
- public void BindArrive()
+ public void BindArrive(string flag = "0")
{
- SearchV_TB_ARRIVEData((result) =>
+ if (flag == "0")
{
- Grid_V_TB_ARRIVE.RecordCount = result.Count();
- var list = SortAndPage(result, Grid_V_TB_ARRIVE);
- Grid_V_TB_ARRIVE.DataSource = list;
- Grid_V_TB_ARRIVE.DataBind();
- });
+ SearchV_TB_ARRIVEData((result) =>
+ {
+ Grid_V_TB_ARRIVE.RecordCount = result.Count();
+ var list = SortAndPage(result, Grid_V_TB_ARRIVE);
+ Grid_V_TB_ARRIVE.DataSource = list;
+ Grid_V_TB_ARRIVE.DataBind();
+ });
+ }
+
}
public void SearchV_TB_ARRIVEData(Action> p_action)
@@ -78,6 +85,10 @@ namespace SCP.Views.PlanData
{
_entity.SubSite = factoryList.SelectedValue;
}
+ else if (string.IsNullOrEmpty(factoryList.SelectedValue))
+ {
+ _entity.Site = CurrentUser.UsedDomain;
+ }
if (!string.IsNullOrEmpty(DDL_BillState.SelectedValue))
{
_entity.BillType_DESC = DDL_BillState.SelectedValue;
@@ -86,10 +97,18 @@ namespace SCP.Views.PlanData
{
_entity.BeginTime = DP_StartDate.SelectedDate;
}
+ else
+ {
+ _entity.BeginTime = DateTime.Now.AddYears(-1);
+ }
if (DP_StartDate.SelectedDate != null)
{
_entity.EndTime = Date_EndDate.SelectedDate;
}
+ else
+ {
+ _entity.EndTime = DateTime.Now;
+ }
_entity.UserInAddress = CurrentUser.FactoryList;
_entity.UserInVendIds = CurrentUser.VenderList;
_entity.UserInSubSite = CurrentUser.SubSiteList;
@@ -122,7 +141,11 @@ namespace SCP.Views.PlanData
}
protected void Grid_V_TB_ARRIVE_PageIndexChange(object sender, GridPageEventArgs e)
{
- BindArrive();
+ if (Grid_V_TB_ARRIVE.RecordCount != 0)
+ {
+ BindArrive();
+ }
+
}
protected void Grid_V_TB_ARRIVE_RowDataBound(object sender, GridRowEventArgs e)
{
@@ -130,7 +153,10 @@ namespace SCP.Views.PlanData
}
protected void Grid_V_TB_ARRIVE_Sort(object sender, GridSortEventArgs e)
{
- BindArrive();
+ if (Grid_V_TB_ARRIVE.RecordCount != 0)
+ {
+ BindArrive();
+ }
}
protected void btnShow_Click(object sender, EventArgs e)
{
@@ -147,7 +173,10 @@ namespace SCP.Views.PlanData
protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid_V_TB_ARRIVE.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
- BindArrive();
+ if (Grid_V_TB_ARRIVE.RecordCount != 0)
+ {
+ BindArrive();
+ }
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
@@ -155,21 +184,67 @@ namespace SCP.Views.PlanData
}
protected void btnOutput_OnClick(object sender, EventArgs e)
{
- List _ls = new List();
- SearchV_TB_ARRIVEData(rs => {
- _ls = rs.Select(p => p.ArrvBillNum).ToList();
- DataSet ds = null;
- if (CurrentUser.VenderList.Count>0)
- {
- ds = SCP_EXCEL_CONTROLLER.GET_ARRIVE_EXECEL(_ls,CurrentUser.VenderList.FirstOrDefault());
- }
- else
- {
- ds = SCP_EXCEL_CONTROLLER.GET_ARRIVE_EXECEL(_ls);
- }
-
- PageBase.DataSetToExcel(ds, "到货单");
- });
+ if (Grid_V_TB_ARRIVE.RecordCount == 0)
+ {
+ Alert.Show("请先完成查询后再进行导出!");
+ return;
+ }
+ V_TB_ARRIVE _entity = new V_TB_ARRIVE();
+ _entity.IsDeleted = false;
+ if (!string.IsNullOrEmpty(TXT_BillNo.Text))
+ {
+ _entity.PoBillNum = TXT_BillNo.Text;
+ }
+ if (!string.IsNullOrEmpty(TXT_ArriveBill.Text))
+ {
+ _entity.ArrvBillNum = TXT_ArriveBill.Text;
+ }
+ if (!string.IsNullOrEmpty(TXT_AsnBill.Text))
+ {
+ _entity.AsnBillNum = TXT_AsnBill.Text;
+ }
+ if (!string.IsNullOrEmpty(TXT_AskBill.Text))
+ {
+ _entity.AskBillNum = TXT_AskBill.Text;
+ }
+ if (!string.IsNullOrEmpty(TXT_VendId.Text))
+ {
+ _entity.VendId = TXT_VendId.Text;
+ }
+ if (!string.IsNullOrEmpty(factoryList.SelectedValue))
+ {
+ _entity.SubSite = factoryList.SelectedValue;
+ }
+ else if (string.IsNullOrEmpty(factoryList.SelectedValue))
+ {
+ _entity.Site = CurrentUser.UsedDomain;
+ }
+ if (!string.IsNullOrEmpty(DDL_BillState.SelectedValue))
+ {
+ _entity.BillType_DESC = DDL_BillState.SelectedValue;
+ }
+ if (DP_StartDate.SelectedDate != null)
+ {
+ _entity.BeginTime = DP_StartDate.SelectedDate;
+ }
+ else
+ {
+ _entity.BeginTime = DateTime.Now.AddYears(-1);
+ }
+ if (DP_StartDate.SelectedDate != null)
+ {
+ _entity.EndTime = Date_EndDate.SelectedDate;
+ }
+ else
+ {
+ _entity.EndTime = DateTime.Now;
+ }
+ _entity.UserInAddress = CurrentUser.FactoryList;
+ _entity.UserInVendIds = CurrentUser.VenderList;
+ _entity.UserInSubSite = CurrentUser.SubSiteList;
+ DataSet ds = null;
+ ds = SCP_EXCEL_CONTROLLER.GET_ARRIVE_EXECELBycondition(_entity);
+ PageBase.DataSetToExcel(ds, "到货单");
}
}
}
\ No newline at end of file