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.

173 lines
5.9 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.Web;
using System.Web.Mvc;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.TruckMng.Helper;
using HcUtility.Comm;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.Areas.CommMng.Models;
using DSWeb.EntityDA;
using System.Text;
namespace DSWeb.Areas.RptMng.Controllers
{
[JsonRequestBehavior]
public class MsRptFuelQryController : Controller
{
//
// GET: /RptMng/MsRptFuelQry
public ActionResult Index()
{
return View();
}
//
// GET/RptMng/MsRptFuelQry/QryData
public ContentResult QryData(int start, int limit, string condition,string sort)
{
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request));
if (!string.IsNullOrEmpty(strDa))
{
if (!string.IsNullOrEmpty(condition))
{
condition = condition + " and " + strDa;
}
else
{
condition = strDa;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT A.ORGCODE,A.TRUCKNO,A.DRVNAME,");
strSql.Append("SUM(A.RATEDFUEL) AS RATEDFUEL,SUM(A.FuelQty) AS REALFUEL,'' AS REMARK");
strSql.Append(" from tMsWlPcHead A where 1=1 ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition);
}
strSql.Append(" group by A.OrgCode,A.TruckNo,A.DrvName ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
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 };
/*
var dbparams = new List<CustomDbParamter>();
var paramps_OrgCode = new CustomDbParamter();
paramps_OrgCode.ParameterName = "@PS_ORGCODE";
paramps_OrgCode.DbType = DbType.String;
paramps_OrgCode.Direction = ParameterDirection.Input;
paramps_OrgCode.Value = RptHelper.JsonGetValue(condition, "PS_ORGCODE").ToString();
dbparams.Add(paramps_OrgCode);
var paramps_TruckNo = new CustomDbParamter();
paramps_TruckNo.ParameterName = "@PS_TRUCKNO";
paramps_TruckNo.DbType = DbType.String;
paramps_TruckNo.Direction = ParameterDirection.Input;
paramps_TruckNo.Value = RptHelper.JsonGetValue(condition, "PS_TRUCKNO").ToString();
dbparams.Add(paramps_TruckNo);
var paramps_ExpDateBgn = new CustomDbParamter();
paramps_ExpDateBgn.ParameterName = "@PS_EXPDATEBGN";
paramps_ExpDateBgn.DbType = DbType.String;
paramps_ExpDateBgn.Direction = ParameterDirection.Input;
paramps_ExpDateBgn.Value = RptHelper.JsonGetValue(condition, "PS_EXPDATEBGN").ToString();
dbparams.Add(paramps_ExpDateBgn);
var paramps_ExpDateEnd = new CustomDbParamter();
paramps_ExpDateEnd.ParameterName = "@PS_EXPDATEEND";
paramps_ExpDateEnd.DbType = DbType.String;
paramps_ExpDateEnd.Direction = ParameterDirection.Input;
paramps_ExpDateEnd.Value = RptHelper.JsonGetValue(condition, "PS_EXPDATEEND").ToString();
dbparams.Add(paramps_ExpDateEnd);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsRptFuelQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", false);
return new ContentResult() { Content = json };
*/
}
public static string GetRangDAStr(string tb, string userid, string usercode, string orgcode)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modTruckYl' 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 = " UPPER(A.ORGCODE)='" + orgcode + "'";
}
else if (visiblerange == "2")
{
str = " UPPER(A.ORGCODE)='" + orgcode + "'";
}
else if (visiblerange == "1")
{
str = " UPPER(A.ORGCODE)='" + orgcode + "'";
}
return str;
}
#region 参照部分
#endregion
}
}