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.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsCodeFeeSetListController.cs

422 lines
14 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.MsCodeFeeSetList;
using DSWeb.MvcShipping.DAL.MsAnnounce;
using DSWeb.MvcShipping.DAL.MsCodeFeeSetList;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using System.Web.Script.Serialization;
using System.Text;
using System.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.SoftMng.Filter;
namespace DSWeb.MvcShipping.Controllers
{
public class MsCodeFeeSetListController : Controller
{
//
// GET:
public ActionResult Index ( )
{
return View();
}
//
// GET: /
public ActionResult Edit ( )
{
return View();
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataList ( int start, int limit, string sort, string condition )
{
var dataList = MsCodeFeeSetListDAL.GetDataList(condition,start,limit,sort);
int count = MsCodeFeeSetListDAL.getTotalCount(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataListStr(string sort, string condition)
{
var dataListStr = MsCodeFeeSetListDAL.GetDataListStr(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetData(string handle, string condition)
{
CodeFeeSetList head = null;
if (handle == "edit")
{
var list = MsCodeFeeSetListDAL.GetDataList(condition,0,1);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeFeeSetList();
head.ISSEA = true;
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeGroup()
{
var strSql = new StringBuilder();
strSql.Append(" SELECT GID,FEEGROUPCODE,FEEGROUPNAME,REMARKS from code_fee_group");
strSql.Append(" ORDER BY FEEGROUPNAME");
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 1000, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<CodeFeeSetList>(data);
var result=new DBResult();
var addcode = true;
if (opstatus == "add")
{
if (MsCodeFeeSetListDAL.GetCodeFeeCount(" NAME='"+headData.NAME+"' AND GID<>'"+headData.GID+"'"))
{
addcode = false;
result.Success = false;
result.Message="费用名称"+headData.NAME+"已存在,不允许重复!";
}
else
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.CREATEUSER = Convert.ToString(Session["USERID"]);
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (string.IsNullOrEmpty(headData.TAXRATE)) headData.TAXRATE = "0";
if (headData.TAXRATE == "") headData.TAXRATE = "0";
if (addcode)
{
var modb = new ModelObjectDB();
result = modb.Save(headData);
var GID = headData.GID;
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodeFeeSetListDAL.GetData("A.GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult modify(string data, string modifydata)
{
var headdata = JsonConvert.Deserialize<CodeFeeSetList>(data);
var amodifydata = JsonConvert.Deserialize<CodeFeeSetList>(modifydata);
var result = new DBResult();
result = MsCodeFeeSetListDAL.Modify(headdata, amodifydata, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Reapeat(string oldfeename, string newfeename)
{
var result = new DBResult();
result = MsCodeFeeSetListDAL.Reapeat(oldfeename, newfeename, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Update()
{
var dataList = Request["data"];
JavaScriptSerializer json = new JavaScriptSerializer();
List<CodeFeeSetList> list = json.Deserialize<List<CodeFeeSetList>>(dataList);
list = serializeParams(list);
DBResult result = null;
if (list != null)
{
foreach (var model in list)
{
var modb = new ModelObjectDB();
if (model.GID==string.Empty)
{
model.GID = Guid.NewGuid().ToString();
model.DbOperationType = DbOperationType.DbotIns;
model.CREATEUSER = Session["USERID"].ToString();
model.MODIFIEDUSER = Session["USERID"].ToString();
}
else
{
model.DbOperationType = DbOperationType.DbotUpd;
model.MODIFIEDUSER = Session["USERID"].ToString();
model.CREATEUSER = Session["USERID"].ToString();
}
if (string.IsNullOrEmpty(model.TAXRATE)) model.TAXRATE = "0";
result= modb.Save(model);
}
}
var jsonstr = JsonConvert.Serialize(new { Success = true, Message = result.Success ? "保存成功" : result.Message });
return new ContentResult() { Content = jsonstr };
}
public ContentResult Delete ( )
{
var data = Request["data"];
JavaScriptSerializer json = new JavaScriptSerializer();
CodeFeeSetList codefee = json.Deserialize<CodeFeeSetList>(data);
var result = new DBResult();
if (codefee != null)
{
if (MsCodeFeeSetListDAL.GetFeeCount(codefee.NAME))
{
result.Success=false;
result.Message = "此费用名称已使用,不能删除或修改";
}
else
{
var modb = new ModelObjectDB();
codefee.DbOperationType = DbOperationType.DbotDel;
result = modb.Save(codefee);
}
}
var jsonstr = JsonConvert.Serialize(new { Success = result.Success, Message = result.Success?"删除成功":result.Message });
return new ContentResult() { Content = jsonstr };
}
public ContentResult IsFeeUse(string feename)
{
var result = new DBResult();
if (MsCodeFeeSetListDAL.GetFeeCount(feename))
{
result.Success = true;
result.Message = "费用名称" + feename + "已使用!";
}
else
{
result.Success = false;
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private List<CodeFeeSetList> serializeParams (List<CodeFeeSetList> list)
{
foreach (var codefee in list)
{
string v1 = "";
switch (codefee.DEFAULTUNIT)
{
case "单票":
v1 = "1";
break;
case "重量":
v1 = "2";
break;
case "尺码":
v1 = "3";
break;
case "计费吨":
v1 = "4";
break;
case "TEU":
v1 = "5";
break;
case "净重":
v1 = "6";
break;
case "总价":
v1 = "7";
break;
case "计价重量":
v1 = "8";
break;
case "箱型":
v1 = "9";
break;
case "CBM":
v1 = "10";
break;
case "BILL":
v1 = "11";
break;
default:
v1 = codefee.DEFAULTUNIT;
break;
}
codefee.DEFAULTUNIT = v1;
string v2 = "";
switch (codefee.DEFAULTDEBIT)
{
case "船公司":
v2 = "1";
break;
case "订舱代理":
v2 = "2";
break;
case "场站":
v2 = "3";
break;
case "车队":
v2 = "4";
break;
case "委托单位":
v2 = "5";
break;
case "报关行":
v2 = "6";
break;
case "代理":
v2 = "7";
break;
case "航空公司":
v2 = "8";
break;
case "发货人":
v2 = "9";
break;
case "收货人":
v2 = "10";
break;
case "通知人":
v2 = "11";
break;
default:
v2 = codefee.DEFAULTDEBIT;
break;
}
codefee.DEFAULTDEBIT = v2;
string v3 = "";
switch (codefee.DEFAULTCREDIT)
{
case "船公司":
v3 = "1";
break;
case "订舱代理":
v3 = "2";
break;
case "场站":
v3 = "3";
break;
case "车队":
v3 = "4";
break;
case "委托单位":
v3 = "5";
break;
case "报关行":
v3 = "6";
break;
case "代理":
v3 = "7";
break;
case "航空公司":
v3 = "8";
break;
case "发货人":
v3 = "9";
break;
case "收货人":
v3 = "10";
break;
case "通知人":
v3 = "11";
break;
case "船代":
v3 = "12";
break;
case "码头":
v3 = "13";
break;
default:
v3 = codefee.DEFAULTCREDIT;
break;
}
codefee.DEFAULTCREDIT = v3;
}
return list;
}
}
}