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.
352 lines
12 KiB
352 lines
12 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;
|
|
using System.Data;
|
|
|
|
namespace SCP.WarehouseData
|
|
{
|
|
public partial class SCP_RECEIVE : PageBase
|
|
{
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
IsRoleRight();
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
LoadData();
|
|
}
|
|
}
|
|
public void IsRoleRight()
|
|
{
|
|
|
|
if (CurrentUser.RoleList.Contains("计划人员"))
|
|
{
|
|
btnReject.Hidden = false;
|
|
}
|
|
else
|
|
{
|
|
btnReject.Hidden = true;
|
|
}
|
|
if (CurrentUser.FactoryList == null || CurrentUser.FactoryList.Count == 0)
|
|
{
|
|
Alert.Show("当前用户未选择地点!");
|
|
return;
|
|
}
|
|
}
|
|
public void LoadData()
|
|
{
|
|
Grid_V_TB_RECEIVE.PageSize = ConfigHelper.PageSize;
|
|
ddlGridPageSize.SelectedValue = ConfigHelper.PageSize.ToString();
|
|
BindData();
|
|
}
|
|
|
|
public void BindData()
|
|
{
|
|
var _entity = new V_TB_RECEIVE();
|
|
_entity.RecvBillNum=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 = "退货单";
|
|
}
|
|
}
|
|
|
|
_entity.UserInAddress = CurrentUser.FactoryList;
|
|
_entity.UserInVendIds = CurrentUser.VenderList;
|
|
_entity.VendName = txtSupplier.Text;//供应商
|
|
_entity.PoBillNum = txtPO.Text;//订单号
|
|
_entity.AsnBillNum = AsnBillNum.Text;//发货单号
|
|
_entity.OperName = OperName.Text;//操作员
|
|
|
|
SCP_RECIVECE_CONTROLLER.Get_V_TB_RECEIVE_GG_List(_entity, (ret) =>
|
|
{
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
Grid_V_TB_RECEIVE.RecordCount =ret.Result.Count();
|
|
var _list= SortAndPage(ret.Result, Grid_V_TB_RECEIVE);
|
|
Grid_V_TB_RECEIVE.DataSource =_list;
|
|
Grid_V_TB_RECEIVE.DataBind();
|
|
}
|
|
});
|
|
|
|
}
|
|
protected void ddlGridPageSize_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid_V_TB_RECEIVE.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
|
|
BindData();
|
|
}
|
|
protected void Grid1_OnRowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
string ID = GetSelectedDataKey(Grid_V_TB_RECEIVE, 1);
|
|
string Site = GetSelectedDataKey(Grid_V_TB_RECEIVE, 4);
|
|
|
|
string STATE = Grid_V_TB_RECEIVE.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("../WarehouseData/SCP_RECEIVE_DETAIL.aspx?ID={0}&STATE={1}&Site={2}", ID, STATE,Site);
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
|
|
}
|
|
|
|
//明细
|
|
protected void btnDetail_OnClick(object sender, EventArgs e)
|
|
{
|
|
List<int> listids = GetSelectedDataKeyIDs(Grid_V_TB_RECEIVE);
|
|
if (listids.Count == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("请勾选要查看明细的单据"));
|
|
return;
|
|
}
|
|
|
|
if (listids.Count > 1)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("只能查看一条单据的明细"));
|
|
return;
|
|
}
|
|
|
|
string STATE = Grid_V_TB_RECEIVE.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_RECEIVE, 1);
|
|
string url = String.Format("../WarehouseData/SCP_RECEIVE_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_RECEIVE);
|
|
if (listids.Count == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("请勾选要审核的单据"));
|
|
return;
|
|
}
|
|
var _ls = new List<string>();
|
|
var _ls1 = new List<string>();
|
|
int[] selections = Grid_V_TB_RECEIVE.SelectedRowIndexArray;
|
|
for (int i = 0, count = Grid_V_TB_RECEIVE.Rows.Count; i < count; i++)
|
|
{
|
|
if (selections.Contains(i))
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_RECEIVE.DataKeys[i];
|
|
if (CurrentUser.UsedDomain == "CNH")
|
|
{
|
|
string _createtime = rowDataKeys[6].ToString();
|
|
if (int.Parse(DateTime.Parse(_createtime).ToString("yyMMdd")) < int.Parse("200531"))
|
|
{
|
|
Alert.Show("请选择2020-06-01之后数据审核!");
|
|
return;
|
|
}
|
|
}
|
|
_ls.Add(rowDataKeys[1] as string);
|
|
var erpRec = rowDataKeys[2] as string;
|
|
if (string.IsNullOrEmpty(erpRec))
|
|
{
|
|
Alert.Show("Erp收货单号不能为空,请稍后审核!");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
var ret = SCP_RECIVECE_CONTROLLER.Save_TB_RECEIVE_STATE(_ls, ReceiveState.Check, strUserName,CurrentUser.UsedDomain);
|
|
PageContext.RegisterStartupScript(Alert.GetShowInParentReference("审核成功"));
|
|
BindData();
|
|
}
|
|
|
|
protected void Grid1_OnPageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid_V_TB_RECEIVE.PageIndex = e.NewPageIndex;
|
|
BindData();
|
|
}
|
|
//导出
|
|
protected void btnOutput_OnClick(object sender, EventArgs e)
|
|
{
|
|
|
|
var _entity = new V_TB_RECEIVE();
|
|
_entity.RecvBillNum = 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 = "退货单";
|
|
}
|
|
}
|
|
|
|
_entity.UserInAddress = CurrentUser.FactoryList;
|
|
_entity.UserInVendIds = CurrentUser.VenderList;
|
|
_entity.VendName = txtSupplier.Text;//供应商
|
|
_entity.PoBillNum = txtPO.Text;//订单号
|
|
_entity.AsnBillNum = AsnBillNum.Text;//发货单号
|
|
_entity.OperName = OperName.Text;//操作员
|
|
List<string> _ls = new List<string>();
|
|
SCP_RECIVECE_CONTROLLER.Get_V_TB_RECEIVE_GG_List(_entity, (ret) =>
|
|
{
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
_ls = ret.Result.Select(p => p.RecvBillNum).ToList();
|
|
DataSet ds = null;
|
|
if (CurrentUser.VenderList.Count > 0)
|
|
{
|
|
ds = SCP_RECIVECE_CONTROLLER.GET_RECEIVE_EXECEL(_ls,CurrentUser.UsedDomain, CurrentUser.VenderList.FirstOrDefault());
|
|
}
|
|
else
|
|
{
|
|
ds = SCP_RECIVECE_CONTROLLER.GET_RECEIVE_EXECEL(_ls,CurrentUser.UsedDomain);
|
|
}
|
|
|
|
PageBase.DataSetToExcel(ds, "收货退货单");
|
|
}
|
|
});
|
|
|
|
|
|
|
|
}
|
|
protected void BtnSearchDetail_Click(object sender , EventArgs e)
|
|
{
|
|
string RecvBillNum = txtReceiveBill.Text;
|
|
string VendName = txtSupplier.Text;
|
|
string State = ddl.SelectedValue;
|
|
string PartCode = TXT_PartCode.Text;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../北京安通林/SCP_RECEIVE_DETAIL.aspx?ID={0}&&VendName={1}&&State={2}&&PartCode={3}", RecvBillNum, VendName, State, PartCode)));
|
|
}
|
|
|
|
protected void btnReject_Click(object sender, EventArgs e)
|
|
{
|
|
//ICollection<Role> Roles = CurrentUser.Roles;
|
|
//string strUserName = CurrentUser.ChineseName;
|
|
|
|
//List<int> listids = GetSelectedDataKeyIDs(Grid_V_TB_RECEIVE);
|
|
//if (listids.Count == 0)
|
|
//{
|
|
// PageContext.RegisterStartupScript(Alert.GetShowInParentReference("请勾选要报废的单据"));
|
|
// return;
|
|
//}
|
|
|
|
//var _ls = new List<string>();
|
|
//var _ls1 = new List<string>();
|
|
//int[] selections = Grid_V_TB_RECEIVE.SelectedRowIndexArray;
|
|
//for (int i = 0, count = Grid_V_TB_RECEIVE.Rows.Count; i < count; i++)
|
|
//{
|
|
// if (selections.Contains(i))
|
|
// {
|
|
// object[] rowDataKeys = Grid_V_TB_RECEIVE.DataKeys[i];
|
|
// _ls.Add(rowDataKeys[1] as string);
|
|
// var state= rowDataKeys[3].ToString();
|
|
// if(state!="0")
|
|
// {
|
|
// Alert.Show("只能选择状态为【收货状态】退货单据!");
|
|
// return;
|
|
// }
|
|
// }
|
|
//}
|
|
//if (_ls.Select(p => p.Contains("C.")).Count() > 0)
|
|
//{
|
|
// PageContext.RegisterStartupScript(Alert.GetShowInParentReference("只能报废退货单!"));
|
|
// return;
|
|
//}
|
|
|
|
|
|
//var ret = SCP_RECIVECE_CONTROLLER.Save_TB_RECEIVE_STATE(_ls, ReceiveState.Reject, strUserName);
|
|
//PageContext.RegisterStartupScript(Alert.GetShowInParentReference("报废成功"));
|
|
BindData();
|
|
}
|
|
}
|
|
}
|