|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Util;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using System.Collections;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 客户订单维护
|
|
|
/// </summary>
|
|
|
public class VendorController : BaseController
|
|
|
{
|
|
|
private IVendorService service;
|
|
|
public VendorController(IVendorService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /Vendor/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="VendorName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getVendorListByPage(String vendorCode, String vendorName, Pager pager, String direction, String sort, String enabled = "Y")
|
|
|
{
|
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getVendorListByPage(enabled, vendorCode, vendorName, factoryId, pager, direction, sort);
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectVendor()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> VendorList = this.service.getSelectVendor();
|
|
|
result.Add("list", VendorList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveVendor()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String vendorCode = Request.Form["vendorCode"].ToString();
|
|
|
String vendorFax = Request.Form["vendorFax"].ToString();
|
|
|
String vendorName = Request.Form["vendorName"].ToString();
|
|
|
String vendorMtel = Request.Form["vendorMtel"].ToString();
|
|
|
String vendorTel = Request.Form["vendorTel"].ToString();
|
|
|
String vendorMail = Request.Form["vendorMail"].ToString();
|
|
|
String vendorSale = Request.Form["vendorSale"].ToString();
|
|
|
String vendorPwd = Request.Form["vendorPwd"].ToString();
|
|
|
String vendorAddr = Request.Form["vendorAddr"].ToString();
|
|
|
String vendorId = Request.Form["vendorId"].ToString();
|
|
|
String dock = Request.Form["dock"].ToString();
|
|
|
|
|
|
SysVendor sysVendor = new SysVendor();
|
|
|
sysVendor.VendorCode = vendorCode;
|
|
|
sysVendor.VendorFax = vendorFax;
|
|
|
sysVendor.VendorName = vendorName;
|
|
|
sysVendor.VendorMtel = vendorMtel;
|
|
|
sysVendor.VendorTel = vendorTel;
|
|
|
sysVendor.VendorMail = vendorMail;
|
|
|
sysVendor.VendorSale = vendorSale;
|
|
|
sysVendor.VendorPwd = vendorPwd;
|
|
|
sysVendor.VendorAddr = vendorAddr;
|
|
|
sysVendor.Dock = dock;
|
|
|
|
|
|
sysVendor.FactoryId = CurrentEmp.FactoryId;
|
|
|
sysVendor.FactoryCode = CurrentEmp.FactoryCode;
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysVendor.VendorId = Convert.ToInt32(vendorId);
|
|
|
sysVendor.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.updateVendor(sysVendor);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (this.service.getVendorByExistName(vendorCode) != null)
|
|
|
{
|
|
|
message = "供应商代码已存在,请检查!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sysVendor.CreateUserId = CurrentEmp.EmpId;
|
|
|
if (this.service.saveVendor(sysVendor) > 0)
|
|
|
{
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "添加失败";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editVendor(String vendorId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(vendorId))
|
|
|
{
|
|
|
List<SysVendor> VendorInfo = this.service.getVendor(vendorId);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("vendorId", vendorId);
|
|
|
ViewData.Add("vendorCode", VendorInfo[0].VendorCode);
|
|
|
ViewData.Add("vendorName", VendorInfo[0].VendorName);
|
|
|
ViewData.Add("vendorTel", VendorInfo[0].VendorTel);
|
|
|
ViewData.Add("vendorAddr", VendorInfo[0].VendorAddr);
|
|
|
ViewData.Add("vendorFax", VendorInfo[0].VendorFax);
|
|
|
ViewData.Add("vendorMtel", VendorInfo[0].VendorMtel);
|
|
|
ViewData.Add("vendorMail", VendorInfo[0].VendorMail);
|
|
|
ViewData.Add("vendorSale", VendorInfo[0].VendorSale);
|
|
|
ViewData.Add("vendorPwd", VendorInfo[0].VendorPwd);
|
|
|
ViewData.Add("dock", VendorInfo[0].Dock);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
|
|
|
return View("EditVendor");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteVendor(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteVendor(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableVendor(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onDisable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.DisableVendor(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入dock
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult dockImport()
|
|
|
{
|
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
|
string factoryCode = CurrentEmp.FactoryCode;
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
IFormFile file = Request.Form.Files[0];
|
|
|
List<VendorDock> data = ExcelHelper.GetList<VendorDock>(file, 0);
|
|
|
result = service.ImportExcel(data, factoryId, factoryCode, CurrentEmp.EmpId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
public ActionResult uploadFile()
|
|
|
{
|
|
|
return View("uploadFile");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导出数据到Excel
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult exportData(String vendorCode, String vendorName, string enabled = "Y")
|
|
|
{
|
|
|
List<Vendor> listHt = this.service.getExportList(vendorCode, vendorName, enabled, CurrentEmp.FactoryId);
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "供应商管理" + dateTime + ".xls");
|
|
|
}
|
|
|
/// <summary>k
|
|
|
/// 下载模板
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult downLoadExcel(string rackPart, string partPackage, string enabled = "Y")
|
|
|
{
|
|
|
List<VendorDock> listHt = new List<VendorDock>();//导出空数据模板
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "供应商道口" + dateTime + ".xls");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|