tijian_tieying/web/dccdc/Controllers/wzController.cs

374 lines
13 KiB
C#
Raw Permalink Normal View History

2025-02-20 12:14:39 +08:00
using dccdc.BLL;
using dccdc.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using static dccdc.Controllers.DictionariesController;
namespace dccdc.Controllers
{
public class wzController : Controller
{
// GET: wz
public ActionResult Index()
{
return View();
}
#region
public ActionResult wzlbView()
{
return View();
}
public ActionResult wzlbMessage(string id)
{
ViewData["bumenlist"] = new SelectList(new ERPBuMenBll().GetAllList(""), "id", "bumenname");
var list = new List<Droplist>() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } };
ViewData["ztlist"] = new SelectList(list, "value", "title");
if (!string.IsNullOrEmpty(id))
{
var bll = new BLL.wzlbBll();
var model = bll.GetAllList(id).First();
return View(model);
}
else
{
return View();
}
}
public JsonResult getwzlbPage(int page, int pagesize, string key)
{
var bll = new BLL.wzlbBll();
int count = bll.getCount(key);
var models = bll.getPage(page, pagesize, key);
return Json(new { Total = count, Rows = models });
}
public JsonResult savewzlb(wzlbModel model)
{
var user = Session["loginUser"] as Models.ERPUser;
model.tjr = user.TrueName;
model.tjsj = DateTime.Now;
var bll = new BLL.wzlbBll();
return Json(bll.save(model));
}
#endregion
#region
public ActionResult wzView()
{
List<wzlbModel> wzlb = new BLL.wzlbBll().GetAllList("");
wzlb = wzlb.Where(t => t.zt == 1).ToList();
ViewBag.wzlbs = new SelectList(wzlb, "id", "lbmc");
return View();
}
public ActionResult wzMessage(string id)
{
var list = new List<Droplist>() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } };
ViewData["ztlist"] = new SelectList(list, "value", "title");
List<wzlbModel> wzlb = new BLL.wzlbBll().GetAllList("");
wzlb=wzlb.Where(t => t.zt == 1).ToList();
ViewBag.wzlbs = new SelectList(wzlb , "id", "lbmc");
if (!string.IsNullOrEmpty(id))
{
var bll = new BLL.wzBll();
var model = bll.GetAllList(id).First();
return View(model);
}
else
{
var bll = new BLL.wzBll();
var bm = bll.GetMaxBm();
var model = new Models.wzModel();
model.bm = (bm+1).ToString();
model.ggxh = "";
model.sccj = "";
model.jldw = "";
model.dj = 0;
model.zt = 1;
return View(model);
}
}
public JsonResult getwzPage(int page, int pagesize, string key,string wzlb)
{
var bll = new BLL.wzBll();
int count = bll.getCount(key,wzlb);
var models = bll.getPage(page, pagesize, key,wzlb);
return Json(new { Total = count, Rows = models });
}
public JsonResult savewz(wzModel model)
{
//规格型号 生产厂家 计量单位 用于计算不能是null
if (model.ggxh == null)
model.ggxh = "";
if (model.sccj == null)
model.sccj = "";
if (model.jldw == null)
model.jldw = "";
if (model.dj == null)
model.dj = 0;
var bll = new BLL.wzBll();
if (model.id == 0) //添加验证重复 修改不允许修改
{
if (bll.GetBm(model.bm))
return Json(new { State = 0, Message = "编码重复!" });
}
var user = Session["loginUser"] as Models.ERPUser;
model.tjr = user.TrueName;
model.tjsj = DateTime.Now;
return Json(bll.save(model));
}
#endregion
#region
public ActionResult cgsqdView()
{
var list = new List<Droplist>() { new Droplist { Value = "0", Title = "等待审批" }, new Droplist { Value = "1", Title = "部门领导已审批" }, new Droplist { Value = "2", Title = "领导审批" }, new Droplist { Value = "-1", Title = "审批不通过" } };
ViewData["ztlist"] = new SelectList(list, "value", "title");
var user = Session["loginUser"] as Models.ERPUser;
ViewData["userid"] = user.ID;
string ksid = "";
ViewData["level"] = getLevel(ref ksid);
return View();
}
//获取身份 0个人 1部门领导 2单位领导
private int getLevel(ref string ksid)
{
var user = Session["loginUser"] as Models.ERPUser;
string dwlds = new BLL.Common().getParm_Value("wzsplds", "32,58", "物资审批单位领导,分割多个领导");
List<int> lds = new List<int>();
foreach(string l in dwlds.Split(','))
{
int il = 0;
if(int.TryParse(l,out il))
{
lds.Add(il);
}
}
if (lds.Contains(user.ID)) //单位领导写死id
return 2;
else
{
var kss = new BLL.ERPBuMenBll().GetAllList(user.Department);
if (kss.Count > 0)
{
ksid = kss[0].ID.ToString();
if (kss[0].ChargeMan == user.UserName)
return 1;
}
return 0;
}
}
public ActionResult cgsqdMessage(string id)
{
ViewBag.jflyD = new SelectList(new xmjingfeiBll().GetAllList(""), "id", "xmmc");
ViewBag.wzlbD = new SelectList(new wzlbBll().GetAllList("", "1"), "id", "lbmc");
if (!string.IsNullOrEmpty(id))
{
var bll = new BLL.cgsqdBll();
var model = bll.GetAllList(id).First();
return View(model);
}
else
{
return View();
}
}
//申请单入库
//public ActionResult rkdMessage(string id)
//{
// ViewBag.gysD = new SelectList(new gyszdBll().GetAllList(""), "id", "mc");
// var list = new List<Droplist>() { new Droplist { Value = "0", Title = "未入库" }, new Droplist { Value = "1", Title = "已入库" } };
// ViewBag.ztD = new SelectList(list, "value", "title");
// if (!string.IsNullOrEmpty(id))
// {
// var bll = new BLL.cgsqdBll();
// var model = bll.GetAllList(id).First();
// return View(model);
// }
// else
// {
// return View();
// }
//}
//public JsonResult opSaveStore(string id, string gysid, string gys, string cgje, string zt, string items)
//{
// var bll = new rkdBll();
// var user = Session["loginUser"] as Models.ERPUser;
// if (string.IsNullOrEmpty(gysid) || string.IsNullOrEmpty(items))
// return Json(new { State = 1, Message = "false" });
// return Json(bll.opSave(id, gysid, gys, cgje, zt, items, user.ID, user.TrueName, 1, Convert.ToInt32(id)));
//}
[AllowAnonymous]
public string getRudByRkdh(string rkdh)
{
var bll = new rkdBll();
if (string.IsNullOrEmpty(rkdh))
return "";
return Newtonsoft.Json.JsonConvert.SerializeObject(bll.getRudByRkdh(rkdh));
}
[AllowAnonymous]
public string getRudMxByRkdId(string rkdid)
{
var bll = new rkdBll();
if (string.IsNullOrEmpty(rkdid))
return "";
return Newtonsoft.Json.JsonConvert.SerializeObject(bll.getRudMxByRkdId(rkdid));
}
public JsonResult getcgsqdPage(int page, int pagesize, string key)
{
string ksid = "";
int level = getLevel(ref ksid);
var bll = new BLL.cgsqdBll();
if (level == 2)
{
int count = bll.getCount(key, "");
var models = bll.getPage(page, pagesize, key, "");
return Json(new { Total = count, Rows = models });
}
else
{
int count = bll.getCount(key, ksid);
var models = bll.getPage(page, pagesize, key, ksid);
return Json(new { Total = count, Rows = models });
}
}
public JsonResult opSave(string id, string jflyid, string jfly, string sqyy, string cgje, string items)
{
var bll = new cgsqdBll();
var user = Session["loginUser"] as Models.ERPUser;
int ksid = 0;
var kss = new BLL.ERPBuMenBll().GetAllList(user.Department);
if (kss.Count > 0)
ksid = kss[0].ID;
if (string.IsNullOrEmpty(jflyid) || string.IsNullOrEmpty(items))
return Json(new { State = 1, Message = "false" });
if(id=="")
return Json(bll.opSave(id, jflyid, jfly, sqyy, cgje, items, user.ID, user.TrueName, ksid, user.Department));
else
return Json(bll.opSave2(id, jflyid, jfly, sqyy, cgje, items, user.ID, user.TrueName, ksid, user.Department));
}
[AllowAnonymous]
public string getCgsqdBySqdh(string sqdh)
{
var bll = new cgsqdBll();
if (string.IsNullOrEmpty(sqdh))
return "";
return Newtonsoft.Json.JsonConvert.SerializeObject(bll.getCgsqdBySqdh(sqdh));
}
[AllowAnonymous]
public string getCgsqdMxBySqdId(string sqdid)
{
var bll = new cgsqdBll();
if (string.IsNullOrEmpty(sqdid))
return "";
return Newtonsoft.Json.JsonConvert.SerializeObject(bll.getCgsqdMxBySqdId(sqdid));
}
public JsonResult delete(string id)
{
if (string.IsNullOrEmpty(id))
return Json(null);
return Json(new BLL.cgsqdBll().delete(id));
}
public JsonResult check(string id, string zt)
{
var user = Session["loginUser"] as Models.ERPUser;
if (string.IsNullOrEmpty(id))
return Json(null);
return Json(new BLL.cgsqdBll().check(id, zt, user.TrueName));
}
public JsonResult getwzbykey(string key, string id,string key1)
{
var bll = new BLL.wzBll();
var models = bll.GetListByKey(key,key1);
//修改时 添加已有明细
if (!string.IsNullOrEmpty(id))
{
var bllmx = new BLL.cgsqdmxBll();
var modelmx = bllmx.GetListByParent(id);
wzModel mm;
foreach (cgsqdmxModel m in modelmx)
{
mm = new wzModel();
mm.id = m.wzid;
mm.mc = m.wzmc;
mm.dj = m.dj;
mm.sl = m.sl;
models.Add(mm);
}
}
return Json(new { Rows = models });
}
#endregion
#region
public ActionResult gyszdView()
{
return View();
}
public ActionResult gyszdMessage(string id)
{
var list = new List<Droplist>() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } };
ViewData["ztlist"] = new SelectList(list, "value", "title");
if (!string.IsNullOrEmpty(id))
{
var bll = new BLL.gyszdBll();
var model = bll.GetAllList(id).First();
return View(model);
}
else
{
return View();
}
}
public JsonResult getgyszdPage(int page, int pagesize, string key)
{
var bll = new BLL.gyszdBll();
int count = bll.getCount(key);
var models = bll.getPage(page, pagesize, key);
return Json(new { Total = count, Rows = models });
}
public JsonResult savegyszd(gyszdModel model)
{
var user = Session["loginUser"] as Models.ERPUser;
model.tjr = user.TrueName;
model.tjsj = DateTime.Now;
var bll = new BLL.gyszdBll();
return Json(bll.save(model));
}
#endregion
#region
public ActionResult gylyr()
{
return View();
}
public JsonResult savegylyr(string id,string xm)
{
return Json(new BLL.wzBll().savegylyr(id, xm));
}
public string getgylyrlist()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = new BLL.wzBll().getgylyrlist() });
}
#endregion
}
}