|
|
using System;
|
|
|
using System.Linq;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.MvcContainer.Models.MsCodeMsds;
|
|
|
using DSWeb.MvcContainer.DAL.MsCodeMsds;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using System.Collections.Generic;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
|
namespace DSWeb.MvcContainer.Controllers
|
|
|
{
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsCodeMsdsController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET:
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET: /
|
|
|
public ActionResult Edit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult MsdsView()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult WhiteIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
//
|
|
|
// GET:
|
|
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = MsCodeMsdsDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]),sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult GetDataListStr(string sort, string condition)
|
|
|
{
|
|
|
var dataListStr = MsCodeMsdsDAL.GetDataListStr(condition, Convert.ToString(Session["COMPANYID"]), sort);
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult GetDataListRm(string CODENAME,string sort, string condition="")
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(CODENAME))
|
|
|
{
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
if (condition == "")
|
|
|
condition = " isnull(ISSTOP, 0) = 0 AND (CHEMICALCGOODSNAME like '%" + CODENAME + "%' or GOODNAME like '%" + CODENAME + "%') ";
|
|
|
else
|
|
|
condition = condition + " isnull(ISSTOP, 0) = 0 and (CHEMICALCGOODSNAME like '%" + CODENAME + "%' or GOODNAME like '%" + CODENAME + "%') ";
|
|
|
|
|
|
}
|
|
|
|
|
|
var dataList = MsCodeMsdsDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/TruckMng/MsWlTyreAcc/GetData/
|
|
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
{
|
|
|
CodeMSDS head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsCodeMsdsDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new CodeMSDS();
|
|
|
head.COMPANYID = Convert.ToString(Session["COMPANYID"]);
|
|
|
}
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult Save(string opstatus, string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<CodeMSDS>(data);
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
headData.COMPANYID = Convert.ToString(Session["COMPANYID"]);
|
|
|
headData.INPUTBY = Convert.ToString(Session["USERID"]);
|
|
|
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headData.ModelUIStatus = "E";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
|
|
|
var ct = MsCodeMsdsDAL.GetRdCount("GID<>'" + headData.GID + "' AND GOODNAME='" + headData.GOODNAME + "'");
|
|
|
if (ct != 0)
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse
|
|
|
{
|
|
|
Success = false,
|
|
|
Message ="品名重复,不允许保存"
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
|
|
|
var GID = headData.GID;
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
var result=modb.Save(headData);
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = MsCodeMsdsDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<CodeMSDS>>(data);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.DeleteCodeMSDS(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult Stop(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<CodeMSDS>>(data);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.StopCodeMSDS(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
public ContentResult UnStop(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<CodeMSDS>>(data);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.UnStopCodeMSDS(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult GetFactryList(string condition, string sort)
|
|
|
{
|
|
|
var dataList = MsCodeMsdsDAL.GetFactryList(condition, sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
public ContentResult GetFactryData(string handle, string condition)
|
|
|
{
|
|
|
var dataList = MsCodeMsdsDAL.GetFactryData(condition);
|
|
|
|
|
|
CodeMSDSFactry head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsCodeMsdsDAL.GetFactryList(condition);
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new CodeMSDSFactry();
|
|
|
|
|
|
}
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult SaveFactry(string opstatus, string data,string MSDSID)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<CodeMSDSFactry>(data);
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
headData.GID = Guid.NewGuid().ToString();
|
|
|
headData.MSDSID = MSDSID;
|
|
|
headData.INPUTBY = Convert.ToString(Session["USERID"]);
|
|
|
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
|
|
|
var GID = headData.GID;
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
var result = modb.Save(headData);
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = MsCodeMsdsDAL.GetFactryData("GID='" + GID + "'")
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult GetRejectionList(string condition, string sort)
|
|
|
{
|
|
|
var dataList = MsCodeMsdsDAL.GetRejectionList(condition, sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult SaveDetail(string body,string MSDSID)
|
|
|
{
|
|
|
//
|
|
|
var bodyList = JsonConvert.Deserialize<List<CodeMSDSRejection>>(body);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.SaveDetail(bodyList, MSDSID,Convert.ToString(Session["USERID"]));
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult Deletefactry(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<CodeMSDSFactry>>(data);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.DeletefactryDetail(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
public ContentResult DeleteRejection(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<CodeMSDSRejection>>(data);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.DeleteRejectionDetail(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
#region 白名单
|
|
|
|
|
|
public ContentResult GetMsdsWhiteList(string condition, string sort)
|
|
|
{
|
|
|
var dataList = MsCodeMsdsDAL.GetMsdsWhiteList(condition, sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult SaveMsdsWhiteDetail(string body)
|
|
|
{
|
|
|
//
|
|
|
var bodyList = JsonConvert.Deserialize<List<CodeMSDSWhite>>(body);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.SaveMsdsWhiteDetail(bodyList, Convert.ToString(Session["USERID"]));
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
public ContentResult DeleteMsdsWhiteDetail(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<CodeMSDSWhite>>(data);
|
|
|
|
|
|
DBResult result = MsCodeMsdsDAL.DeleteMsdsWhiteDetail(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|