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.
 
 
 
 
 

201 lines
6.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Controller;
using FineUI;
using System.Data;
using System.Drawing;
namespace SCP.Views..SupplierData
{
public partial class SCP_INVOICE : PageBase
{
public void Page_Load(object sender, EventArgs e)
{
IsRoleRight();
if (!IsPostBack)
{
TranslatorAgents(Toolbar1);
TranslatorAgent(Grid_V_TB_INVOICE);
TranslatorAgents(FormRow_1);
TranslatorAgents(FormRow_2);
TranslatorAgents(FormRow_3);
TranslatorAgents(FormRow_4);
BindInvoice();
BindVender(DDL_VEND_LIST);
}
}
public void IsRoleRight()
{
if (CurrentUser.RoleList.Contains("采购人员"))
{
DDL_VEND_LIST.Hidden = false;
BTN_INV.Hidden = false;
}
}
public void BindInvoice()
{
SearchInvoice(ret => {
Grid_V_TB_INVOICE.RecordCount = ret.Count();
ret = SortAndPage(ret, Grid_V_TB_INVOICE);
var _ls = ret.ToList();
Grid_V_TB_INVOICE.DataSource = ret;
Grid_V_TB_INVOICE.DataBind();
});
}
public void SearchInvoice(Action<IQueryable<V_TB_INVOICE>> p_action)
{
V_TB_INVOICE _entity = new V_TB_INVOICE();
_entity.InvcBillNum = TXT_InvcBillNum.Text;
_entity.VendName = TXT_VendName.Text;
_entity.InvoiceNum = TXT_InvoiceNum.Text;
_entity.UserInVendIds = CurrentUser.VenderList;
if (CurrentUser.RoleList.Contains("采购人员"))
{
if (string.IsNullOrEmpty(DDL_VEND_LIST.SelectedValue))
{
Alert.Show("选择开票的供应商,并点击确认!");
return;
}
var _venderId = DDL_VEND_LIST.SelectedValue;
_entity.VendId = _venderId;
}
else
{
if (CurrentUser.VenderList != null && CurrentUser.VenderList.Count > 0)
{
_entity.VendId = CurrentUser.VenderList[0];
}
}
if (CurrentUser.FactoryList != null && CurrentUser.FactoryList.Count > 0)
{
_entity.Site = CurrentUser.FactoryList[0];
}
_entity.InvoiceList = SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_BY_TIME(DP_CreateTime1.Text, DP_CreateTime2.Text, TXT_PO.Text, TXT_ASN.Text);
SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_List(_entity, (ret) =>
{
if (ret.State == ReturnStatus.Succeed)
{
if (_entity.InvoiceList == null || _entity.InvoiceList.Count == 0)
{
Alert.Show("未查询到符合条件的发票!");
}
p_action(ret.Result);
}
});
}
protected void btnView_OnClick(object sender, EventArgs e)
{
if (Grid_V_TB_INVOICE.SelectedRowIndexArray.Length != 1)
{
Alert.Show("请选择一行要操作的记录!");
return;
}
string roleID = GetSelectedDataKey(Grid_V_TB_INVOICE, 1);
string url = String.Format("../SupplierData/SCP_INVOICE_EDIT.aspx?ID={0}", roleID);
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
}
//显示面板
protected void btnShow_OnClick(object sender, EventArgs e)
{
gp1.Hidden = false;
}
//关闭面板
protected void OnClick(object sender, EventArgs e)
{
gp1.Hidden = true;
}
protected void Grid_V_TB_INVOICE_PageIndexChange(object sender, FineUI.GridPageEventArgs e)
{
BindInvoice();
}
protected void Grid_V_TB_INVOICE_RowDoubleClick(object sender, FineUI.GridRowClickEventArgs e)
{
//string roleID = GetSelectedDataKey(Grid1, 1);
//string url = String.Format("../SupplierData/InvoiceDetail.aspx?ID={0}", roleID);
//PageContext.RegisterStartupScript(Window1.GetShowReference(url));
}
protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid_V_TB_INVOICE.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
BindInvoice();
}
protected void BTN_SEARCH_Click(object sender, EventArgs e)
{
BindInvoice();
}
//导出
protected void btnOutput_OnClick(object sender, EventArgs e)
{
int[] _selections = Grid_V_TB_INVOICE.SelectedRowIndexArray;
if (_selections.Count() == 0)
{
Alert.Show("请选择发票记录导出!");
}
List<string> _ls = new List<string>();
for (int i = 0, count = Grid_V_TB_INVOICE.Rows.Count; i < count; i++)
{
if (_selections.Contains(i))
{
object[] rowDataKeys = Grid_V_TB_INVOICE.DataKeys[i];
_ls.Add(rowDataKeys[1] as string);
}
}
if (_ls.Count == 0)
{
Alert.Show("请选择记录导出!");
return;
}
DataSet ds = SCP_EXCEL_CONTROLLER.GET_INVOICE_EXECEL(_ls);
ds.Tables[1].Columns.Remove("成本价");
PageBase.DataSetToExcel(ds, "导出发票");
}
protected void Grid_V_TB_INVOICE_RowDataBound(object sender, GridRowEventArgs e)
{
int i = 0;
System.Web.UI.WebControls.Label _label = (System.Web.UI.WebControls.Label)Grid_V_TB_INVOICE.Rows[e.RowIndex].FindControl("Total1");
if (!string.IsNullOrEmpty(_label.Text))
{
try
{
if (decimal.Parse(_label.Text) < 0)
{
_label.ForeColor = Color.Red;
i++;
}
}
catch
{ }
}
//if (i > 0)
//{
// Alert.Show("请尽快处理索赔和退货数据,如果不处理新建发票将")
//}
}
protected void BTN_INV_Click(object sender, EventArgs e)
{
BindInvoice();
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindInvoice();
}
}
}