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.
 
 
 
 
 

285 lines
10 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CK.SCP.Common;
using CK.SCP.Controller;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
using FineUI;
using CK.SCP.Utils;
using System.Data;
using GridReport;
namespace SCP.ErpExtend
{
public partial class SCP_INVOICE_RECVICE : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
IsRoleRight();
if (!IsPostBack)
{
BindData();
SetRoleRule();
}
}
public void IsRoleRight()
{
if (CurrentUser.FactoryList == null || CurrentUser.FactoryList.Count == 0)
{
Alert.Show("当前用户未选择地点!");
return;
}
}
private void SetRoleRule()
{
IsPriceVisible(Grid1, "合同价格");
IsPriceVisible(Grid1, "合同差额");
IsPriceVisible(Grid1, "要货日期");
}
private void Search(Action<IQueryable<V_TB_INVOICE_DETAIL>> p_list)
{
V_TB_INVOICE_DETAIL _entity = new V_TB_INVOICE_DETAIL();
_entity.AsnBillNum = TXT_AsnBillNum.Text;
_entity.RecvBillNum = TXT_RecvBillNum.Text;
_entity.InvoiceNum = TXT_InvoiceNum.Text;
_entity.PoBillNum = TXT_PoBillNum.Text;
_entity.PartCode = TXT_PartCode.Text;
_entity.InvcBillNum = TXT_InvoiceBillNum.Text;
_entity.State = int.Parse(DDL_State.SelectedValue);
SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_DETAIL_List(_entity, (ret) => {
if (ret.State == ReturnStatus.Succeed)
{
p_list(ret.Result);
}
});
}
public void BindData()
{
Search(ret =>
{
Grid1.RecordCount = ret.Count();
var list = SortAndPage<V_TB_INVOICE_DETAIL>(ret, Grid1);
var _ls=list.ToList();
if (_ls.Count > 0)
{
var _vendList= SCP_TB_VENDER_CONTROLLER.GetVendNameList(_ls.Select(p => p.VendId).ToList(), CurrentUser.FactoryList.FirstOrDefault());
_ls.ForEach(p => {
var _entity= _vendList.Where(itm => itm.VendId == p.VendId).FirstOrDefault();
if (_entity != null)
{
p.VendName = _entity.VendName;
}
else
{
p.VendName = string.Empty;
}
});
}
Grid1.DataSource = list;
Grid1.DataBind();
});
}
protected void btnOutput_Click(object sender, EventArgs e)
{
List<V_TB_INVOICE_DETAIL> _ls = new List<V_TB_INVOICE_DETAIL>();
for (int i = 0, count = Grid1.Rows.Count; i < count; i++)
{
V_TB_INVOICE_DETAIL inv = new V_TB_INVOICE_DETAIL();
object[] rowDataKeys = Grid1.DataKeys[i];
inv.PoBillNum = rowDataKeys[1].ToString();//订单
if (rowDataKeys[2] != null)
{
inv.PoLineNum = int.Parse(rowDataKeys[2].ToString());//订单行
}
inv.AsnBillNum = rowDataKeys[3].ToString();//发货单
inv.PartCode = rowDataKeys[4].ToString();//零件号
inv.PartDesc1 = rowDataKeys[5].ToString();//零件名称
inv.Currency = rowDataKeys[6].ToString();//币种
if (rowDataKeys[7] != null)
{
inv.Price = decimal.Parse(rowDataKeys[7].ToString());//单价
}
if (rowDataKeys[8] != null)
{
inv.ContractPrice = decimal.Parse(rowDataKeys[8].ToString());//合同价格
}
if (rowDataKeys[9] != null)
{
inv.BlancePrice = decimal.Parse(rowDataKeys[9].ToString());//合同差额
}
if (rowDataKeys[10] != null)
{
inv.CreateTime = DateTime.Parse(rowDataKeys[10].ToString());//要货日期
}
if (rowDataKeys[11] != null)
{
inv.Qty = decimal.Parse(rowDataKeys[11].ToString());//开票数量
}
if (rowDataKeys[12] != null)
{
inv.Remark = rowDataKeys[12].ToString();//备注
}
if (rowDataKeys[13] != null)
{
inv.InvoiceNum = rowDataKeys[13].ToString();//备注
}
if (rowDataKeys[14] != null)
{
inv.RecvBillNum = rowDataKeys[14].ToString();//备注
}
if (rowDataKeys[15] != null)
{
inv.VendId = rowDataKeys[15].ToString();//备注
}
if (rowDataKeys[16] != null)
{
inv.ProjectId = rowDataKeys[16].ToString();//备注
}
if (rowDataKeys[17] != null)
{
inv.VendName= rowDataKeys[17].ToString();//备注
}
if (rowDataKeys[18] != null)
{
inv.PoUnit = rowDataKeys[18].ToString();//备注
}
if (rowDataKeys[19] != null)
{
inv.InvcBillNum = rowDataKeys[19].ToString();//备注
}
_ls.Add(inv);
}
Dictionary<string, string> cellheader = new Dictionary<string, string>
{
{ "ProjectId", "项目编号" },
{ "InvcBillNum", "发票编号" },
{ "InvoiceNum", "金税票号" },
{ "RecvBillNum", "收货单号" },
{ "AsnBillNum", "发货单号" },
{ "PoBillNum", "订单编号" },
{ "PoLineNum", "行号" },
{ "VendId", "供应商编码" },
{ "PartCode", "零件号" },
{ "PartDesc1", "零件名称" },
{ "Currency", "币种" },
{ "Qty", "开票数量" },
{ "PoUnit","单位"}
};
string url = EntityListToExcel2003(cellheader, _ls, "发票明细");
}
protected void BtnSearch_Click(object sender, EventArgs e)
{
BindData();
}
protected void btnPrint_Click(object sender, EventArgs e)
{
List<V_TB_INVOICE_DETAIL> _ls = new List<V_TB_INVOICE_DETAIL>();
for (int i = 0, count = Grid1.Rows.Count; i < count; i++)
{
V_TB_INVOICE_DETAIL inv = new V_TB_INVOICE_DETAIL();
object[] rowDataKeys = Grid1.DataKeys[i];
inv.PoBillNum = rowDataKeys[1].ToString();//订单
if (rowDataKeys[2] != null)
{
inv.PoLineNum = int.Parse(rowDataKeys[2].ToString());//订单行
}
if (rowDataKeys[3] != null)
{
inv.AsnBillNum = rowDataKeys[3].ToString();//发货单
}
inv.PartCode = rowDataKeys[4].ToString();//零件号
inv.PartDesc1 = rowDataKeys[5].ToString();//零件名称
inv.Currency = rowDataKeys[6].ToString();//币种
if (rowDataKeys[7] != null)
{
inv.Price = decimal.Parse(rowDataKeys[7].ToString());//单价
}
if (rowDataKeys[8] != null)
{
inv.ContractPrice = decimal.Parse(rowDataKeys[8].ToString());//合同价格
}
if (rowDataKeys[9] != null)
{
inv.BlancePrice = decimal.Parse(rowDataKeys[9].ToString());//合同差额
}
if (rowDataKeys[10] != null)
{
inv.CreateTime = DateTime.Parse(rowDataKeys[10].ToString());//要货日期
}
if (rowDataKeys[11] != null)
{
inv.Qty = decimal.Parse(rowDataKeys[11].ToString());//开票数量
}
if (rowDataKeys[12] != null)
{
inv.Remark = rowDataKeys[12].ToString();//备注
}
if (rowDataKeys[13] != null)
{
inv.InvoiceNum = rowDataKeys[13].ToString();//备注
}
if (rowDataKeys[14] != null)
{
inv.RecvBillNum = rowDataKeys[14].ToString();//备注
}
if (rowDataKeys[15] != null)
{
inv.VendId = rowDataKeys[15].ToString();//备注
}
if (rowDataKeys[16] != null)
{
inv.ProjectId = rowDataKeys[16].ToString();//备注
}
if (rowDataKeys[17] != null)
{
inv.VendName = rowDataKeys[17].ToString();//备注
}
if (rowDataKeys[18] != null)
{
inv.PoUnit = rowDataKeys[18].ToString();//备注
}
if (rowDataKeys[19] != null)
{
inv.InvcBillNum = rowDataKeys[19].ToString();//备注
}
_ls.Add(inv);
}
DataSet _ds = new DataSet();
_ls.ForEach(p=>{
if(string.IsNullOrEmpty(p.AsnBillNum))
{
p.AsnBillNum = "空项";
}
});
var _dt = ConvertHelper.ToDataTable(_ls);
_ds.Tables.Add(_dt);
string str = JSONReportData.FromDataSet(_ds);
var js = string.Format("openPostWindow('{0}',{1},'winOpen')", "../../Handlers/GenerateReport.ashx?report=InvRecBill&data=101&type=pdf&filename=BarCode.pdf&open=", str);
PageContext.RegisterStartupScript(js);
}
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindData();
}
}
}