|
|
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.Models.MonthDataSet;
|
|
|
using DSWeb.MvcShipping.Models.ProfitFieldSet;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 月度利润报表查询
|
|
|
/// </summary>
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsRptOpProfitMonthController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET: /MvcShipping/MsRptOpProfit
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult ProfitFieldSet()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/RptMng/MsRptPcHeadQry/QryData
|
|
|
|
|
|
|
|
|
public ContentResult CustListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string startmonth, string endmonth)
|
|
|
{
|
|
|
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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var monthlist = GetMonthList(startmonth, endmonth);
|
|
|
var Fieldset = GetProfitFieldSet(Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.CUSTOMERNAME");
|
|
|
foreach (var enumValue in monthlist)
|
|
|
{
|
|
|
if (Fieldset.RMBDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBDR ");
|
|
|
if (Fieldset.RMBCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBCR ");
|
|
|
if (Fieldset.USDDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDDR ");
|
|
|
if (Fieldset.USDCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDCR ");
|
|
|
if (Fieldset.OTDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTDR ");
|
|
|
if (Fieldset.OTCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTCR ");
|
|
|
if (Fieldset.TTLDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLDR ");
|
|
|
if (Fieldset.TTLCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLCR ");
|
|
|
if (Fieldset.RMBPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR-G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBPROFIT ");
|
|
|
if (Fieldset.USDPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR-G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDPROFIT ");
|
|
|
if (Fieldset.OTPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR-G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTPROFIT ");
|
|
|
if (Fieldset.TTLPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR-G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLPROFIT ");
|
|
|
if (Fieldset.TEU)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then B.TEU else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TEU ");
|
|
|
}
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.CUSTOMERNAME ");
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
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.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult SaleListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string startmonth, string endmonth)
|
|
|
{
|
|
|
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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var monthlist = GetMonthList(startmonth, endmonth);
|
|
|
var Fieldset = GetProfitFieldSet(Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.SALE");
|
|
|
foreach (var enumValue in monthlist)
|
|
|
{
|
|
|
if (Fieldset.RMBDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBDR ");
|
|
|
if (Fieldset.RMBCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBCR ");
|
|
|
if (Fieldset.USDDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDDR ");
|
|
|
if (Fieldset.USDCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDCR ");
|
|
|
if (Fieldset.OTDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTDR ");
|
|
|
if (Fieldset.OTCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTCR ");
|
|
|
if (Fieldset.TTLDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLDR ");
|
|
|
if (Fieldset.TTLCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLCR ");
|
|
|
if (Fieldset.RMBPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR-G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBPROFIT ");
|
|
|
if (Fieldset.USDPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR-G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDPROFIT ");
|
|
|
if (Fieldset.OTPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR-G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTPROFIT ");
|
|
|
if (Fieldset.TTLPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR-G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLPROFIT ");
|
|
|
if (Fieldset.TEU)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then B.TEU else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TEU ");
|
|
|
}
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.SALE ");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by B.SALE," + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALE");
|
|
|
|
|
|
}
|
|
|
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.SALE");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult BsSourceListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string startmonth, string endmonth)
|
|
|
{
|
|
|
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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var monthlist = GetMonthList(startmonth, endmonth);
|
|
|
var Fieldset = GetProfitFieldSet(Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.BSSOURCE");
|
|
|
foreach (var enumValue in monthlist)
|
|
|
{
|
|
|
if (Fieldset.RMBDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBDR ");
|
|
|
if (Fieldset.RMBCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBCR ");
|
|
|
if (Fieldset.USDDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDDR ");
|
|
|
if (Fieldset.USDCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDCR ");
|
|
|
if (Fieldset.OTDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTDR ");
|
|
|
if (Fieldset.OTCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTCR ");
|
|
|
if (Fieldset.TTLDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLDR ");
|
|
|
if (Fieldset.TTLCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLCR ");
|
|
|
if (Fieldset.RMBPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR-G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBPROFIT ");
|
|
|
if (Fieldset.USDPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR-G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDPROFIT ");
|
|
|
if (Fieldset.OTPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR-G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTPROFIT ");
|
|
|
if (Fieldset.TTLPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR-G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLPROFIT ");
|
|
|
if (Fieldset.TEU)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then B.TEU else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TEU ");
|
|
|
}
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.BSSOURCE ");
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.BSSOURCE");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.BSSOURCE");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 ContentResult BsSourceDetailListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string startmonth, string endmonth)
|
|
|
{
|
|
|
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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var monthlist = GetMonthList(startmonth, endmonth);
|
|
|
var Fieldset = GetProfitFieldSet(Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.BSSOURCE,B.BSSOURCEDETAIL");
|
|
|
foreach (var enumValue in monthlist)
|
|
|
{
|
|
|
if (Fieldset.RMBDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBDR ");
|
|
|
if (Fieldset.RMBCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBCR ");
|
|
|
if (Fieldset.USDDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDDR ");
|
|
|
if (Fieldset.USDCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDCR ");
|
|
|
if (Fieldset.OTDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTDR ");
|
|
|
if (Fieldset.OTCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTCR ");
|
|
|
if (Fieldset.TTLDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLDR ");
|
|
|
if (Fieldset.TTLCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLCR ");
|
|
|
if (Fieldset.RMBPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR-G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBPROFIT ");
|
|
|
if (Fieldset.USDPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR-G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDPROFIT ");
|
|
|
if (Fieldset.OTPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR-G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTPROFIT ");
|
|
|
if (Fieldset.TTLPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR-G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLPROFIT ");
|
|
|
if (Fieldset.TEU)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then B.TEU else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TEU ");
|
|
|
}
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.BSSOURCE,B.BSSOURCEDETAIL ");
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.BSSOURCE,B.BSSOURCEDETAIL");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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.BSSOURCE,B.BSSOURCEDETAIL");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 ContentResult SumListData(int start, int limit, string condition, string sort, string printstr, string startmonth, string endmonth)
|
|
|
{
|
|
|
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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var monthlist = GetMonthList(startmonth, endmonth);
|
|
|
var Fieldset = GetProfitFieldSet(Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT 1 as NO");
|
|
|
foreach (var enumValue in monthlist)
|
|
|
{
|
|
|
if (Fieldset.RMBDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBDR ");
|
|
|
if (Fieldset.RMBCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBCR ");
|
|
|
if (Fieldset.USDDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDDR ");
|
|
|
if (Fieldset.USDCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDCR ");
|
|
|
if (Fieldset.OTDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTDR ");
|
|
|
if (Fieldset.OTCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTCR ");
|
|
|
if (Fieldset.TTLDR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLDR ");
|
|
|
if (Fieldset.TTLCR)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLCR ");
|
|
|
if (Fieldset.RMBPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.RMBDR-G.RMBCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "RMBPROFIT ");
|
|
|
if (Fieldset.USDPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.USDDR-G.USDCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "USDPROFIT ");
|
|
|
if (Fieldset.OTPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.OTDR-G.OTCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "OTPROFIT ");
|
|
|
if (Fieldset.TTLPROFIT)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then G.TTLDR-G.TTLCR else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TTLPROFIT ");
|
|
|
if (Fieldset.TEU)
|
|
|
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7)='" + enumValue.MONTHFIELDNAME + "' then B.TEU else 0 end) as ZL" + enumValue.MONTHNO.ToString() + "TEU ");
|
|
|
}
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
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<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]='modMonthProfitreportRange' 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 月度数
|
|
|
|
|
|
public ContentResult GetMonthsData(string startmonth, string endmonth)
|
|
|
{
|
|
|
|
|
|
var dataList = GetMonthList(startmonth, endmonth, Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
}
|
|
|
|
|
|
static public List<ProfitMonthFieldSet> GetMonthList(string startmonth, string endmonth,string companyid)
|
|
|
{
|
|
|
var startdate = startmonth.Split('-');
|
|
|
var enddate = endmonth.Split('-');
|
|
|
|
|
|
int monthstart = Convert.ToInt16(startdate[0]) * 12 + Convert.ToInt16(startdate[1]);
|
|
|
int monthend = Convert.ToInt16(enddate[0]) * 12 + Convert.ToInt16(enddate[1]);
|
|
|
|
|
|
var betweenmonth = monthend - monthstart + 1;
|
|
|
|
|
|
DateTime dt = DateTime.ParseExact(startmonth, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
|
|
|
|
|
|
var evList = new List<ProfitMonthFieldSet>();
|
|
|
var month = "";
|
|
|
|
|
|
var profitfield=GetProfitFieldSet(companyid);
|
|
|
|
|
|
for (int i = 0; i < betweenmonth; i++)
|
|
|
{
|
|
|
var evData = new ProfitMonthFieldSet();
|
|
|
evData.MONTHNAME = dt.ToString("yyyy年MM月");
|
|
|
evData.MONTHNO = i;
|
|
|
month = dt.Month.ToString();
|
|
|
if (month.Length == 1) month = "0" + month;
|
|
|
evData.MONTHFIELDNAME = dt.Year.ToString() + "/" + month;
|
|
|
evData.RMBDR = profitfield.RMBDR;
|
|
|
evData.RMBCR = profitfield.RMBCR;
|
|
|
evData.USDDR = profitfield.USDDR;
|
|
|
evData.USDCR = profitfield.USDCR;
|
|
|
evData.OTDR = profitfield.OTDR;
|
|
|
evData.OTCR = profitfield.OTCR;
|
|
|
evData.TTLDR = profitfield.TTLDR;
|
|
|
evData.TTLCR = profitfield.TTLCR;
|
|
|
evData.RMBPROFIT = profitfield.RMBPROFIT;
|
|
|
evData.USDPROFIT = profitfield.USDPROFIT;
|
|
|
evData.OTPROFIT = profitfield.OTPROFIT;
|
|
|
evData.TTLPROFIT = profitfield.TTLPROFIT;
|
|
|
evData.TEU = profitfield.TEU;
|
|
|
evList.Add(evData);
|
|
|
dt = dt.AddMonths(1);
|
|
|
}
|
|
|
|
|
|
|
|
|
return evList;
|
|
|
}
|
|
|
|
|
|
static public List<MonthDataSet> GetMonthList(string startmonth, string endmonth)
|
|
|
{
|
|
|
var startdate = startmonth.Split('-');
|
|
|
var enddate = endmonth.Split('-');
|
|
|
|
|
|
int monthstart = Convert.ToInt16(startdate[0]) * 12 + Convert.ToInt16(startdate[1]);
|
|
|
int monthend = Convert.ToInt16(enddate[0]) * 12 + Convert.ToInt16(enddate[1]);
|
|
|
|
|
|
var betweenmonth = monthend - monthstart + 1;
|
|
|
|
|
|
DateTime dt = DateTime.ParseExact(startmonth, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
|
|
|
|
|
|
var evList = new List<MonthDataSet>();
|
|
|
var month = "";
|
|
|
|
|
|
|
|
|
for (int i = 0; i < betweenmonth; i++)
|
|
|
{
|
|
|
var evData = new MonthDataSet();
|
|
|
evData.MONTHNAME = dt.ToString("yyyy年MM月");
|
|
|
evData.MONTHNO = i;
|
|
|
month = dt.Month.ToString();
|
|
|
if (month.Length == 1) month = "0" + month;
|
|
|
evData.MONTHFIELDNAME = dt.Year.ToString() + "/" + month;
|
|
|
|
|
|
evList.Add(evData);
|
|
|
dt = dt.AddMonths(1);
|
|
|
}
|
|
|
|
|
|
|
|
|
return evList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 利润字段设置
|
|
|
|
|
|
public ContentResult GetProfitFieldSet()
|
|
|
{
|
|
|
ProfitFieldSet head = null;
|
|
|
head = GetProfitFieldSet(Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
}
|
|
|
|
|
|
static public ProfitFieldSet GetProfitFieldSet(string companyid)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT GID,RMBDR,RMBCR,USDDR,USDCR,OTDR,OTCR,TTLDR,TTLCR,RMBPROFIT,USDPROFIT,OTPROFIT,TTLPROFIT,TEU from sys_profitfieldset");
|
|
|
strSql.Append(" Where COMPANYID='" + companyid + "'");
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var evList = new List<ProfitFieldSet>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var evData = new ProfitFieldSet();
|
|
|
evData.GID = Convert.ToString(reader["GID"]);
|
|
|
if (reader["RMBDR"] != DBNull.Value)
|
|
|
evData.RMBDR = Convert.ToBoolean(reader["RMBDR"]);
|
|
|
if (reader["RMBCR"] != DBNull.Value)
|
|
|
evData.RMBCR = Convert.ToBoolean(reader["RMBCR"]);
|
|
|
if (reader["USDDR"] != DBNull.Value)
|
|
|
evData.USDDR = Convert.ToBoolean(reader["USDDR"]);
|
|
|
if (reader["USDCR"] != DBNull.Value)
|
|
|
evData.USDCR = Convert.ToBoolean(reader["USDCR"]);
|
|
|
if (reader["OTDR"] != DBNull.Value)
|
|
|
evData.OTDR = Convert.ToBoolean(reader["OTDR"]);
|
|
|
if (reader["OTCR"] != DBNull.Value)
|
|
|
evData.OTCR = Convert.ToBoolean(reader["OTCR"]);
|
|
|
if (reader["TTLDR"] != DBNull.Value)
|
|
|
evData.TTLDR = Convert.ToBoolean(reader["TTLDR"]);
|
|
|
if (reader["TTLCR"] != DBNull.Value)
|
|
|
evData.TTLCR = Convert.ToBoolean(reader["TTLCR"]);
|
|
|
if (reader["RMBPROFIT"] != DBNull.Value)
|
|
|
evData.RMBPROFIT = Convert.ToBoolean(reader["RMBPROFIT"]);
|
|
|
if (reader["USDPROFIT"] != DBNull.Value)
|
|
|
evData.USDPROFIT = Convert.ToBoolean(reader["USDPROFIT"]);
|
|
|
if (reader["OTPROFIT"] != DBNull.Value)
|
|
|
evData.OTPROFIT = Convert.ToBoolean(reader["OTPROFIT"]);
|
|
|
if (reader["TTLPROFIT"] != DBNull.Value)
|
|
|
evData.TTLPROFIT = Convert.ToBoolean(reader["TTLPROFIT"]);
|
|
|
if (reader["TEU"] != DBNull.Value)
|
|
|
evData.TEU = Convert.ToBoolean(reader["TEU"]);
|
|
|
evList.Add(evData);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
if (evList.Count > 0)
|
|
|
return evList[0];
|
|
|
|
|
|
return new ProfitFieldSet();
|
|
|
}
|
|
|
|
|
|
public ContentResult SaveProfitFieldSet(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<ProfitFieldSet>(data);
|
|
|
|
|
|
var isPost = true;
|
|
|
var errorstr = "";
|
|
|
headData.COMPANYID = Convert.ToString(Session["COMPANYID"]);
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (isPost)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
var cmdDelete =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"delete from sys_profitfieldset where COMPANYID=@COMPANYID ");
|
|
|
cmdDelete.Parameters.Clear();
|
|
|
db.AddInParameter(cmdDelete, "@COMPANYID", DbType.String, Convert.ToString(Session["COMPANYID"]));
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into sys_profitfieldset (GID,COMPANYID,RMBDR,RMBCR,USDDR,USDCR,OTDR,OTCR,TTLDR,TTLCR,RMBPROFIT,USDPROFIT,OTPROFIT,TTLPROFIT,TEU)
|
|
|
values (@GID,@COMPANYID ,@RMBDR,@RMBCR,@USDDR,@USDCR,@OTDR,@OTCR,@TTLDR,@TTLCR,@RMBPROFIT,@USDPROFIT,@OTPROFIT,@TTLPROFIT,@TEU) ");
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, headData.GID);
|
|
|
db.AddInParameter(cmdInsert, "@COMPANYID", DbType.String, headData.COMPANYID);
|
|
|
db.AddInParameter(cmdInsert, "@RMBDR", DbType.Boolean, headData.RMBDR);
|
|
|
db.AddInParameter(cmdInsert, "@RMBCR", DbType.Boolean, headData.RMBCR);
|
|
|
db.AddInParameter(cmdInsert, "@USDDR", DbType.Boolean, headData.USDDR);
|
|
|
db.AddInParameter(cmdInsert, "@USDCR", DbType.Boolean, headData.USDCR);
|
|
|
db.AddInParameter(cmdInsert, "@OTDR", DbType.Boolean, headData.OTDR);
|
|
|
db.AddInParameter(cmdInsert, "@OTCR", DbType.Boolean, headData.OTCR);
|
|
|
db.AddInParameter(cmdInsert, "@TTLDR", DbType.Boolean, headData.TTLDR);
|
|
|
db.AddInParameter(cmdInsert, "@TTLCR", DbType.Boolean, headData.TTLCR);
|
|
|
db.AddInParameter(cmdInsert, "@RMBPROFIT", DbType.Boolean, headData.RMBPROFIT);
|
|
|
db.AddInParameter(cmdInsert, "@USDPROFIT", DbType.Boolean, headData.USDPROFIT);
|
|
|
db.AddInParameter(cmdInsert, "@OTPROFIT", DbType.Boolean, headData.OTPROFIT);
|
|
|
db.AddInParameter(cmdInsert, "@TTLPROFIT", DbType.Boolean, headData.TTLPROFIT);
|
|
|
db.AddInParameter(cmdInsert, "@TEU", DbType.Boolean, headData.TEU);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
result.Success = true;
|
|
|
result.Message = "保存成功!";
|
|
|
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|