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.

179 lines
6.2 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsOpSeaeEdiDAL;
using DSWeb.MvcShipping.Models.MsOpSeaeEdi;
using DSWeb.MvcShipping.Models.MsOpSeae;
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 System.IO;
using System.Web;
using DSWeb.MvcShipping.DAL.MsOpSeaeEdiPortDAL;
using DSWeb.EntityDA;
using DSWeb.Areas.MvcShipping.DAL.Message.vgm;
using DSWeb.MvcShipping.DAL.MsOpSeaeCustPrice;
using DSWeb.MvcShipping.Models.MsOpSeaeCustPrice;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpSeaeCustCZController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult Map()
{
return View();
}
public ActionResult CustomVGMIndex()
{
return View();
}
public ActionResult CustomVGMEdit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
int count = 0;
var dataList = MsOpSeaeCustCZDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), start, limit, out count, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
string userid = Convert.ToString(Session["USERID"]);
if (userid == "" || userid == null)
{
var jsonRespose = new JsonResponse { Success = false, Message = "登陆状态失效,请重新登陆进行操作!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
string INPUTBY = Convert.ToString(Session["SHOWNAME"]);
Cust_CZ head = null;
if (handle == "edit")
{
head = MsOpSeaeCustCZDAL.GetData(condition);
}
if (handle == "add")
{
head = new Cust_CZ();
head.GID = Guid.NewGuid().ToString();
head.CZCOM = "";
head.CZJE = 0;
}
if (head == null)
{
head = new Cust_CZ();
}
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<Cust_CZ>(data);
string userid = Convert.ToString(Session["USERID"]);
string comid = Convert.ToString(Session["COMPANYID"]);
var isPost = true;
headData.DbOperationType = DbOperationType.DbotIns;
if (isPost)
{
var modb = new ModelObjectDB();
headData.CZTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.GID = Guid.NewGuid().ToString();
headData.COMID = MsOpSeaeCustCZDAL.GetComidWithComName(headData.CZCOM);
headData.CREATE_BY = Session["SHOWNAME"].ToString();
string msg = "";
bool rst = MsOpSeaeCustCZDAL.CZ(headData, out msg);
var jsonRespose = new JsonResponse
{
Success = rst,
Message = msg,
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult UpLoadFP()
{
string opstatus = Request["OpStatus"];
string data = Request["data"];
var head = JsonConvert.Deserialize<Cust_CZ>(data);
head = MsOpSeaeCustCZDAL.GetData("GID = '" + head.GID + "'");
var file = Request.Files["LoadFile"];
if (file.FileName != "")
{
var path = Server.MapPath("../../UploadFiles/FP/" + head.GID);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var partname = DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
string filename = path + "\\" + partname;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
file.SaveAs(filename);
string filenameURL = "../../UploadFiles/FP/" + head.GID + "/" + partname;
head.FPPath = filenameURL;
}
string msg = "";
int saveType = opstatus == "add" ? 0 : 1;
var modb = new ModelObjectDB();
head.DbOperationType = DbOperationType.DbotUpd;
DBResult result = modb.Save(head);
var json = JsonConvert.Serialize(new { success = result.Success, Message = msg, Data = head.GID });
return new ContentResult() { Content = json };
}
public ContentResult DeletePiLiang(string bsnos)
{
DBResult rs = MsOpSeaeCustPriceDAL.DeletePiLiang(bsnos);
var jsonRespose = new JsonResponse { Success = rs.Success, Message = rs.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}