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.

201 lines
6.6 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.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using HcUtility.Comm;
using HcUtility.Core;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
namespace DSWeb.MvcShipping.Controllers
{
/// <summary>
/// 利润报表查询
/// </summary>
[JsonRequestBehavior]
public class MsRptVesselVoyController : Controller
{
//
// GET: /MvcShipping/MsRptOpProfit
public ActionResult Index()
{
return View();
}
//
// GET/RptMng/MsRptPcHeadQry/QryData
public ContentResult VesselListData(int start, int limit, string condition, string sort, string printstr,string sortstr)
{
var strSql = new StringBuilder();
strSql.Append("SELECT B.VESSEL,B.VOYNO,B.ETD,B.PORTLOAD,B.PORTDISCHARGE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT,SUM(B.NETWEIGHT) AS NETWEIGHT,SUM(B.KGS) AS KGS,SUM(B.TEU) AS TEU");
strSql.Append(",SUM(B.CNTR1) AS CNTR1,SUM(B.CNTR2) AS CNTR2,SUM(B.CNTR3) AS CNTR3,SUM(B.CNTR4) AS CNTR4,SUM(B.CNTR5) AS CNTR5,SUM(B.CNTR6) AS CNTR6,SUM(B.CNTR7) AS CNTR7,SUM(B.CNTR8) AS CNTR8,SUM(B.CNTR9) AS CNTR9,SUM(B.CNTR10) AS CNTR10,SUM(B.OTCNTR) AS OTCNTR");
strSql.Append(" FROM V_OP_BILL B ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" Group by B.VESSEL,B.VOYNO,B.ETD,B.PORTLOAD,B.PORTDISCHARGE ");
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
{
if (!string.IsNullOrEmpty(sortstr))
{
strSql.Append(" order by " + sortstr);
}
else
{
strSql.Append(" order by B.VESSEL");
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "完成",
Data = strSql.ToString()
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by B.VESSEL");
}
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(start, limit, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
}
public static string GetRangDAStr(string tb, string userid, string usercode, string companyid)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modProfitreportRange' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
operaterange = Convert.ToString(reader["OPERATERANGE"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "')";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var deptname = rangeDa.GetDEPTNAME(userid);
var userstr = new StringBuilder();
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
}
else
{
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
};
}
str =str+ ")";
reader.Close();
}
}
else
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
return str;
}
#region 参照部分
#endregion
}
}