Browse Source

到货查询 导出

master
qian 10 months ago
parent
commit
0c355a65ae
  1. 148
      北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs
  2. 2
      北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx
  3. 127
      北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx.cs

148
北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs

@ -2,6 +2,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations; using System.Data.Entity.Migrations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -516,5 +517,152 @@ namespace CK.SCP.Controller
} }
return _ds; return _ds;
} }
/// <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;
}
} }
} }

2
北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx

@ -47,7 +47,7 @@
<f:FormRow runat="server"> <f:FormRow runat="server">
<Items> <Items>
<f:TextBox runat="server" Label="供应商编码" ID="TXT_VendId"/> <f:TextBox runat="server" Label="供应商编码" ID="TXT_VendId"/>
<f:DatePicker runat="server" Required="true" DateFormatString="yyyy-MM-dd" Label="到货日期日期" EmptyText="请选择日期" ID="DP_StartDate" /> <f:DatePicker runat="server" Required="true" DateFormatString="yyyy-MM-dd" Label="到货日期日期" EmptyText="请选择日期" ID="DP_StartDate" />
<f:DatePicker runat="server" Required="true" DateFormatString="yyyy-MM-dd" EmptyText="请选择日期" Label="至" ID="Date_EndDate" /> <f:DatePicker runat="server" Required="true" DateFormatString="yyyy-MM-dd" EmptyText="请选择日期" Label="至" ID="Date_EndDate" />
<f:DropDownList ID="factoryList" Label="工厂地点" DataTextField="FactoryName" DataValueField="ErpSite" runat="server"></f:DropDownList> <f:DropDownList ID="factoryList" Label="工厂地点" DataTextField="FactoryName" DataValueField="ErpSite" runat="server"></f:DropDownList>
</Items> </Items>

127
北京北汽/SCP/Views/PlanData/SCP_ARRIVE.aspx.cs

@ -30,24 +30,31 @@ namespace SCP.Views.PlanData
return; return;
} }
BindFactory(); BindFactory();
BindArrive(); BindArrive("1");
DP_StartDate.MaxDate = DateTime.Now;
DP_StartDate.MinDate = DateTime.Now.AddYears(-1);
} }
private void BindFactory() private void BindFactory()
{ {
var _ls = ScpCache.FactoryList; var _ls = ScpCache.FactoryList;
_ls = _ls.Where(q => CurrentUser.FactoryList.Contains(q.FactoryId)).ToList();
_ls.Insert(0, new TB_FACTORY() { FactoryId = "", FactoryName = "" }); _ls.Insert(0, new TB_FACTORY() { FactoryId = "", FactoryName = "" });
factoryList.DataSource = _ls; factoryList.DataSource = _ls;
factoryList.DataBind(); 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(); SearchV_TB_ARRIVEData((result) =>
var list = SortAndPage<V_TB_ARRIVE>(result, Grid_V_TB_ARRIVE); {
Grid_V_TB_ARRIVE.DataSource = list; Grid_V_TB_ARRIVE.RecordCount = result.Count();
Grid_V_TB_ARRIVE.DataBind(); var list = SortAndPage<V_TB_ARRIVE>(result, Grid_V_TB_ARRIVE);
}); Grid_V_TB_ARRIVE.DataSource = list;
Grid_V_TB_ARRIVE.DataBind();
});
}
} }
public void SearchV_TB_ARRIVEData(Action<IQueryable<V_TB_ARRIVE>> p_action) public void SearchV_TB_ARRIVEData(Action<IQueryable<V_TB_ARRIVE>> p_action)
@ -78,6 +85,10 @@ namespace SCP.Views.PlanData
{ {
_entity.SubSite = factoryList.SelectedValue; _entity.SubSite = factoryList.SelectedValue;
} }
else if (string.IsNullOrEmpty(factoryList.SelectedValue))
{
_entity.Site = CurrentUser.UsedDomain;
}
if (!string.IsNullOrEmpty(DDL_BillState.SelectedValue)) if (!string.IsNullOrEmpty(DDL_BillState.SelectedValue))
{ {
_entity.BillType_DESC = DDL_BillState.SelectedValue; _entity.BillType_DESC = DDL_BillState.SelectedValue;
@ -86,10 +97,18 @@ namespace SCP.Views.PlanData
{ {
_entity.BeginTime = DP_StartDate.SelectedDate; _entity.BeginTime = DP_StartDate.SelectedDate;
} }
else
{
_entity.BeginTime = DateTime.Now.AddYears(-1);
}
if (DP_StartDate.SelectedDate != null) if (DP_StartDate.SelectedDate != null)
{ {
_entity.EndTime = Date_EndDate.SelectedDate; _entity.EndTime = Date_EndDate.SelectedDate;
} }
else
{
_entity.EndTime = DateTime.Now;
}
_entity.UserInAddress = CurrentUser.FactoryList; _entity.UserInAddress = CurrentUser.FactoryList;
_entity.UserInVendIds = CurrentUser.VenderList; _entity.UserInVendIds = CurrentUser.VenderList;
_entity.UserInSubSite = CurrentUser.SubSiteList; _entity.UserInSubSite = CurrentUser.SubSiteList;
@ -122,7 +141,11 @@ namespace SCP.Views.PlanData
} }
protected void Grid_V_TB_ARRIVE_PageIndexChange(object sender, GridPageEventArgs e) 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) 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) 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) protected void btnShow_Click(object sender, EventArgs e)
{ {
@ -147,7 +173,10 @@ namespace SCP.Views.PlanData
protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e) protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
{ {
Grid_V_TB_ARRIVE.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue); 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) protected void Window1_Close(object sender, WindowCloseEventArgs e)
{ {
@ -155,21 +184,67 @@ namespace SCP.Views.PlanData
} }
protected void btnOutput_OnClick(object sender, EventArgs e) protected void btnOutput_OnClick(object sender, EventArgs e)
{ {
List<string> _ls = new List<string>(); if (Grid_V_TB_ARRIVE.RecordCount == 0)
SearchV_TB_ARRIVEData(rs => { {
_ls = rs.Select(p => p.ArrvBillNum).ToList(); Alert.Show("请先完成查询后再进行导出!");
DataSet ds = null; return;
if (CurrentUser.VenderList.Count>0) }
{ V_TB_ARRIVE _entity = new V_TB_ARRIVE();
ds = SCP_EXCEL_CONTROLLER.GET_ARRIVE_EXECEL(_ls,CurrentUser.VenderList.FirstOrDefault()); _entity.IsDeleted = false;
} if (!string.IsNullOrEmpty(TXT_BillNo.Text))
else {
{ _entity.PoBillNum = TXT_BillNo.Text;
ds = SCP_EXCEL_CONTROLLER.GET_ARRIVE_EXECEL(_ls); }
} if (!string.IsNullOrEmpty(TXT_ArriveBill.Text))
{
PageBase.DataSetToExcel(ds, "到货单"); _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, "到货单");
} }
} }
} }
Loading…
Cancel
Save