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.
152 lines
5.6 KiB
C#
152 lines
5.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using System.Collections.Generic;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using System.Web.Script.Serialization;
|
|
using DSWeb.EntityDA;
|
|
using System.Data;
|
|
using System.Text;
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
using DSWeb.Areas.MvcShipping.Models.JinKouSuYuan;
|
|
using DSWeb.Areas.MvcShipping.DAL.JinKouSuYuan;
|
|
using System.IO;
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
public class JinKouSuYuan_ShangPinController : Controller
|
|
{
|
|
//
|
|
// GET:
|
|
public ActionResult Index ( )
|
|
{
|
|
return View();
|
|
}
|
|
//
|
|
// GET: /
|
|
public ActionResult Edit ( )
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult InEdit ( )
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetDataList_CodeGoods(int start, int limit, string sort, string condition)
|
|
{
|
|
int count = 0;
|
|
var dataList = JinKouSuYuanShangPinDAL.GetDataList_CodeGoods(condition, start, limit, out count, sort);
|
|
var timeStamp = DateTime.Now.ToShortDateString();
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList(), timeStamp = timeStamp });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetData_CodeGoods(string OpStatus, string condition)
|
|
{
|
|
int count = 0;
|
|
if (OpStatus=="add")
|
|
{
|
|
code_goods cg = new code_goods();
|
|
cg.GID = Guid.NewGuid().ToString();
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = cg });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
else
|
|
{
|
|
var dataList = JinKouSuYuanShangPinDAL.GetDataList_CodeGoods(condition, 0, 1, out count);
|
|
if (dataList.Count > 0)
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList()[0] });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
else
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "无此数据", data = "" });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public ContentResult Save(string opstatus, string data)
|
|
{
|
|
|
|
|
|
var head = JsonConvert.Deserialize<code_goods>(data);
|
|
var file = Request.Files["LoadFile"];
|
|
if (file!=null)
|
|
{
|
|
var path = Server.MapPath("../../UploadFiles/" + 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);
|
|
head.IMGPATH = filename;
|
|
}
|
|
|
|
string msg = "";
|
|
int saveType = opstatus == "add" ? 0 : 1;
|
|
bool result = JinKouSuYuanShangPinDAL.Save_CodeGoods(head,saveType,out msg);
|
|
var json = JsonConvert.Serialize(new { Success = result, Message = msg, Data = head.GID });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult Submit()
|
|
{
|
|
|
|
string opstatus = Request["OpStatus"];
|
|
string data = Request["data"];
|
|
var head = JsonConvert.Deserialize<code_goods>(data);
|
|
|
|
var file = Request.Files["LoadFile"];
|
|
if (file.FileName != "")
|
|
{
|
|
var path = Server.MapPath("../../UploadFiles/" + 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/"+head.GID + "/" + partname;
|
|
head.IMGPATH = filenameURL;
|
|
}
|
|
|
|
string msg = "";
|
|
int saveType = opstatus == "add" ? 0 : 1;
|
|
bool result = JinKouSuYuanShangPinDAL.Save_CodeGoods(head, saveType, out msg);
|
|
var json = JsonConvert.Serialize(new { success = result, Message = msg, Data = head.GID });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult Delete(string opstatus, string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<List<code_goods>>(data);
|
|
string msg = "";
|
|
bool result = JinKouSuYuanShangPinDAL.Delete_CodeGoods(head, out msg);
|
|
var json = JsonConvert.Serialize(new { Success = result, Message = msg });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
}
|
|
} |