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.

255 lines
9.6 KiB

using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Utils;
using CK.SCP.Controller;
using FineUI;
using CK.SCP.Models.AppBoxEntity;
namespace SCP.Views.SupplierData
{
public partial class SCP_ARRIVE : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
IsRoleRight();
if (!IsPostBack)
{
LoadData();
}
}
public void IsRoleRight()
{
if (!CurrentUser.RoleList.Contains("采购负责人"))
{
Alert.Show("当前用户角色不能操作该模块!");
return;
}
if (CurrentUser.FactoryList == null || CurrentUser.FactoryList.Count == 0)
{
Alert.Show("当前用户未选择地点!");
return;
}
}
public void LoadData()
{
Grid_V_TB_ARRIVE.PageSize = ConfigHelper.PageSize;
ddlGridPageSize.SelectedValue = ConfigHelper.PageSize.ToString();
BindData();
}
public void BindData()
{
var _entity = new V_TB_ARRIVE();
_entity.ArrvBillNum = txtReceiveBill.Text;//单据号
if (!string.IsNullOrEmpty(ddl.SelectedValue))
{
//已收货:0,审核通过:1,已开票,2
int istate = Convert.ToInt32(ddl.SelectedValue);
if (istate == 0)
{
_entity.State = 0;
}
else if (istate == 1)
{
_entity.State = 1;
}
else if (istate == 2)
{
_entity.State = 2;
}
}
else
{
_entity.State = -1;
}
if (!string.IsNullOrEmpty(ddtype.SelectedValue))
{
string istate = ddtype.SelectedValue;
if (istate == "收货单")
{
_entity.BillType_DESC = "收货单";
}
else if (istate == "退货单")
{
_entity.BillType_DESC = "退货单";
}
}
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.VendName = txtSupplier.Text;//供应商
_entity.PoBillNum = txtPO.Text;//订单号
_entity.AsnBillNum = AsnBillNum.Text;//发货单号
_entity.OperName = OperName.Text;//操作员
SCP_RECIVECE_CONTROLLER.Get_V_TB_ARRIVE_List(_entity, (ret) =>
{
if (ret.State == ReturnStatus.Succeed)
{
Grid_V_TB_ARRIVE.RecordCount = ret.Result.Count();
var _list = SortAndPage(ret.Result, Grid_V_TB_ARRIVE);
Grid_V_TB_ARRIVE.DataSource = _list;
Grid_V_TB_ARRIVE.DataBind();
}
});
}
protected void ddlGridPageSize_OnSelectedIndexChanged(object sender, EventArgs e)
{
Grid_V_TB_ARRIVE.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
BindData();
}
protected void Grid1_OnRowDoubleClick(object sender, GridRowClickEventArgs e)
{
string ID = GetSelectedDataKey(Grid_V_TB_ARRIVE, 1);
string STATE = Grid_V_TB_ARRIVE.Rows[e.RowIndex].Values[0].ToString();
if (string.IsNullOrEmpty(STATE))
{
STATE = "0";
}
if (STATE != "0" && STATE != "1" && STATE != "2")
{
STATE = "0";
}
string url = String.Format("../SupplierData/SCP_ARRIVE_DETAIL.aspx?ID={0}&STATE={1}", ID, STATE);
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
}
//明细
protected void btnDetail_OnClick(object sender, EventArgs e)
{
List<int> listids = GetSelectedDataKeyIDs(Grid_V_TB_ARRIVE);
if (listids.Count == 0)
{
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("请勾选要查看明细的单据"));
return;
}
if (listids.Count > 1)
{
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("只能查看一条单据的明细"));
return;
}
string STATE = Grid_V_TB_ARRIVE.SelectedRow.Values[0].ToString();
if (string.IsNullOrEmpty(STATE))
{
STATE = "0";
}
if (STATE != "0" && STATE != "1" && STATE != "2")
{
STATE = "0";
}
string roleID = GetSelectedDataKey(Grid_V_TB_ARRIVE, 1);
string url = String.Format("../SupplierData/SCP_ARRIVE_DETAIL.aspx?ID={0}&STATE={1}", roleID, STATE);
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
}
//查询
protected void BtnSearch_OnClick(object sender, EventArgs e)
{
BindData();
}
//显示面板
protected void btnShow_OnClick(object sender, EventArgs e)
{
gp1.Hidden = false;
}
//关闭面板
protected void OnClick(object sender, EventArgs e)
{
gp1.Hidden = true;
}
//审核通过
protected void btnCheck_OnClick(object sender, EventArgs e)
{
ICollection<Role> Roles = CurrentUser.Roles;
string strUserName = CurrentUser.ChineseName;
List<int> listids = GetSelectedDataKeyIDs(Grid_V_TB_ARRIVE);
if (listids.Count == 0)
{
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("请勾选要审核的单据"));
return;
}
var _ls = new List<string>();
int[] selections = Grid_V_TB_ARRIVE.SelectedRowIndexArray;
for (int i = 0, count = Grid_V_TB_ARRIVE.Rows.Count; i < count; i++)
{
if (selections.Contains(i))
{
object[] rowDataKeys = Grid_V_TB_ARRIVE.DataKeys[i];
_ls.Add(rowDataKeys[1] as string);
}
}
var ret = SCP_RECIVECE_CONTROLLER.Save_TB_ARRIVE_STATE(_ls, ReceiveState.Check, strUserName);
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("审核成功"));
BindData();
}
protected void Grid1_OnPageIndexChange(object sender, GridPageEventArgs e)
{
Grid_V_TB_ARRIVE.PageIndex = e.NewPageIndex;
BindData();
}
//导出
protected void btnOutput_OnClick(object sender, EventArgs e)
{
var _entity = new V_TB_ARRIVE();
_entity.ArrvBillNum = txtReceiveBill.Text;
if (!string.IsNullOrEmpty(ddl.SelectedValue))
{
_entity.State = Convert.ToInt32(ddl.SelectedValue);
}
else
{
_entity.State = -1;
}
_entity.PoBillNum = txtPO.Text;
_entity.AsnBillNum = AsnBillNum.Text;
_entity.OperName = OperName.Text;
SCP_RECIVECE_CONTROLLER.Get_V_TB_ARRIVE_List(_entity, (ret) =>
{
if (ret.State == ReturnStatus.Succeed)
{
Dictionary<string, string> cellheader = new Dictionary<string, string>
{
{ "State_DESC", "状态" },
//{ "AsnBillNum", "单据类型" },
{ "VendName", "供应商" },
{ "ArrvBillNum", "单据号" },
{ "PoBillNum", "订单号" },
{ "AsnBillNum", "发货单号" },
{ "ShipTime", "时间" },
{ "Site_Desc", "地点" },
{ "BillType_DESC", "类型" },
{ "OperName", "审核员" },
{ "Remark", "备注" },
};
string url = EntityListToExcel2003(cellheader, ret.Result.ToList(), "审核明细");
}
});
}
}
}