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.
 
 
 
 
 

216 lines
8.6 KiB

using CK.SCP.Controller;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Utils;
using FineUI;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SCP.Views.PlanData
{
public partial class SCP_PO_PLAN : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
BindVender(ddl_Vender);
}
}
public void LoadData()
{
if (CurrentUser.FactoryList == null || CurrentUser.FactoryList.Count == 0)
{
Alert.Show("当前用户未选择地点!");
return;
}
Bind();
}
public void Bind()
{
SearchV_TB_PO_PLANData((result) => {
Grid_V_TB_PO_PLAN.RecordCount = result.Count();
var list = SortAndPage<V_TB_PO_PLAN>(result, Grid_V_TB_PO_PLAN);
var _ls= list.ToList();
Grid_V_TB_PO_PLAN.DataSource = _ls;
Grid_V_TB_PO_PLAN.DataBind();
});
}
public void SearchV_TB_PO_PLANData(Action<IQueryable<V_TB_PO_PLAN>> p_action)
{
V_TB_PO_PLAN _entity = new V_TB_PO_PLAN();
_entity.PoBillNum= ddl_Vender.SelectedValue;
_entity.EndTime = DP_StartDate.SelectedDate;
if (CurrentUser.RoleList.Contains("供应商"))
{
if (CurrentUser.RoleList.Contains("计划人员") || CurrentUser.RoleList.Contains("采购人员") || CurrentUser.Name=="admin")
{
ddl_Vender.Hidden = false;
DP_StartDate.Hidden = false;
btnMake.Hidden = false;
btnSearch.Hidden = false;
}
else
{
ddl_Vender.Hidden = true;
DP_StartDate.Hidden = true;
btnMake.Hidden = true;
btnSearch.Hidden = true;
_entity.UserInVendIds = CurrentUser.VenderList;
_entity.UserInAddress = CurrentUser.FactoryList;
}
}
SCP_PLAN_CONTROLLER.Get_V_TB_PO_PLAN_List(_entity, (_ret) =>
{
if (_ret.State == ReturnStatus.Succeed)
{
p_action(_ret.Result);
}
});
}
protected void btnOutput_Click(object sender, EventArgs e)
{
SearchV_TB_PO_PLANData((rs) => {
var _list = rs.ToList();
Dictionary<string, string> cellheader = new Dictionary<string, string>();
cellheader.Add("PoBillNum", "订单编号");
cellheader.Add("AskBillNum", "看板编号");
cellheader.Add("PartCode", "零件编码");
cellheader.Add("PartDesc", "零件描述");
cellheader.Add("PlanQty", "数量");
cellheader.Add("PoUnit", "单位");
cellheader.Add("EndTime", "交货日期");
cellheader.Add("Version", "版本号");
cellheader.Add("Domain", "域名");
string url = EntityListToExcel2003(cellheader, _list, "预测导出");
});
}
protected void Grid_V_TB_PO_PLAN_RowDoubleClick(object sender, FineUI.GridRowClickEventArgs e)
{
object[] rowDataKeys = this.Grid_V_TB_PO_PLAN.DataKeys[e.RowIndex];
V_TB_PO_PLAN _entity = new V_TB_PO_PLAN();
_entity.Domain = rowDataKeys[0] as string;
_entity.PartCode = rowDataKeys[1] as string;
_entity.EndTime = ConvertHelper.To<DateTime>(rowDataKeys[2]);
_entity.PoBillNum = rowDataKeys[3] as string;
_entity.Site = rowDataKeys[4] as string;
_entity.AskBillNum = rowDataKeys[5] as string;
_entity.Version = rowDataKeys[6] as string;
_entity.PartDesc = rowDataKeys[7] as string;
_entity.PlanQty = ConvertHelper.To<decimal>(rowDataKeys[8]);
_entity.PoUnit = rowDataKeys[9] as string;
_entity.VendId = rowDataKeys[10] as string;
_entity.PoLine = ConvertHelper.To<int>(rowDataKeys[11]);
string _url = string.Format("../PlanData/SCP_PO_PLAN_DETAIL.aspx?PartCode={0}&&EndTime={1}&&PoBillNum={2}&&VendId={3}&&Domain={4}",
_entity.PartCode, _entity.EndTime.Value.ToString(), _entity.PoBillNum, _entity.VendId, _entity.Domain);
PageContext.RegisterStartupScript
(Window1.GetShowReference(_url));
}
protected void btnMake_Click(object sender, EventArgs e)
{
List<V_TB_PO_PLAN> _ls = new List<V_TB_PO_PLAN>();
int[] _selections = Grid_V_TB_PO_PLAN.SelectedRowIndexArray;
for (int i = 0, count = Grid_V_TB_PO_PLAN.Rows.Count; i < count; i++)
{
if (_selections.Contains(i))
{
V_TB_PO_PLAN _entity = new V_TB_PO_PLAN();
GridRow row = Grid_V_TB_PO_PLAN.Rows[i];
object[] rowDataKeys = Grid_V_TB_PO_PLAN.DataKeys[i];
_entity.Domain = rowDataKeys[0] as string;
_entity.PartCode = rowDataKeys[1] as string;
_entity.EndTime = ConvertHelper.To<DateTime>(rowDataKeys[2]);
_entity.PoBillNum = rowDataKeys[3] as string;
_entity.Site = rowDataKeys[4] as string;
_entity.AskBillNum = rowDataKeys[5] as string;
_entity.Version = rowDataKeys[6] as string;
_entity.PartDesc = rowDataKeys[7] as string;
_entity.PlanQty = ConvertHelper.To<decimal>(rowDataKeys[8]);
_entity.PoUnit = rowDataKeys[9] as string;
_entity.VendId = rowDataKeys[10] as string;
_entity.PoLine= ConvertHelper.To<int>(rowDataKeys[11]);
_ls.Add(_entity);
}
}
if (_ls.Count > 0)
{
var _count = _ls.Count(p => !string.IsNullOrEmpty(p.AskBillNum));
if (_count > 0)
{
Alert.Show("选择记录里有已生成要货看板记录!");
return;
}
}
var ret = SCP_PLAN_CONTROLLER.PLAN_TO_ASK(_ls, CurrentUser, true);
if (ret.State == ReturnStatus.Succeed && ret.Result == true)
{
Bind();
}
else
{
Alert.Show(string.Join("<br>", ret.MessageList));
}
}
protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Convert.ToInt32(ddlGridPageSize.SelectedValue);
Bind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Bind();
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
}
protected void Grid_V_TB_PO_PLAN_PageIndexChange(object sender, GridPageEventArgs e)
{
Bind();
}
protected void btnExecl_Click(object sender, EventArgs e)
{
if (CurrentUser.RoleList.Contains("供应商"))
{
if (CurrentUser.RoleList.Contains("计划人员") || CurrentUser.RoleList.Contains("采购人员") || CurrentUser.Name == "admin")
{
if (string.IsNullOrEmpty(ddl_Vender.SelectedValue))
{
Alert.Show("供应商选项不能为空");
return;
}
V_TB_PO_PLAN _plan = new V_TB_PO_PLAN();
_plan.PoBillNum = ddl_Vender.SelectedValue;
DataTable _tb = SCP_PLAN_CONTROLLER.Get_TB_PLAN_REPORT(_plan);
DataSet _ds = new DataSet();
_ds.Tables.Add(_tb);
DataSetToExcel(_ds, "导出计划");
}
else
{
V_TB_PO_PLAN _plan = new V_TB_PO_PLAN();
_plan.PoBillNum = CurrentUser.VenderList.FirstOrDefault();
DataTable _tb=SCP_PLAN_CONTROLLER.Get_TB_PLAN_REPORT(_plan);
DataSet _ds = new DataSet();
_ds.Tables.Add(_tb);
DataSetToExcel(_ds, "导出计划");
}
}
}
}
}