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.

149 lines
5.2 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.CodeGoodInv;
using DSWeb.MvcShipping.DAL.MsCodeGoodInv;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCodeGoodInvController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult InvIndex()
{
return View();
}
//
// GET
public ContentResult GetDataList(string condition,string sort)
{
var dataList = MsCodeGoodInvDAL.GetDataList(condition, 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)
{
CodeGoodInv head = null;
if (handle == "edit")
{
var list = MsCodeGoodInvDAL.GetDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeGoodInv();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
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 headData = JsonConvert.Deserialize<CodeGoodInv>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDetail(string body)
{
string errorstr = "";
DBResult result = null;
var bodyList = JsonConvert.Deserialize<List<CodeGoodInv>>(body);
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
#region 默认值
CodeGoodInv headRow = new CodeGoodInv();
headRow.GOODCODE = enumValue.GOODCODE;
headRow.GOODNAME = enumValue.GOODNAME;
headRow.DESCRIP = enumValue.DESCRIP;
headRow.TAXRATE = enumValue.TAXRATE;
headRow.TAXNO = enumValue.TAXNO;
headRow.TAXCLASS = enumValue.TAXCLASS;
headRow.TAXCLASSNAME = enumValue.TAXCLASSNAME;
headRow.ISTAXPRICE = enumValue.ISTAXPRICE;
headRow.ISUSEPREF = enumValue.ISUSEPREF;
headRow.ISDEF = enumValue.ISDEF;
headRow.SPEC = enumValue.SPEC;
headRow.UNIT = enumValue.UNIT;
headRow.ZTAXTYPE = enumValue.ZTAXTYPE;
headRow.DEFREMARK = enumValue.DEFREMARK;
headRow.DEFCURR = enumValue.DEFCURR;
#endregion
//
if (enumValue.GID.ToString().Trim() == "*")//"add"
{
headRow.GID = Guid.NewGuid().ToString().Trim();
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.GID = enumValue.GID.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
}
//
var modb = new ModelObjectDB();
result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
}
}
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}