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.
 
 
 
 
 

272 lines
9.4 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.Text;
using CK.SCP.Models.Enums;
using Microsoft.Ajax.Utilities;
namespace SCP.Views.PlanData
{
public partial class SCP_PO_MATERIAL : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
}
}
public void LoadData()
{
if (CurrentUser.FactoryList == null || CurrentUser.FactoryList.Count == 0)
{
Alert.Show("当前用户未选择地点");
return;
}
BindOrder();
}
public void BindOrder()
{
SearchV_TB_MPO((result) =>
{
Grid_V_TB_MPO.RecordCount = result.Count();
var list = SortAndPage<V_TB_MPO>(result, Grid_V_TB_MPO);
Grid_V_TB_MPO.DataSource = list;
Grid_V_TB_MPO.DataBind();
});
}
public void SearchV_TB_MPO(Action<IQueryable<V_TB_MPO>> p_action)
{
V_TB_MPO _entity = new V_TB_MPO();
if (this.DP_StartDate.SelectedDate != null)
{
_entity.DocDateBegin = Convert.ToDateTime(DP_StartDate.SelectedDate);
}
if (DP_EndDate.SelectedDate != null)
{
_entity.DocDateEnd = Convert.ToDateTime(DP_EndDate.SelectedDate);
}
if (!string.IsNullOrWhiteSpace(TXT_CreatedByDesc.Text))
{
_entity.CreatedBy = TXT_CreatedByDesc.Text.Trim();
}
if (!string.IsNullOrWhiteSpace(TXT_VendorNO.Text))
{
_entity.VendorNO = TXT_VendorNO.Text.Trim();
}
if (!string.IsNullOrWhiteSpace(TXT_VendorNO.Text))
{
_entity.VendorNO = TXT_VendorNO.Text.Trim();
}
if (!string.IsNullOrWhiteSpace(TXT_VendorDesc.Text))
{
_entity.VendorDesc = TXT_VendorDesc.Text.Trim();
}
if (!string.IsNullOrWhiteSpace(TXT_PurdocNO.Text))
{
_entity.PurdocNO = TXT_PurdocNO.Text.Trim();
}
if (!string.IsNullOrEmpty( DDL_State.SelectedValue))
{
_entity.AcceptStatusSelect = DDL_State.SelectedValue;
}
_entity.UserInVendIds = CurrentUser.VenderList;
SCP_MPO_CONTROLLER.Get_V_TB_MPO_List(_entity, (_ret) =>
{
if (_ret.State == ReturnStatus.Succeed)
{
p_action(_ret.Result);
}
});
}
protected void Grid_V_TB_MPO_RowDoubleClick(object sender, FineUI.GridRowClickEventArgs e)
{
int[] selections = Grid_V_TB_MPO.SelectedRowIndexArray;
List<string> NOList = new List<string>();
if (selections.Count() > 0)
{
foreach (int rowIndex in selections)
{
NOList.Add(Grid_V_TB_MPO.DataKeys[rowIndex][1] as string);
}
string BillNum = String.Join(",", NOList);
string url = string.Format("../PlanData/SCP_MPO_DETAIL.aspx?PurdocNO={0}", BillNum);
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
}
else
{
Alert.Show("请选择数据后再进行查看明细");
return;
}
}
protected void Grid_V_TB_MPO_PageIndexChange(object sender, FineUI.GridPageEventArgs e)
{
BindOrder();
}
/// <summary>
/// 导出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOutput_Click(object sender, EventArgs e)
{
int[] selections = Grid_V_TB_MPO.SelectedRowIndexArray;
List<string> NOList = new List<string>();
if (selections.Count() > 0)
{
foreach (int rowIndex in selections)
{
var ctypesta = Grid_V_TB_MPO.DataKeys[rowIndex][13] as string;
if (ctypesta == "D")
{
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("选中的数据包含作废信息,请重新选择!"));
return;
}
NOList.Add(Grid_V_TB_MPO.DataKeys[rowIndex][1] as string);
}
}
else
{
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有选择数据!"));
return;
}
NOList = NOList.Distinct().ToList();
var ret = SCP_MPO_CONTROLLER.GetMPODetailList(NOList);
Dictionary<string, string> cellheader = new Dictionary<string, string>
{
{ "PurdocNO", "订单号" },
{"PURDOCITEMNO","行号" },
{ "PurchaseReqNO", "申请单号" },
{ "ProposerDesc", "申请人" },
{"State_DESC","状态" },
{ "OASTATUS", "OA审批状态" },
{ "MtlNO", "物料号" },
{ "Shorttext", "物料描述" },
{ "SizeCol", "型号规格" },
{ "Matbrand", "材料牌号" },
{ "Unitdes", "单位" },
{ "Quantity", "数量" },
{ "PRICE", "价格" },
{ "NetValue", "金额" },
{ "PurinfoReCord", "采购信息" },
{ "ItemDeliveryDate", "要求到货日期" },
{ "Glaccnum", "科目" },
{ "CostCenterDes", "成本中心" },
{ "StoreLocation", "存储地点" },
{ "CType_DESC","是否已作废"},
};
string url = EntityListToExcel2003(cellheader, ret.ToList(), "一般材料采购订单明细");
}
protected void btnDetail_Click(object sender, EventArgs e)
{
int[] selections = Grid_V_TB_MPO.SelectedRowIndexArray;
List<string> NOList = new List<string>();
if (selections.Count() > 0)
{
foreach (int rowIndex in selections)
{
NOList.Add(Grid_V_TB_MPO.DataKeys[rowIndex][1] as string);
}
string BillNum = String.Join(",", NOList);
string url = string.Format("../PlanData/SCP_MPO_DETAIL.aspx?PurdocNO={0}", BillNum);
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
}
else
{
Alert.Show("请选择数据后再进行查看明细");
return;
}
}
protected void btnShow_Click(object sender, EventArgs e)
{
gp1.Hidden = false;
}
protected void BtnClose_Click(object sender, EventArgs e)
{
gp1.Hidden = true;
}
protected void BtnSearch_Click(object sender, EventArgs e)
{
BindOrder();
}
protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid_V_TB_MPO.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
BindOrder();
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindOrder();
}
///// <summary>
///// 打印
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//protected void btnPrinter_Click(object sender, EventArgs e)
//{
// int[] selections = Grid_V_TB_MPO.SelectedRowIndexArray;
// string PurdocNO = "";
// int acc = 0;
// string status = "";
// if (selections.Count() == 0)
// {
// Alert.Show("请选择要打印的数据");
// return;
// }
// else if (selections.Count() > 1)
// {
// Alert.Show("只能选择一条数据进行打印");
// return;
// }
// else
// {
// foreach (int rowIndex in selections)
// {
// PurdocNO = Grid_V_TB_MPO.DataKeys[rowIndex][1] as string;
// acc = int.Parse(Grid_V_TB_MPO.DataKeys[rowIndex][7].ToString());
// status = Grid_V_TB_MPO.DataKeys[rowIndex][12] as string;
// if (status =="D")
// {
// Alert.Show("已作废的数据不可以进行打印");
// return;
// }
// }
// if (acc == (int)GeneralMaterialOrderState.New)
// {
// Alert.Show("供应商确认过的数据才可以打印");
// return;
// }
// var str = string.Format("window.open(\"../../Handlers/GenerateReport.ashx?report=GeneralMaterialOrder&data=131&type=pdf&filename=标签.pdf&PurdocNO={0}&open=\")", PurdocNO);
// PageContext.RegisterStartupScript(str);
// }
//}
}
}