public ActionResult Auto(string supName) { SupplierProvider provider = new SupplierProvider(); List<SupplierEntity> list = provider.GetList(); if (!list.IsNullOrEmpty() && !supName.IsEmpty()) { list = list.Where(a => a.SupNum.Contains(supName) || a.SupName.Contains(supName)).ToList(); } list = list.IsNull() ? new List<SupplierEntity>() : list; StringBuilder sb = new StringBuilder(); JsonObject jsonObject = null; foreach (SupplierEntity t in list) { jsonObject = new JsonObject(); jsonObject.AddProperty("SupNum", t.SupNum); jsonObject.AddProperty("SupName", t.SupName); jsonObject.AddProperty("ContactName", t.ContactName); jsonObject.AddProperty("Phone", t.Phone); sb.Append(jsonObject.ToString() + "\n"); } if (sb.Length == 0) { sb.Append("\n"); } return Content(sb.ToString()); }
public ActionResult AddSupplier() { string SupNum = WebUtil.GetQueryStringValue<string>("SupNum"); if (SupNum.IsEmpty()) { ViewBag.Supplier = new SupplierEntity(); ViewBag.SupType = EnumHelper.GetOptions<ESupType>((int)ESupType.Invented, "请选择供应商类型"); return View(); } else { SupplierProvider provider = new SupplierProvider(); SupplierEntity entity = provider.GetSupplier(SupNum); entity = entity == null ? new SupplierEntity() : entity; ViewBag.SupType = EnumHelper.GetOptions<ESupType>(entity.SupType,"请选择供应商类型"); ViewBag.Supplier = entity; return View(); } }
public ActionResult AddSupplier([ModelBinder(typeof(JsonBinder<SupplierEntity>))] SupplierEntity entity) { SupplierProvider provider = new SupplierProvider(); entity.CreateTime = DateTime.Now; int line = 0; if (entity.SupNum.IsEmpty()) { entity.SupNum = SequenceProvider.GetSequence(typeof(SupplierEntity)); line = provider.AddSupplier(entity); } else { line = provider.Update(entity); } if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return Content(this.ReturnJson.ToString()); }
public ActionResult SupplierReportTOP10() { int queryTime = WebUtil.GetFormValue<int>("QueryTime", 0); int pageIndex = 1; int pageSize = 10; string storageNum = this.DefaultStore; InStorageProvider provider = new InStorageProvider(); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; List<InStorageEntity> listResult = provider.GetListTOP10(queryTime, storageNum); listResult = listResult.IsNull() ? new List<InStorageEntity>() : listResult; SupplierProvider cusProvider = new SupplierProvider(); foreach (InStorageEntity item in listResult) { SupplierEntity tempItem = cusProvider.GetSupplier(item.SupNum); item.SupName = tempItem.SupName; item.Description = tempItem.Description; } /*******************************************订单数量排名前十的供应商饼图数据****************************************************/ StringBuilder sb = new StringBuilder(); sb.Append("<pie>"); listResult.ForEach(a => { if (a.Num > 0) { sb.AppendFormat("<slice title=\"{0}\">{1}</slice>", a.SupName, a.Num.ToString()); } }); sb.Append("</pie>"); this.ReturnJson.AddProperty("InStorageData", sb.ToString()); string json = ConvertJson.ListToJson<InStorageEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return Content(this.ReturnJson.ToString()); }
public ActionResult SupplierDetailList() { int queryTime = WebUtil.GetFormValue<int>("QueryTime", 0); int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue<int>("pageSize", 0); string storageNum = this.DefaultStore; SupplierProvider provider = new SupplierProvider(); SupplierEntity entity = new SupplierEntity(); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; List<SupplierEntity> listResult = provider.GetList(entity, ref pageInfo); listResult = listResult.IsNull() ? new List<SupplierEntity>() : listResult; InStorageProvider inProvider = new InStorageProvider(); foreach (SupplierEntity item in listResult) { item.Num = inProvider.GetNumBySupNum(item.SupNum, queryTime, storageNum); } string json = ConvertJson.ListToJson<SupplierEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return Content(this.ReturnJson.ToString()); }
public ActionResult ToExcel() { PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue }; string SupNum = WebUtil.GetFormValue<string>("SupNum", string.Empty); SupplierProvider provider = new SupplierProvider(); SupplierEntity entity = new SupplierEntity(); List<SupplierEntity> list = provider.GetList(); if (!list.IsNullOrEmpty()) { List<SupplierEntity> listResult = list.Where(a => a.SupNum.Contains(SupNum) || a.SupName.Contains(SupNum)).ToList(); listResult = listResult.IsNull() ? new List<SupplierEntity>() : listResult; if (listResult.IsNotNull()) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("序号 ")); dt.Columns.Add(new DataColumn("供应商编号")); dt.Columns.Add(new DataColumn("供应商名称")); dt.Columns.Add(new DataColumn("电话")); dt.Columns.Add(new DataColumn("传真")); dt.Columns.Add(new DataColumn("Email")); dt.Columns.Add(new DataColumn("联系人")); dt.Columns.Add(new DataColumn("地址")); dt.Columns.Add(new DataColumn("描述")); int count = 1; foreach (SupplierEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.SupNum; row[2] = t.SupName; row[3] = t.Phone; row[4] = t.Fax; row[5] = t.Email; row[6] = t.ContactName; row[7] = t.Address; row[8] = t.Description; dt.Rows.Add(row); count++; } string filePath = Server.MapPath("~/UploadFiles/"); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } string filename = string.Format("供应商管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss")); NPOIExcel excel = new NPOIExcel("供应商管理", "供应商", System.IO.Path.Combine(filePath, filename)); excel.ToExcel(dt); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!") ; } } return Content(this.ReturnJson.ToString()); }
public ActionResult GetSupplierList() { int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 1); int pageSize = WebUtil.GetFormValue<int>("pageSize", 15); string SupNum = WebUtil.GetFormValue<string>("SupNum", string.Empty); SupplierProvider provider = new SupplierProvider(); SupplierEntity entity = new SupplierEntity(); List<SupplierEntity> list = provider.GetList(); if (!list.IsNullOrEmpty()) { List<SupplierEntity> listResult = list.Where(a => a.SupNum.Contains(SupNum) || a.SupName.Contains(SupNum)).ToList(); List<SupplierEntity> returnList = listResult.Skip((pageIndex - 1) * pageSize).Take(pageSize).OrderByDescending(a => a.ID).ToList(); string json = ConvertJson.ListToJson<SupplierEntity>(returnList, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", listResult.Count); } return Content(this.ReturnJson.ToString()); }
public ActionResult doImportFile() { string msg = ""; try { string filename = WebUtil.GetFormValue<string>("Url", string.Empty); var path = Server.MapPath(filename); var dataset = ExcelHelper.LoadDataFromExcel(path, "供应商管理$", "", "2007"); List<SupplierEntity> list = new List<SupplierEntity>(); //获取产品信息, GetProCatInfo(dataset, list); if (list.Count > 0) { SupplierProvider provider = new SupplierProvider(); msg = provider.ImportProCateData(list); this.ReturnJson.AddProperty("d", msg); } } catch (Exception ex) { msg = ex.Message; this.ReturnJson.AddProperty("d", "error"); } return Content(this.ReturnJson.ToString()); }
public ActionResult Delete(string supNum) { SupplierProvider provider = new SupplierProvider(); int line = provider.Delete(supNum); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return Content(this.ReturnJson.ToString()); }
public ActionResult BatchDel(string SupNum) { SupplierProvider provider = new SupplierProvider(); var list = SupNum.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List<string> ls = new List<string>(); int line = 0; foreach (string t in list) { line += provider.Delete(t); } if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return Content(this.ReturnJson.ToString()); }
/// <summary> /// 供应商下拉列表 /// </summary> /// <param name="roleNum"></param> /// <returns></returns> public static string GetSupNameList(string SupNum) { SupplierProvider provider = new SupplierProvider(); List<SupplierEntity> list = provider.GetList(); StringBuilder sb = new StringBuilder(); string storeTemplate = "<option value='{0}' {1}>{2}</option>"; if (!list.IsNullOrEmpty()) { foreach (SupplierEntity store in list) { sb.AppendFormat(storeTemplate, store.SupNum, store.SupNum == SupNum ? "selected='selected'" : string.Empty, store.SupName); } } return sb.ToString(); }