using FineUIPro;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Common.EnumType;
|
using iWareDataCore.BASE.EnumType;
|
using iWareDataCore.BASE.Service;
|
using iWareExcel.EXCEL.Service;
|
using iWareWms;
|
using iWareWms.Code.Excel.Service;
|
using System;
|
using System.Collections.Generic;
|
|
namespace iWareWms.View.MATERIAL.Material
|
{
|
|
public partial class Material : PageBase
|
{
|
protected override Grid GetGrid()
|
{
|
return MaterialGrid;
|
}
|
|
protected override DropDownList GetPageSizeDropDownList()
|
{
|
return ddlPageSize;
|
}
|
|
protected override List<object> GetDataSource(int pageIndex, int pageSize, out string msg, out int totalNum, out int currentPage)
|
{
|
var materials = MaterialViewService.GetInstance().QueryByParam(new QueryParam
|
{
|
Search = new Dictionary<string, object> { { "Code", tbCode.Text.Trim() } },
|
Filter = new Dictionary<string, object> { { "Status", ddlStatus.SelectedValue }, { "MaterialType", ddlTypeId.SelectedValue } },
|
PageIndex = pageIndex,
|
PageSize = pageSize
|
}, out msg, out totalNum, out currentPage);
|
var material = new List<object>();
|
materials.ForEach(x => material.Add(x));
|
return material;
|
}
|
|
protected override void Delete(int id, out string msg)
|
{
|
MaterialService.GetInstance().Delete(id, out msg);
|
WriteLog("物料删除" + msg, "物料管理");
|
}
|
|
protected override void Delete(List<int> ids, out string msg)
|
{
|
MaterialService.GetInstance().Delete(ids, out msg);
|
WriteLog("物料删除" + msg, "物料管理");
|
}
|
|
protected override void ChangeStatus(List<int> ids, int enable, out string msg)
|
{
|
MaterialService.GetInstance().ChangeStatus(ids, enable, out msg);
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
if (!IsPostBack)
|
{
|
//判断启用状态复选框是否选择了至少一项纪录
|
ResolveEnableStatusButtonForGrid(MenuButton1, MaterialGrid, true);
|
|
//判断禁用状态复选框是否选择了至少一项纪录
|
ResolveEnableStatusButtonForGrid(MenuButton2, MaterialGrid, false);
|
|
//判断删除复选框是否选择了至少一项纪录
|
ResolveDeleteButtonForGrid(Button3, MaterialGrid);
|
|
//物料启用状态
|
ddlStatus.Items.Add("全部", "");
|
foreach (var status in Enum.GetValues(typeof(iWareCommon.Common.EnumType.EStatus)))
|
{
|
ddlStatus.Items.Add(status.ToString(), ((int)status).ToString());
|
}
|
|
//物料大类
|
//ddlType.Items.Add("全部", "");
|
//foreach (var type in Enum.GetValues(typeof(EMaterialType)))
|
//{
|
// ddlType.Items.Add(type.ToString(), ((int)type).ToString());
|
//}
|
|
|
|
string msg;
|
var types = MaterialTypeService.GetInstance().QueryByParam(new QueryParam(),out msg);
|
|
ddlTypeId.Items.Add("全部", "");
|
types.ForEach(x => ddlTypeId.Items.Add(x.Name, x.Type.ToString()));
|
|
//新增物料
|
Button1.OnClientClick = types.Count > 0 ? Window1.GetShowReference("~/View/MATERIAL/Material/MaterialDetail.aspx", "新增物料") : "alert('请先添加物料类型')";
|
Query(1);
|
}
|
}
|
|
/// <summary>
|
/// 物料启用状态,枚举前台显示
|
/// </summary>
|
/// <param name="tryp"></param>
|
/// <returns></returns>
|
protected string GetStatus(object status)
|
{
|
return ((iWareCommon.Common.EnumType.EStatus)Convert.ToInt32(status)).ToString();
|
}
|
|
/// <summary>
|
/// 物料类型,枚举前台显示
|
/// </summary>
|
/// <param name="type"></param>
|
/// <returns></returns>
|
protected string GetType(object type)
|
{
|
return ((EMaterialType)Convert.ToInt32(type)).ToString();
|
}
|
|
/// <summary>
|
/// 切割类型前台枚举显示
|
/// </summary>
|
/// <param name="tryp"></param>
|
/// <returns></returns>
|
protected string GetCuttingType(object cuttingtype)
|
{
|
return ((ECuttingType)Convert.ToInt32(cuttingtype)).ToString();
|
}
|
|
protected override Window GetWindow()
|
{
|
return Window2;
|
}
|
|
|
protected override void GetPath(object userName)
|
{
|
string msg;
|
var materials = MaterialViewService.GetInstance().QueryByParam(new QueryParam
|
{
|
Search = new Dictionary<string, object> { { "Code", tbCode.Text.Trim() } },
|
Filter = new Dictionary<string, object> { { "Status", ddlStatus.SelectedValue }, { "MaterialType", ddlTypeId.SelectedValue } }
|
}, out msg);
|
var datas = new List<object>();
|
materials.ForEach(x => datas.Add(x));
|
var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Name", "物料信息" } } }, out msg);
|
var path = ExcelService.GetInstance().ToExcelByEPPlus(workBooks[0], new Dictionary<string, List<object>> { { "物料信息", datas } }, out msg);
|
Session["ExcelPath"] = path;
|
}
|
|
protected override FineUIPro.Timer GetTimer()
|
{
|
return timer1;
|
}
|
|
protected void FileUpload1_FileSelected(object sender, EventArgs e)
|
{
|
string msg;
|
if (!FileUpload1.HasFile)
|
{
|
Alert.ShowInTop("请选择上传文件!");
|
return;
|
}
|
var dt = DateTime.Now;
|
string path = string.Format(@"c:\importExcel\{0}\{1}\{2}\{3}\", dt.Year, dt.Month, dt.Day, (long)(dt - Convert.ToDateTime("1970-01-01 08:00:00")).TotalMilliseconds); ;
|
path += FileUpload1.FileName;
|
FileUpload1.SaveAs(path);
|
|
var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Name", "物料信息" } } }, out msg);
|
|
MaterialViewService.GetInstance().ImportExcel(path, workBooks[0], out msg);
|
if(string.IsNullOrEmpty(msg) )
|
{
|
msg="导入成功";
|
}
|
Alert.ShowInTop(msg);
|
WriteLog("物料导入" + msg, "物料管理");
|
Query(1);
|
}
|
}
|
}
|