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.
252 lines
9.8 KiB
C#
252 lines
9.8 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.Areas.MvcShipping.Models.JinKouSuYuan;
|
|
using DSWeb.Areas.MvcShipping.DAL.JinKouSuYuan;
|
|
using System.IO;
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
public class JinKouSuYuanController : Controller
|
|
{
|
|
//
|
|
// GET:
|
|
public ActionResult Index ( )
|
|
{
|
|
return View();
|
|
}
|
|
//
|
|
// GET: /
|
|
public ActionResult Edit ( )
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult InEdit ( )
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetDataList_OPBS(int start, int limit, string sort, string condition)
|
|
{
|
|
int count = 0;
|
|
var dataList = JinKouSuYuanDAL.GetDataList_OPBS(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_OPBS(string OpStatus, string condition)
|
|
{
|
|
int count = 0;
|
|
if (OpStatus=="add")
|
|
{
|
|
op_bs ob = new op_bs();
|
|
ob.BSNO = Guid.NewGuid().ToString();
|
|
ob.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = ob });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
else
|
|
{
|
|
var dataList = JinKouSuYuanDAL.GetDataList_OPBS(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 GetDataList_OPBSGOODS(int start, int limit, string sort, string condition)
|
|
{
|
|
int count = 0;
|
|
var dataList = JinKouSuYuanDAL.GetDataList_OPBSGOODS(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 Save(string opstatus, string data, string op_bs_goods, string op_bs_goodsDel)
|
|
{
|
|
var head = JsonConvert.Deserialize<op_bs>(data);
|
|
var goodsList = JsonConvert.Deserialize<List<OP_BS_GOODS>>(op_bs_goods);
|
|
var goodsDelList = JsonConvert.Deserialize<List<OP_BS_GOODS>>(op_bs_goodsDel);
|
|
|
|
string msg = "";
|
|
int saveType = opstatus == "add" ? 0 : 1;
|
|
bool result = JinKouSuYuanDAL.Save_OPBS(head,saveType,out msg);
|
|
if (result)
|
|
{
|
|
if (goodsList!=null)
|
|
{
|
|
foreach (var item in goodsList)
|
|
{
|
|
int saveType2 = item.GOODS_GID == "*" ? 0 : 1;
|
|
item.BSNO = head.BSNO;
|
|
bool rst2 = JinKouSuYuanDAL.Save_OPBSGOODS(item, saveType2, out msg);
|
|
if (!rst2)
|
|
{
|
|
result = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (goodsDelList!=null)
|
|
{
|
|
JinKouSuYuanDAL.Delete_OPBSGOODS(goodsDelList, out msg);
|
|
}
|
|
|
|
}
|
|
var json = JsonConvert.Serialize(new { Success = result, Message = msg, Data = head.BSNO });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult Delete(string opstatus, string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<List<op_bs>>(data);
|
|
string msg = "";
|
|
bool result = JinKouSuYuanDAL.Delete_OPBS(head,out msg);
|
|
var json = JsonConvert.Serialize(new { Success = result, Message = msg });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetCodeGoodsList()
|
|
{
|
|
var dataList = JinKouSuYuanDAL.GetCodeGoodsList();
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetInfoWithGoodId(string GID)
|
|
{
|
|
string ycg = "";
|
|
string GuiGe = JinKouSuYuanDAL.GetInfoWithGoodId(GID, out ycg);
|
|
if (GuiGe==""||GuiGe==null)
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = false, Message = "查询失败" });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
else
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", GuiGe = GuiGe, YuanChanGuo = ycg });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
}
|
|
|
|
public ContentResult CreateCode(string data, string CodeBegin)
|
|
{
|
|
var opbsgoods = JsonConvert.Deserialize<List<OP_BS_GOODS>>(data);
|
|
int ResultNum;
|
|
bool rst = int.TryParse(CodeBegin, out ResultNum);
|
|
if (!rst)
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "识别码开始值录入错误" });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
string msg = JinKouSuYuanDAL.CreateCode(opbsgoods, ResultNum);
|
|
var json2 = JsonConvert.Serialize(new { Success = true, Message = msg });
|
|
return new ContentResult() { Content = json2 };
|
|
|
|
}
|
|
|
|
public ContentResult Submit()
|
|
{
|
|
|
|
var opstatus = Request["OpStatus"];
|
|
var head = JsonConvert.Deserialize<op_bs>(Request["data"]);
|
|
var goodsList = JsonConvert.Deserialize<List<OP_BS_GOODS>>(Request["op_bs_goods"]);
|
|
var goodsDelList = JsonConvert.Deserialize<List<OP_BS_GOODS>>(Request["op_bs_goodsDel"]);
|
|
|
|
//图片上传
|
|
var file = Request.Files["GOODCREPATH"];
|
|
if (file.FileName != "")
|
|
{
|
|
var path = Server.MapPath("../../UploadFiles/CRE/" + head.BSNO);
|
|
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/CRE/" + head.BSNO + "/" + partname;
|
|
head.GOODCREPATH = filenameURL;
|
|
}
|
|
|
|
string msg = "";
|
|
int saveType = opstatus == "add" ? 0 : 1;
|
|
bool result = JinKouSuYuanDAL.Save_OPBS(head, saveType, out msg);
|
|
if (result)
|
|
{
|
|
if (goodsList != null)
|
|
{
|
|
foreach (var item in goodsList)
|
|
{
|
|
item.BSNO = head.BSNO;
|
|
int saveType2 = item.GOODS_GID == "*" ? 0 : 1;
|
|
bool rst2 = JinKouSuYuanDAL.Save_OPBSGOODS(item, saveType2, out msg);
|
|
if (!rst2)
|
|
{
|
|
result = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (goodsDelList != null)
|
|
{
|
|
JinKouSuYuanDAL.Delete_OPBSGOODS(goodsDelList, out msg);
|
|
}
|
|
|
|
}
|
|
var json = JsonConvert.Serialize(new { success = result, Message = msg, Data = head.BSNO });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetGoodInfo()
|
|
{
|
|
var code = Request["q"];
|
|
|
|
if (code!=null)
|
|
{
|
|
string goodcode = JinKouSuYuanDAL.Base64Decode(code);
|
|
var data = JinKouSuYuanDAL.GetGoodInfo(goodcode);
|
|
if (data.Code!=""&&data.Code!=null)
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = data });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
else
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "无此数据", data = "" });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "无此数据", data = "" });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
}
|
|
}
|
|
} |