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.
307 lines
11 KiB
307 lines
11 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Utils;
|
|
using CK.SCP.Controller;
|
|
using FineUI;
|
|
using System.IO;
|
|
using System.Data;
|
|
using CK.SCP.Models.ScpEntity.ExcelImportEntity;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Common;
|
|
using CK.SCP.Models;
|
|
using System.Text;
|
|
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
|
|
|
|
namespace SCP.PlanData
|
|
{
|
|
public partial class SCP_PO_EXTEND : 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_PO((result)=> {
|
|
Grid_V_TB_PO.RecordCount = result.Count();
|
|
var list = SortAndPage<V_TB_PO>(result, Grid_V_TB_PO);
|
|
Grid_V_TB_PO.DataSource = list;
|
|
Grid_V_TB_PO.DataBind();
|
|
});
|
|
|
|
}
|
|
public void SearchV_TB_PO(Action<IQueryable<V_TB_PO>> p_action)
|
|
{
|
|
var ls=SCPDB.TB_FACTORY.Where(p => p.ErpDomain == CurrentUser.UsedDomain).ToList();
|
|
DropDownList1.DataSource = ls;
|
|
DropDownList1.DataBind();
|
|
V_TB_PO _entity = new V_TB_PO();
|
|
_entity.IsDeleted = false;
|
|
if (this.DP_StartDate.SelectedDate != null)
|
|
{
|
|
_entity.BeginTime = DP_StartDate.SelectedDate;
|
|
}
|
|
if (DP_EndDate.SelectedDate != null)
|
|
{
|
|
_entity.BeginTime = DP_EndDate.SelectedDate;
|
|
}
|
|
if (!string.IsNullOrEmpty(DDL_State.SelectedValue))
|
|
{
|
|
_entity.State = int.Parse(DDL_State.SelectedValue);
|
|
}
|
|
_entity.VendId = TXT_Vendid.Text;
|
|
_entity.PoBillNum = TXT_BillNo.Text;
|
|
_entity.VendName = TXT_VendName.Text;
|
|
if (!string.IsNullOrEmpty(rblist.SelectedValue))
|
|
{
|
|
_entity.ModType =ConvertHelper.To<int> (rblist.SelectedValue);
|
|
}
|
|
_entity.ErpBillNum = TXT_ProjectId.Text;
|
|
_entity.SubSite = DropDownList1.SelectedValue;
|
|
_entity.IsDeleted = false;
|
|
_entity.UserInAddress = CurrentUser.FactoryList;
|
|
_entity.UserInVendIds = CurrentUser.VenderList;
|
|
SCP_PO_CONTROLLER.Get_V_TB_PO_List(_entity, (_ret) => {
|
|
if (_ret.State == ReturnStatus.Succeed)
|
|
{
|
|
p_action(_ret.Result);
|
|
}
|
|
});
|
|
}
|
|
|
|
protected void Grid_V_TB_PO_RowDoubleClick(object sender, FineUI.GridRowClickEventArgs e)
|
|
{
|
|
//object[] rowDataKeys = Grid_V_TB_PO.DataKeys[e.RowIndex];
|
|
|
|
//string PoBillNum = rowDataKeys[1] as string;
|
|
//string VendID = rowDataKeys[3] as string;
|
|
//PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_PO_DETAIL.aspx?PoBillNum={0}", PoBillNum)));
|
|
}
|
|
|
|
protected void Grid_V_TB_PO_PageIndexChange(object sender, FineUI.GridPageEventArgs e)
|
|
{
|
|
BindOrder();
|
|
}
|
|
|
|
protected void Grid_V_TB_PO_Sort(object sender, FineUI.GridSortEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void btnOutput_Click(object sender, EventArgs e)
|
|
{
|
|
int[] _selections = Grid_V_TB_PO.SelectedRowIndexArray;
|
|
if (_selections.Count() == 0)
|
|
{
|
|
Alert.Show("请选择订单记录导出!");
|
|
}
|
|
List<string> _ls = new List<string>();
|
|
for (int i = 0, count = Grid_V_TB_PO.Rows.Count; i < count; i++)
|
|
{
|
|
if (_selections.Contains(i))
|
|
{
|
|
|
|
object[] rowDataKeys = Grid_V_TB_PO.DataKeys[i];
|
|
_ls.Add(rowDataKeys[1] as string);
|
|
}
|
|
}
|
|
if (_ls.Count == 0)
|
|
{
|
|
Alert.Show("请选择记录导出!");
|
|
return;
|
|
}
|
|
//List<string> _ls = new List<string>();
|
|
//for (int i = 0, count = Grid_V_TB_PO.Rows.Count; i < count; i++)
|
|
//{
|
|
// object[] rowDataKeys = Grid_V_TB_PO.DataKeys[i];
|
|
// _ls.Add(rowDataKeys[1] as string);
|
|
//}
|
|
DataSet ds =SCP_EXCEL_CONTROLLER.GET_PO_EXECEL(_ls);
|
|
PageBase.DataSetToExcel(ds, "采购订单");
|
|
|
|
}
|
|
|
|
protected void btnDetail_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid_V_TB_PO.SelectedRowIndexArray.Count() == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有选择数据!"));
|
|
return;
|
|
}
|
|
object[] rowDataKeys = Grid_V_TB_PO.DataKeys[Grid_V_TB_PO.SelectedRowIndex];
|
|
if (rowDataKeys != null)
|
|
{
|
|
string PoBillNum = rowDataKeys[1] as string;
|
|
string VendID = rowDataKeys[3] as string;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_PO_DETAIL.aspx?PoBillNum={0}", PoBillNum)));
|
|
}
|
|
}
|
|
|
|
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_PO.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
|
|
BindOrder();
|
|
}
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindOrder();
|
|
}
|
|
|
|
protected void BTN_CREATE_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid_V_TB_PO.SelectedRowIndexArray.Count() == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有选择数据!"));
|
|
return;
|
|
}
|
|
|
|
object[] rowDataKeys = Grid_V_TB_PO.DataKeys[Grid_V_TB_PO.SelectedRowIndex];
|
|
if ( ConvertHelper.To<int>(rowDataKeys[9])== 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("当前订单处于关闭状态,不能创建要货看板!"));
|
|
return;
|
|
}
|
|
|
|
if (rowDataKeys != null)
|
|
{
|
|
string PoBillNum = rowDataKeys[1] as string;
|
|
string VendID = rowDataKeys[3] as string;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_PO_CREATE_ASK.aspx?PoBillNum={0}", PoBillNum)));
|
|
}
|
|
}
|
|
|
|
protected void BtnSearchDetail_Click(object sender, EventArgs e)
|
|
{
|
|
string PoBillNum = TXT_BillNo.Text ;
|
|
string VendName = TXT_VendName.Text;
|
|
string State = DDL_State.SelectedValue;
|
|
string PartCode = TXT_PartCode.Text;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_PO_DETAIL.aspx?PoBillNum={0}&&VendName={1}&&State={2}&&PartCode={3}", PoBillNum,VendName,State,PartCode)));
|
|
}
|
|
protected void btnModeType1_Click(object sender, EventArgs e)
|
|
{
|
|
rblist.SelectedValue = "1";
|
|
BindOrder();
|
|
}
|
|
|
|
protected void btnModeType2_Click(object sender, EventArgs e)
|
|
{
|
|
rblist.SelectedValue = "2";
|
|
BindOrder();
|
|
}
|
|
|
|
protected void Grid_V_TB_PO_RowSelect(object sender, GridRowSelectEventArgs e)
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_PO.DataKeys[e.RowIndex];
|
|
string PoBillNum = rowDataKeys[1] as string;
|
|
|
|
V_TB_PO_DETAIL _detail = new V_TB_PO_DETAIL();
|
|
_detail.PoBillNum = PoBillNum;
|
|
|
|
SCP_PO_CONTROLLER.Get_V_TB_PO_DETAIL_List(_detail, (_ret) =>
|
|
{
|
|
if (_ret.State == ReturnStatus.Succeed)
|
|
{
|
|
Grid_V_TB_PO_DETAIL.DataSource = SCP_CONTRACT_CONTROLLER.GET_CONTRACT_PRICE_LIST(SCP_PO_CONTROLLER.LOAD_PO_DETAIL_SUM(_ret.Result.ToList()));
|
|
Grid_V_TB_PO_DETAIL.DataBind();
|
|
}
|
|
});
|
|
}
|
|
|
|
protected void btnInput_Click_Contract(object sender, EventArgs e)
|
|
{
|
|
Excel_Input(BillModType.Contract);
|
|
}
|
|
protected void btnInput_Click_Non_Contract(object sender, EventArgs e)
|
|
{
|
|
Excel_Input(BillModType.Non_Contract);
|
|
}
|
|
protected void Excel_Input(BillModType p_modtype)
|
|
{
|
|
ResultObject<bool> saveret = new ResultObject<bool>();
|
|
string _fileName = FileUp.FileName;
|
|
if (string.IsNullOrEmpty(_fileName))
|
|
{
|
|
Alert.Show("选择文件为空!");
|
|
return;
|
|
}
|
|
string _lx = _fileName.Split('.')[1];
|
|
Stream _stream = FileUp.PostedFile.InputStream;
|
|
DataTable _dt = new DataTable();
|
|
if (_lx == "xls")
|
|
{
|
|
_dt = ExcelHelper.GetDataTable(_stream);
|
|
}
|
|
else
|
|
{
|
|
_dt = ExcelHelper.GetDataTableOfXlsx(_stream);
|
|
}
|
|
|
|
var list = ConvertHelper.ToList<SCP_PO_EXPORT_IMPORT_MODEL>(ExcelHelper.RemoveEmpty(_dt)).ToList();
|
|
var checkret = SCP_PO_CONTROLLER.Check_EXCEL_PO_MOD(list, p_modtype, CurrentUser.FactoryList[0], CurrentUser.SubSiteList[0]);
|
|
if (checkret.State == ReturnStatus.Failed && checkret.Result == false)
|
|
{
|
|
Alert.Show(string.Join("<br>", checkret.MessageList));
|
|
return;
|
|
}
|
|
if (ScpCache.Config.数据中心接口)
|
|
{
|
|
saveret = SCP_DC_UNI_CONTROLLER.WritePo(list, CurrentUser.FactoryList[0], CurrentUser.Name, DateTime.Now, p_modtype, CurrentUser.SubSiteList[0], CurrentUser.ChineseName, CurrentUser.CellPhone);
|
|
}
|
|
else
|
|
{
|
|
saveret = SCP_PO_CONTROLLER.Save_EXCEL_PO_MOD(list, CurrentUser.FactoryList[0], CurrentUser.Name, DateTime.Now, p_modtype, CurrentUser.SubSiteList[0], CurrentUser.ChineseName, CurrentUser.CellPhone);
|
|
}
|
|
if (saveret.State == ReturnStatus.Succeed && saveret.Result == true)
|
|
{
|
|
BindOrder();
|
|
Alert.Show("订单编号" + saveret.Message + "导入成功!");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//Alert.Show(string.Join("<br>", saveret.MessageList));
|
|
Alert.Show(saveret.Message);
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|