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.
189 lines
6.0 KiB
189 lines
6.0 KiB
using CK.SCP.Controller;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
|
|
using CK.SCP.Utils;
|
|
using FineUI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace SCP.Views.BasicData
|
|
{
|
|
public partial class SCP_TA_VEND_PART : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BindData();
|
|
}
|
|
}
|
|
//
|
|
public void BindData()
|
|
{
|
|
Search(rs =>{
|
|
Grid1.RecordCount = rs.Count();
|
|
var list = SortAndPage<V_TA_VEND_PART>(rs, Grid1);
|
|
list.ToList().ForEach(p => {
|
|
p.PartDesc = (!string.IsNullOrEmpty(p.PartDesc1) ? p.PartDesc1 : string.Empty)
|
|
+ (!string.IsNullOrEmpty(p.PartDesc2) ? p.PartDesc2 : string.Empty); });
|
|
Grid1.DataSource = list;
|
|
|
|
Grid1.DataBind();
|
|
});
|
|
|
|
}
|
|
private void Search(Action<IQueryable<V_TA_VEND_PART>> p_action)
|
|
{
|
|
V_TA_VEND_PART _entity = new V_TA_VEND_PART();
|
|
_entity.VendId = txtVendId.Text;
|
|
_entity.PartCode = txtPartCode.Text;
|
|
_entity.ProjectId = txtProjectId.Text;
|
|
_entity.UserInAddress = CurrentUser.FactoryList;
|
|
|
|
SCP_V_TA_VEND_PART_CONTROLLER.Get_V_TA_VEND_PART_List(_entity, (rs) => {
|
|
if (rs.State == ReturnStatus.Succeed)
|
|
{
|
|
p_action(rs.Result);
|
|
}
|
|
});
|
|
}
|
|
|
|
//导出
|
|
public void BtnOutPut_OnClick(object sender, EventArgs e)
|
|
{
|
|
|
|
//Dictionary<string, string> cellheader = new Dictionary<string, string> {
|
|
// { "VendId", "供应商编号" },
|
|
// { "VendName", "供应商名称" },
|
|
// { "VendAbbCode", "供应商缩写" },
|
|
// { "VendType", "供应商类型" },
|
|
// { "Country", "国家" },
|
|
// { "City", "城市" },
|
|
// { "Currency", "币种" },
|
|
// { "Address", "地址" },
|
|
// { "ZipCode", "邮编" },
|
|
// { "Contacter", "联系人" },
|
|
// { "Phone", "电话" },
|
|
// { "Fax", "传真" },
|
|
// { "Email", "电子邮件" },
|
|
// { "State", "状态" },
|
|
// { "Remark", "备注" },
|
|
//};
|
|
//string url = EntityListToExcel2003(cellheader, list, "供应商");
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询
|
|
protected void btnSearch_OnClick(object sender, EventArgs e)
|
|
{
|
|
BindData();
|
|
}
|
|
|
|
//显示
|
|
//protected void btnShow_OnClick(object sender, EventArgs e)
|
|
//{
|
|
// gp1.Hidden = false;
|
|
//}
|
|
////关闭
|
|
//protected void btnClose_OnClick(object sender, EventArgs e)
|
|
//{
|
|
// gp1.Hidden = true;
|
|
//}
|
|
|
|
protected void Grid1_OnPageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindData();
|
|
}
|
|
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
BindData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传文件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnInput_Click(object sender, EventArgs e)
|
|
{
|
|
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_VENDER_PART_EXPORT>(ExcelHelper.RemoveEmpty(_dt)).ToList();
|
|
var ret = SCP_PO_CONTROLLER.EXCEL_VENDER_PART_MOD(list, CurrentUser.Name);
|
|
if (ret.State == ReturnStatus.Succeed && ret.Result == true)
|
|
{
|
|
Alert.Show("导入成功");
|
|
BindData();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(string.Join("<br>", ret.MessageList));
|
|
}
|
|
}
|
|
protected void LinkButton_Click(object sender, EventArgs e)
|
|
{
|
|
Alert.Show($"<a href=\'/uploadfiles/{"供应商零件.xlsx"}\'>{"供应商零件.xlsx"}</a>", "请点击文件名下载", MessageBoxIcon.Information);
|
|
}
|
|
|
|
protected void Btn_Click(object sender, EventArgs e)
|
|
{
|
|
Search(rs => {
|
|
var list = rs.ToList();
|
|
list.ForEach(p => {
|
|
p.PartDesc = (!string.IsNullOrEmpty(p.PartDesc1) ? p.PartDesc1 : string.Empty)
|
|
+ (!string.IsNullOrEmpty(p.PartDesc2) ? p.PartDesc2 : string.Empty);
|
|
});
|
|
|
|
Dictionary<string, string> cellheader = new Dictionary<string, string> {
|
|
{ "ProjectId", "项目编号" },
|
|
{ "VendId", "供应商代码" },
|
|
{ "VendName", "供应商名称" },
|
|
{ "PartCode", "零件号" },
|
|
{ "PartDesc", "零件名称" },
|
|
{ "VendPartCode", "供应商零件" },
|
|
{ "VendPackQty", "标包数" },
|
|
{ "MinPackQty", "小包装数" },
|
|
{ "PalletPackQty", "托盘包装数" },
|
|
{ "PoUnit", "单位" }
|
|
|
|
};
|
|
string url = EntityListToExcel2003(cellheader, list, "供应商零件");
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
//protected void Grid1_OnSort(object sender, GridSortEventArgs e)
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
}
|