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.
220 lines
7.5 KiB
220 lines
7.5 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq.Dynamic;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
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 NPOI.HSSF.UserModel;
|
|
using NPOI.SS.UserModel;
|
|
using CK.SCP.Models;
|
|
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
|
|
|
|
namespace SCP.BasicData
|
|
{
|
|
public partial class Supplier : PageBase
|
|
{
|
|
private List<TA_VENDER> _list;
|
|
public int num;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BindData();
|
|
// BtnAdd.OnClientClick = Window1.GetShowReference("/BasicData/SupplierEdit.aspx", "新增");
|
|
}
|
|
}
|
|
//
|
|
public void BindData()
|
|
{
|
|
|
|
|
|
var _ls = ScpCache.FactoryList;
|
|
_ls.Insert(0, new TB_FACTORY() { FactoryId = "", FactoryName = "" });
|
|
DPL_Factory.DataSource = _ls;
|
|
DPL_Factory.DataBind();
|
|
// _list = SCP_TB_VENDER_CONTROLLER.Getlist();
|
|
_list= SearchData();
|
|
var list = Sort<TA_VENDER>(_list.AsQueryable(), Grid1);
|
|
|
|
Grid1.DataSource = list;
|
|
Grid1.RecordCount = list.Count();
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
//导出
|
|
public void BtnOutPut_OnClick(object sender, EventArgs e)
|
|
{
|
|
_list = SCP_TB_VENDER_CONTROLLER.Getlist();
|
|
var list = Sort<TA_VENDER>(_list.AsQueryable(), Grid1).ToList();
|
|
// 2.设置单元格抬头
|
|
// key:实体对象属性名称,可通过反射获取值
|
|
// value:Excel列的名称
|
|
Dictionary<string, string> cellheader = new Dictionary<string, string> {
|
|
{ "VendId", "供应商编号" },
|
|
{ "VendName", "供应商名称" },
|
|
{ "VendAbbCode", "供应商缩写" },
|
|
{ "VendType", "供应商类型" },
|
|
{ "Country", "国家" },
|
|
{ "City", "城市" },
|
|
{ "Currency", "币种" },
|
|
{ "Address", "地址" },
|
|
{ "ZipCode", "邮编" },
|
|
{ "Contacter", "联系人" },
|
|
{ "Phone", "电话" },
|
|
{ "Fax", "传真" },
|
|
{ "Email", "电子邮件" },
|
|
{ "State", "状态" },
|
|
{ "Remark", "备注" },
|
|
|
|
};
|
|
// { "TranscriptsEn.ChineseScores", "语文成绩" },
|
|
// { "TranscriptsEn.MathScores", "数学成绩" },
|
|
// 3.进行Excel转换操作,并返回转换的文件下载链接
|
|
string url = EntityListToExcel2003(cellheader, list, "供应商");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <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_EXPORT>(ExcelHelper.RemoveEmpty(_dt)).ToList();
|
|
var ret = SCP_PO_CONTROLLER.EXCEL_VENDER_MOD(list, CurrentUser.FactoryList[0], CurrentUser.Name);
|
|
if (ret.State == ReturnStatus.Succeed && ret.Result == true)
|
|
{
|
|
BindData();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(string.Join("<br>", ret.MessageList));
|
|
}
|
|
}
|
|
//public void BtnSave_OnClick(object sender, EventArgs e)
|
|
//{
|
|
// List<TA_VENDER> _list = new List<TA_VENDER>();
|
|
// for (int i = 0, count = Grid1.Rows.Count; i < count; i++)
|
|
// {
|
|
// GridRow row = Grid1.Rows[i];
|
|
// TA_VENDER _entity = new TA_VENDER();
|
|
// object[] rowDataKeys = Grid1.DataKeys[i];
|
|
// _entity.UID = ConvertHelper.To<Int32>(rowDataKeys[0]);
|
|
// System.Web.UI.WebControls.TextBox _txt = (System.Web.UI.WebControls.TextBox)row.FindControl("txtQuota");
|
|
// if (string.IsNullOrEmpty(_txt.Text))
|
|
// {
|
|
// _txt.Text = "0";
|
|
// }
|
|
// _entity.Quota = decimal.Parse(_txt.Text);
|
|
// if (_entity.Quota > 0)
|
|
// {
|
|
// _list.Add(_entity);
|
|
// }
|
|
// }
|
|
// var ret = SCP_TB_VENDER_CONTROLLER.Save_TA_VENDER(_list);
|
|
// if (ret.State == ReturnStatus.Succeed)
|
|
// {
|
|
// var list = ret.Result;
|
|
// Alert.Show("保存成功!");
|
|
// BindData();
|
|
// }
|
|
// else
|
|
// {
|
|
// Alert.Show("保存失败!");
|
|
// }
|
|
//}
|
|
//查询
|
|
protected void btnSearch_OnClick(object sender, EventArgs e)
|
|
{
|
|
_list = SearchData();
|
|
|
|
var list = Sort<TA_VENDER>(_list.AsQueryable(), Grid1);
|
|
Grid1.DataSource = list;
|
|
Grid1.RecordCount = list.Count();
|
|
Grid1.DataBind();
|
|
}
|
|
public List<TA_VENDER> SearchData()
|
|
{
|
|
Expression<Func<TA_VENDER, bool>> where = c => true;
|
|
|
|
if (!string.IsNullOrEmpty(txtCode.Text))
|
|
{
|
|
where = c => c.VendId.Contains(txtCode.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(txtSupplierName.Text))
|
|
{
|
|
where = where.And(p => p.VendName.Contains(txtSupplierName.Text));
|
|
}
|
|
//if (!string.IsNullOrEmpty(DPL_Factory.SelectedValue))
|
|
//{
|
|
// where = where.And(p => p.Site.Contains(DPL_Factory.SelectedValue));
|
|
//}
|
|
|
|
where = where.And(p => p.Site==CurrentUser.UsedDomain);
|
|
List<TA_VENDER> list = SCPDB.TA_VENDER.Where(where.Compile()).ToList();
|
|
num = SCPDB.TA_VENDER.Where(where.Compile()).Count();
|
|
return list;
|
|
}
|
|
//显示
|
|
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 ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
|
|
BindData();
|
|
}
|
|
protected void Grid1_OnSort(object sender, GridSortEventArgs e)
|
|
{
|
|
|
|
_list = SearchData();
|
|
var list = Sort<TA_VENDER>(_list.AsQueryable(), Grid1);
|
|
Grid1.DataSource = list;
|
|
Grid1.RecordCount = list.Count();
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
}
|
|
|
|
}
|