using FineUIPro; using iWareCommon.Common.Entity; using iWareCommon.Common.EnumType; using iWareDataCore.BASE.Entity; 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 MaterialType : PageBase { protected override Grid GetGrid() { return MaterialViewGrid; } protected override DropDownList GetPageSizeDropDownList() { return ddlPageSize; } protected override List GetDataSource(int pageIndex, int pageSize, out string msg, out int totalNum, out int currentPage) { var types = MaterialTypeViewService.GetInstance().QueryByParam(new QueryParam { Search = new Dictionary { { "Name", tbName.Text.Trim() } }, Filter = new Dictionary { { "RefLabel", ddRefLabel.SelectedValue }, { "Type", ddlType.SelectedValue } }, PageIndex = pageIndex, PageSize = pageSize }, out msg, out totalNum, out currentPage); var res = new List(); types.ForEach(x => res.Add(x)); return res; } /// /// 用于是否被引用 /// /// /// protected string GetRefLabel(object RefLabel) { if (RefLabel == null) { RefLabel = 0; } return ((EYesOrNo)RefLabel).ToString(); } private MaterialTypeEntity GetMaterial() { return new MaterialTypeEntity { Name = tbName.Text.Trim(), }; } protected override void Update(out string msg) { var role = GetMaterial(); role.Id = Convert.ToInt32(Request.QueryString["Id"]); MaterialTypeService.GetInstance().Update(role, out msg); WriteLog("物料类型更新" + msg, "物料管理"); } protected override void Delete(int id, out string msg) { MaterialTypeService.GetInstance().Delete(id, out msg); WriteLog("物料类型删除" + msg, "物料管理"); } protected override void Delete(List ids, out string msg) { MaterialTypeService.GetInstance().Delete(ids, out msg); WriteLog("物料类型删除" + msg, "物料管理"); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //判断删除复选框是否选择了至少一项纪录 ResolveDeleteButtonForGrid(Button3, MaterialViewGrid); Button1.OnClientClick = Window1.GetShowReference("~/View/MATERIAL/MaterialType/MaterialTypeDetail.aspx", "新增物料类型"); foreach (var type in Enum.GetValues(typeof(EMaterialType))) { ddlType.Items.Add(type.ToString(), ((int)type).ToString()); } Query(1); } } /// /// 物料类型,枚举前台显示 /// /// /// protected string GetType(object type) { return ((EMaterialType)Convert.ToInt32(type)).ToString(); } //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 { { "Name", "物料类型" } } }, out msg); // MaterialTypeViewService.GetInstance().ImportExcel(path, workBooks[0], out msg); // Alert.ShowInTop(string.IsNullOrEmpty(msg) ? "导入成功" : msg); // Query(1); //} protected override Window GetWindow() { return Window2; } protected override void GetPath(object userName) { string msg; var types = MaterialTypeViewService.GetInstance().QueryByParam(new QueryParam { Search = new Dictionary { { "Name", tbName.Text.Trim() } }, Filter = new Dictionary { { "RefLabel", ddRefLabel.SelectedValue }, { "Type", ddlType.SelectedValue } }, }, out msg); var datas = new List(); types.ForEach(x => datas.Add(x)); var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary { { "Name", "物料类型" } } }, out msg); var path = ExcelService.GetInstance().ToExcelByEPPlus(workBooks[0], new Dictionary> { { "物料类型", datas } }, out msg); Session["ExcelPath"] = path; } protected override FineUIPro.Timer GetTimer() { return timer1; } } }