You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
8.2 KiB
C#
186 lines
8.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using DSWeb.MvcShipping.DAL.MsCompanysDAL;
|
|
using DSWeb.MvcShipping.Models.MsCompanys;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using System.Collections.Generic;
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Models;
|
|
|
|
using System.IO;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
[JsonRequestBehavior]
|
|
public class MsCompanysController : Controller
|
|
{
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult MsCompanysAccountIndex()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult MsCompanysDeptIndex()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
{
|
|
string strPath = "../../images/logo/noImage.gif";
|
|
string strPhotoPath = Server.MapPath(strPath);
|
|
//
|
|
var dataList = MsCompanysDAL.GetDataList(strPath, strPhotoPath, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
var list = dataList.Skip(start).Take(limit);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetNoPicDataList(int start, int limit, string sort, string condition)
|
|
{
|
|
//
|
|
var dataList = MsCompanysDAL.GetNoPicDataList(condition);
|
|
var list = dataList.ToList();
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetDataListStr(string sort, string condition)
|
|
{
|
|
var dataListStr = MsCompanysDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
{
|
|
string strPath = "../../images/logo/noImage.gif";
|
|
string strPhotoPath = Server.MapPath(strPath);
|
|
//
|
|
MsCompanysEntity head = null;
|
|
head = MsCompanysDAL.GetData(strPath, strPhotoPath, condition);
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
[HttpPost]
|
|
public ContentResult Save(string opstatus, string data)
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
//
|
|
var headData = JsonConvert.Deserialize<MsCompanysEntity>(data);
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
//
|
|
#region 默认赋值
|
|
//headData.LOGO 徽标 Image 16
|
|
headData.ISDELETED = false;
|
|
//headData.ISDISABLE = false;//是否被禁用
|
|
headData.PARENTID = "";
|
|
headData.GPSUser = "";
|
|
headData.GPSPassWord = "";
|
|
//
|
|
headData.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
|
|
headData.CREATETIME = DateTime.Now;//创建时间
|
|
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人
|
|
headData.MODIFIEDTIME = DateTime.Now;//最后一次操作时间
|
|
#endregion
|
|
|
|
if (opstatus == "add")
|
|
{
|
|
headData.GID = "Com" + Guid.NewGuid().ToString().Replace("-", "");//惟一编号 varchar(36)
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
headData.ModelUIStatus = "E";
|
|
}
|
|
else
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
|
|
#region LOGO_微标
|
|
var jsonRespose1 = new JsonResponse { Success = false, Message = "" };
|
|
headData.LOGO = null;
|
|
if (Request.Files.Count > 0)
|
|
{
|
|
var UpFile = Request.Files["upload"];
|
|
if (UpFile != null)
|
|
{
|
|
var FileLength = UpFile.ContentLength;//获取上传文件的字节大小
|
|
if (FileLength > 0)
|
|
{
|
|
Byte[] FileByte = new Byte[FileLength]; //图象文件储存到数组
|
|
Stream ObjectStream = UpFile.InputStream;//建立数据流对像,获取一个 Stream 对象,该对象指向一个上载文件,以准备读取该文件的内容。
|
|
ObjectStream.Read(FileByte, 0, FileLength); //读取图象文件数据
|
|
headData.LOGO = FileByte;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
if (isPost)
|
|
{
|
|
string strPath = "../../images/logo/noImage.gif";
|
|
string strPhotoPath = Server.MapPath(strPath);
|
|
var modb = new ModelObjectDB();
|
|
//DBResult result = modb.Save(headData);
|
|
DBResult result = MsCompanysDAL.Save(headData);
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = MsCompanysDAL.GetData(strPath, strPhotoPath, "GID='" + headData.GID + "'")
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else {
|
|
var jsonRespose = new JsonResponse { Success = false, Message =errorstr };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
#region 删除
|
|
public ContentResult Delete(string data)
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
//
|
|
var head = JsonConvert.Deserialize<MsCompanysEntity>(data);
|
|
var modb = new ModelObjectDB();
|
|
//DBResult result = modb.Delete(head);
|
|
DBResult result = MsCompanysDAL.Delete(head);
|
|
if (result.Success == true)
|
|
{
|
|
DBResult result2 = MsCompanysDAL.setLog(head, Convert.ToString(Session["USERID"]));
|
|
}
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
#endregion
|
|
//
|
|
}
|
|
}
|
|
|