using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcContainer.Models.MsOpPrice; using DSWeb.MvcContainer.DAL.MsOpPrice; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.RptMng.Comm; using System.Text; using DSWeb.Areas.CommMng.Models; using System.Data; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; namespace DSWeb.MvcContainer.Controllers { [JsonRequestBehavior] public class MsOpPriceController : Controller { // // GET: public ActionResult Index() { return View(); } public ActionResult SeaiIndex() { return View(); } // // GET: / public ActionResult SeaeEdit() { return View(); } public ActionResult SeaiEdit() { return View(); } public ActionResult AgentIndex() { return View(); } public ActionResult AgentEdit() { return View(); } public ActionResult YardIndex() { return View(); } public ActionResult RptYardIndex() { return View(); } public ActionResult YardEdit() { return View(); } public ActionResult AuditYardIndex() { return View(); } public ActionResult AddIndex() { return View(); } public ActionResult PiLiangFeeEdit() { return View(); } public ActionResult HistryFeeIndex() { return View(); } public ActionResult HistryFeeYardIndex() { return View(); } public ActionResult HistryFeeAgentIndex() { return View(); } // // GET: public ContentResult GetDataList(int start, int limit, string sort, string condition, string pricetype) { var dataList = MsOpPriceDAL.GetDataList(condition,pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]),sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDataListStr(string sort, string condition, string pricetype) { var dataListStr = MsOpPriceDAL.GetDataListStr(condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]),sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult GetListData(int start, int limit, string pricetype, string condition, string sort, string printstr = "false") { var rangstr = MsOpPriceDAL.GetRangDAStr(pricetype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"])); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(condition)) { condition = condition + " and " + rangstr; } else { condition = rangstr; } } var isopen = MsBaseInfoDAL.GetUserModuleEnable("modAgentdetailView", Convert.ToString(Session["USERID"])); condition = condition.Replace("'", "''"); var strSql = new StringBuilder(); strSql.Append(" declare @sql varchar(4000) declare @feename varchar(1000) "); strSql.Append(" set @sql='select b.GID,b.PRICETYPE,b.LINE,b.COUNTRY,b.PORTLOAD,b.PORTDISCHARGE,b.TRANSPORT,b.CARRIER,b.WEEKETD,b.YARD,b.FEETYPE "); strSql.Append(",b.VOYAGE,b.VALIDETD,b.SERVICE,b.GOODTYPE,b.CTNSTATUS,b.AGENTNAME,b.DEBITCORPNAME,b.PRICEDATE,b.REMARKS,b.INPUTBY,b.INPUTTIME,b.COMPANYID,b.OP"); if (isopen == true) strSql.Append(", b.AGENTATTN,b.AGENTADDR "); else strSql.Append(", '''' AGENTATTN,'''' AGENTADDR "); strSql.Append(",(select ShowName from [user] where GID=b.INPUTBY) as INPUTBYREF "); strSql.Append(",(select ShowName from [user] where GID=b.OP) as OPREF' "); strSql.Append(" select @sql=@sql+',sum(case when c.UNIT='''+g.UNIT+''' and c.CURRENCY='''+g.CURRENCY+''' and c.FEENAME=''海运费'' then c.UNITPRICE else 0 end) as HYF'+g.UNIT+g.CURRENCY from (select DISTINCT FEENAME,UNIT,CURRENCY from op_price_items WHERE FEENAME='海运费') as g "); strSql.Append(" set @sql=@sql+',sum(case when c.CURRENCY=''RMB''AND c.FEENAME<>''海运费'' then c.UNITPRICE else 0 end) as OTRMB,sum(case when c.CURRENCY=''USD'' AND c.FEENAME<>''海运费'' then c.UNITPRICE else 0 end) as OTUSD' "); strSql.Append(" set @sql=@sql+',sum(case when c.CURRENCY=''JPY''AND c.FEENAME<>''海运费'' then c.UNITPRICE else 0 end) as OTJPY,sum(case when c.CURRENCY=''EUR'' AND c.FEENAME<>''海运费'' then c.UNITPRICE else 0 end) as OTEUR' "); strSql.Append(" set @sql=@sql+',sum(case when c.CURRENCY=''RMB'' then c.UNITPRICE else 0 end) as TOTALRMB,sum(case when c.CURRENCY=''USD'' then c.UNITPRICE else 0 end) as TOTALUSD' "); strSql.Append(" set @sql=@sql+',sum(case when c.CURRENCY=''JPY'' then c.UNITPRICE else 0 end) as TOTALJPY,sum(case when c.CURRENCY=''EUR'' then c.UNITPRICE else 0 end) as TOTALEUR' "); strSql.Append(" set @sql=@sql+' from op_price_items c left join op_price b on (b.GID=c.LINKGID) "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" Where " + condition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" group by b.GID,b.PRICETYPE,b.LINE,b.COUNTRY,b.PORTLOAD,b.PORTDISCHARGE,b.TRANSPORT,b.CARRIER,b.WEEKETD,b.YARD,b.FEETYPE,"); strSql.Append("b.VOYAGE,b.VALIDETD,b.SERVICE,b.GOODTYPE,b.CTNSTATUS,b.AGENTNAME,b.AGENTATTN,b.AGENTADDR,b.DEBITCORPNAME,"); strSql.Append("b.PRICEDATE,b.REMARKS,b.INPUTBY,b.INPUTTIME,b.COMPANYID,b.OP "); strSql.Append(" order by " + sortstring + " '"); } else { strSql.Append(" group by b.GID,b.PRICETYPE,b.LINE,b.COUNTRY,b.PORTLOAD,b.PORTDISCHARGE,b.TRANSPORT,b.CARRIER,b.WEEKETD,b.YARD,b.FEETYPE,"); strSql.Append("b.VOYAGE,b.VALIDETD,b.SERVICE,b.GOODTYPE,b.CTNSTATUS,b.AGENTNAME,b.AGENTATTN,b.AGENTADDR,b.DEBITCORPNAME,"); strSql.Append("b.PRICEDATE,b.REMARKS,b.INPUTBY,b.INPUTTIME,b.COMPANYID,b.OP' "); } strSql.Append(" exec(@sql) "); if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true")) { var jsonRespose = new JsonResponse { Success = true, Message = "完成", Data = strSql.ToString() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var dbparams = new List(); 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(start, limit, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } } public ContentResult GetFeeListData(int start, int limit, string pricetype, string condition, string sort, string printstr = "false") { var rangstr = MsOpPriceDAL.GetRangDAStr(pricetype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"])); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(condition)) { condition = condition + " and " + rangstr; } else { condition = rangstr; } } var strSql = new StringBuilder(); strSql.Append(" SELECT f.GID,f.LINKGID,f.ITEMSNO,f.FEENAME,f.UNIT,f.UNITPRICE,f.CURRENCY,f.CHANGERATE "); strSql.Append(" ,f.GOODSNAME,f.REMARKS,f.INPUTBY,f.INPUTTIME,f.FEESTATUS,f.CTNSTATUS ,f.FREEDAY "); strSql.Append(",f.VALIDETD,f.AUDITOPERATOR,f.AUDITDATE,f.CUSTOMERNAME,b.COUNTRY,b.PORTDISCHARGE,b.YARD,b.FEETYPE"); strSql.Append(",b.COMPANYID,b.PRICETYPE"); strSql.Append(",(select ShowName from [user] where GID=f.AUDITOPERATOR) as AUDITNAME"); strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=f.FeeStatus) as FEESTATUS_REF"); strSql.Append(" FROM op_price_items f left join op_price b on (b.GID=f.LINKGID) "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" Where " + condition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring + " '"); } else { strSql.Append(" order by b.INPUTTIME,b.GID "); } if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true")) { var jsonRespose = new JsonResponse { Success = true, Message = "完成", Data = strSql.ToString() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var dbparams = new List(); 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(start, limit, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } } public ContentResult GetUNITLIST(string condition) { //var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); //if (!string.IsNullOrEmpty(strDa)) //{ // if (!string.IsNullOrEmpty(condition)) // { // condition = condition + " and " + strDa; // } // else // { // condition = strDa; // } //} var strSql = new StringBuilder(); strSql.Append(" SELECT DISTINCT c.UNIT,c.CURRENCY "); strSql.Append(" from op_price_items c left join op_price b on (b.GID=c.LINKGID) "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" Where c.FEENAME='海运费' and " + condition); } else { strSql.Append(" Where c.FEENAME='海运费' "); } strSql.Append(" ORDER BY c.UNIT "); var dbparams = new List(); 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, 100, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } public ContentResult GetWXFEELIST(string condition) { var strSql = new StringBuilder(); strSql.Append(" SELECT DISTINCT c.FEENAME "); strSql.Append(" from op_price_items c left join op_price b on (b.GID=c.LINKGID) "); strSql.Append(" Where b.FEETYPE='维修' "); strSql.Append(" ORDER BY c.FEENAME "); var dbparams = new List(); 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 PiliangFee(string bill, string fee) { // var billList = JsonConvert.Deserialize>(bill); var feeList = JsonConvert.Deserialize>(fee); DBResult result = MsOpPriceDAL.SavePiliangUpdateFee(billList, feeList); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } // // GET:/TruckMng/MsWlTyreAcc/GetData/ public ContentResult GetData(string handle, string condition) { OpPrice head = null; if (handle == "edit") { head = MsOpPriceDAL.GetData(condition, Convert.ToString(Session["USERID"])); } if (head == null) { head = new OpPrice(); head.COMPANYID = Convert.ToString(Session["COMPANYID"]); head.OP = Convert.ToString(Session["USERID"]); head.OPREF = Convert.ToString(Session["SHOWNAME"]); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string body) { var headData = JsonConvert.Deserialize(data); var bodyList = JsonConvert.Deserialize>(body); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.COMPANYID = Convert.ToString(Session["COMPANYID"]); headData.INPUTBY = Convert.ToString(Session["USERID"]); headData.INPUTTIME = 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; } var GID = headData.GID; if (headData.PRICEDATE == "") headData.PRICEDATE = null; if (headData.VALIDETD == "") headData.VALIDETD = null; var modb = new ModelObjectDB(); var result=modb.Save(headData); if (result.Success == true) { MsOpPriceDAL.SavePriceItems(bodyList, GID, Convert.ToString(Session["USERID"])); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOpPriceDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsOpPriceDAL.DeleteOpPrice(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SubmitAudit(string feebody) { var billData = JsonConvert.Deserialize>(feebody); DBResult result = MsOpPriceDAL.SubmitAudit(billData); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult AuditFee(string data) { var billData = JsonConvert.Deserialize>(data); DBResult result = MsOpPriceDAL.AuditFee(billData, Convert.ToString(Session["USERID"])); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult AuditBackFee(string data) { var billData = JsonConvert.Deserialize>(data); DBResult result = MsOpPriceDAL.AuditBack(billData); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult GetPriceItemsList(string condition, string sort) { var dataList = MsOpPriceDAL.GetPriceItemsList(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult SavePriceItems(string body, string PID) { // var bodyList = JsonConvert.Deserialize>(body); DBResult result = MsOpPriceDAL.SavePriceItems(bodyList, PID, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeletePriceItems(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsOpPriceDAL.DeletePriceItems(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetCustList(string condition) { var dataList = MsOpPriceDAL.GetCustList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetYardPrice(int start, int limit, string condition, string sort) { var rangstr = MsOpPriceDAL.GetRangDAStr("4", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(condition)) { condition = condition + " and " + rangstr; } else { condition = rangstr; } } var strSql = new StringBuilder(); strSql.Append("SELECT b.GID,b.LINKGID,b.FEENAME,b.UNIT,b.CURRENCY,b.GOODSNAME,b.REMARKS,b.PORTDISCHARGE,b.YARD"); strSql.Append(",b.UNITPRICE,b.CHANGERATE,b.CUSTOMERNAME,b.COUNTRY,b.VALIDETD"); strSql.Append(" FROM v_yard_price b "); strSql.Append(" WHERE 1=1 "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" AND " + condition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring ); } else { strSql.Append(" order by b.FEENAME,b.UNIT,b.CURRENCY,b.GOODSNAME,b.REMARKS,b.PORTDISCHARGE,b.YARD "); } var dbparams = new List(); 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(start, limit, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } //public ContentResult GetYardPrice(string condition) //{ // var rangstr = MsOpPriceDAL.GetRangDAStr("4", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); // if (!string.IsNullOrEmpty(rangstr)) // { // if (!string.IsNullOrEmpty(condition)) // { // condition = condition + " and " + rangstr; // } // else // { // condition = rangstr; // } // } // var strSql = new StringBuilder(); // var objlist =MsOpPriceDAL.GetCustList(condition,Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); // strSql.Append("SELECT b.FEENAME,b.UNIT,b.CURRENCY,b.GOODSNAME,b.REMARKS,b.PORTDISCHARGE,b.YARD"); // foreach (var enumValue in objlist) // { // strSql.Append(",SUM(ISNULL(case when CUSTOMERNAME='" + enumValue.CUSTNAME + "' then UNITPRICE else 0 end,0)) AS " + enumValue.FIELDNAME); // } // strSql.Append(" FROM v_yard_price b "); // strSql.Append(" WHERE 1=1 "); // if (!string.IsNullOrEmpty(condition)) // { // strSql.Append(" AND " + condition); // } // strSql.Append(" Group by b.FEENAME,b.UNIT,b.CURRENCY,b.GOODSNAME,b.REMARKS,b.PORTDISCHARGE,b.YARD "); // strSql.Append(" order by b.FEENAME,b.UNIT,b.CURRENCY,b.GOODSNAME,b.REMARKS,b.PORTDISCHARGE,b.YARD "); // var dbparams = new List(); // 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, 2000, dbRptResult, "Result_Set", true); // return new ContentResult() { Content = json }; //} #region 参照部分 #endregion } }