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.

184 lines
7.8 KiB
C#

12 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using DSWeb.MvcShipping.DAL.Chfee_AuditDAL;
using DSWeb.Areas.Account.Models.MsOpBill;
using System.Text;
using DSWeb.Areas.Mobile.Models.Approval;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.TruckMng.Helper;
using HcUtility.Comm;
namespace DSWeb.Areas.Mobile.DAL
{
public class ApprovalDAL
{
/// <summary>
/// 获取Content的HTML
/// </summary>
/// <returns></returns>
public static string GetBillStatus (string billno)
{
return "";
}
/// <summary>
/// 获取利润与金额合计
/// </summary>
/// <param name="mblno">主题单号</param>
/// <returns></returns>
public static YSYFAmountModel GetAmountAndLirun ( string mblno)
{
StringBuilder sb = new StringBuilder();
sb.Append("select ");
sb.Append("ISNULL(SUM(cfsrmb.AMOUNT),0) as yingshourmb, ");
sb.Append("ISNULL(SUM(cffrmb.AMOUNT),0) as yingfurmb ,");
sb.Append("ISNULL(SUM(cfsusd.AMOUNT),0) as yingshouusd,");
sb.Append("ISNULL(SUM(cffusd.AMOUNT),0) as yingfuusd ");
sb.Append("from ch_fee cf ");
sb.Append("LEFT JOIN v_op_bs os on cf.BSNO = os.BSNO ");
sb.Append("LEFT JOIN ch_fee cfsrmb on cf.GID = cfsrmb.GID AND cfsrmb.FEETYPE = 1 AND cfsrmb.CURRENCY = 'RMB' ");
sb.Append("LEFT JOIN ch_fee cffrmb on cf.GID = cffrmb.GID AND cffrmb.FEETYPE = 2 AND cffrmb.CURRENCY = 'RMB' ");
sb.Append("LEFT JOIN ch_fee cfsusd on cf.GID = cfsusd.GID AND cfsusd.FEETYPE = 1 AND cfsusd.CURRENCY= 'USD' ");
sb.Append("LEFT JOIN ch_fee cffusd on cf.GID = cffusd.GID AND cffusd.FEETYPE = 2 AND cffusd.CURRENCY= 'USD' ");
sb.Append("WHERE os.MBLNO LIKE '%"+mblno+"%' ");
Database db = DatabaseFactory.CreateDatabase();
YSYFAmountModel ysyf = new YSYFAmountModel();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sb.ToString()))
{
while (reader.Read())
{
ysyf.yingfurmb = reader["yingfurmb"].ToString();
ysyf.yingfuusd = reader["yingfuusd"].ToString();
ysyf.yingshourmb = reader["yingshourmb"].ToString();
ysyf.yingshouusd = reader["yingshouusd"].ToString();
}
}
return ysyf;
}
/// <summary>
/// 应收应付审批 2017年9月14日15:10:01 拷贝自 Chfee_AuditController.cs 的 SelAudit方法
/// </summary>
/// <param name="userid"></param>
/// <param name="showname"></param>
/// <param name="comid"></param>
/// <param name="billData"></param>
/// <returns></returns>
public static bool SelAudit (string userid, string showname, string comid, List<MsOpBill> billData )
{
var AuditAutoLock = MsSysParamSetDAL.GetData("PARAMNAME='AuditAutoLock'");
var workflowstr = "";
var AMENDSELFWORK = MsSysParamSetDAL.GetData("PARAMNAME='AMENDSELFWORKFLOW'");
if (AMENDSELFWORK.PARAMVALUE == "1") workflowstr = "AmendFeefyAudit";
DBResult result = null;
foreach (var enumValue in billData)
{
if (enumValue.OPTYPE == "更改单" && AMENDSELFWORK.PARAMVALUE == "1") workflowstr = "AmendFeefyAudit"; else workflowstr = "";
result = Chfee_AuditDAL.PiliangAudit(enumValue.OPLB, enumValue.BSNO, userid, showname, comid, workflowstr);
if (result.Success == true)
{
if (AuditAutoLock.PARAMVALUE == "1")
{
Chfee_AuditDAL.UpLock(enumValue.BSNO, enumValue.OPLB);
}
}
}
return result.Success;
}
/// <summary>
/// 根据提单号获取更改单利润统计
/// </summary>
/// <param name="mblno"></param>
public static GGDAmountModel GetGGDLirunWithMBLNO ( string mblno,string bsno,bool single)
{
string sql =
@" SELECT
ISNULL(SUM(ggdsrmb.AMOUNT),0) as ggdsrmb,
ISNULL(SUM(ggdsusd.AMOUNT),0) as ggdsusd,
ISNULL(SUM(ggdfrmb.AMOUNT),0) as ggdfrmb,
ISNULL(SUM(ggdfusd.AMOUNT),0) as ggdfusd
from ch_fee cf
LEFT JOIN op_amend am on am.BSNO = cf.BSNO
JOIN v_op_bs si on si.BSNO = am.PARENTID
LEFT JOIN ch_fee ggdsrmb on ggdsrmb.GID = cf.GID AND ggdsrmb.FEETYPE = 1 AND ggdsrmb.CURRENCY= 'RMB' --
LEFT JOIN ch_fee ggdsusd on ggdsusd.GID = cf.GID AND ggdsusd.FEETYPE = 1 AND ggdsusd.CURRENCY= 'USD' --
LEFT JOIN ch_fee ggdfrmb on ggdfrmb.GID = cf.GID AND ggdfrmb.FEETYPE = 2 AND ggdfrmb.CURRENCY= 'RMB' --
LEFT JOIN ch_fee ggdfusd on ggdfusd.GID = cf.GID AND ggdfusd.FEETYPE = 2 AND ggdfusd.CURRENCY= 'USD' --
where si.MBLNO like '%" + mblno + "%' AND am.CREATETIME <= (SELECT CREATETIME FROM op_amend WHERE BSNO = '"+bsno+"')";
string sqlwhere = "";
if (single)
{
sqlwhere = "AND am.BSNO = '"+bsno+"'";
}
else
{
sqlwhere = "AND am.CREATETIME <= (SELECT CREATETIME FROM op_amend WHERE BSNO = '"+bsno+"')";
}
Database db = DatabaseFactory.CreateDatabase();
GGDAmountModel ggd = new GGDAmountModel();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql+sqlwhere))
{
while (reader.Read())
{
ggd.ggdsrmb = reader["ggdsrmb"].ToString();
ggd.ggdsusd = reader["ggdsusd"].ToString();
ggd.ggdfrmb = reader["ggdfrmb"].ToString();
ggd.ggdfusd = reader["ggdfusd"].ToString();
}
}
return ggd;
}
/// <summary>
/// 根据bsno用户id获取机密费用名称数额
/// </summary>
/// <param name="mblno"></param>
/// <param name="userid"></param>
/// <returns></returns>
public static JiMiFeeModel GetJiMiFeeInfo ( string bsno, string userid )
{
//判断用户权限
string sql = @"select count(*) from user_action where userid = '"+userid+"' and ACTIONID = (SELECT GID from action where DESCRIPTION = '机密费用')";
Database db = DatabaseFactory.CreateDatabase();
int rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
if (rst>0)
{
//查询机密费用
string sql2 = @"select FEENAME,SUM(AMOUNT) AS AMOUNT from ch_fee
where bsno = '"+bsno+"' and FEENAME = (select PARAMVALUE from sys_param_set where PARAMDESCRIPTION = '') and FEETYPE = 2 and CURRENCY = 'USD' GROUP BY FEENAME ";
JiMiFeeModel jm = null;
using (IDataReader reader = db.ExecuteReader(CommandType.Text,sql2))
{
while (reader.Read())
{
jm = new JiMiFeeModel();
jm.JimiName = Convert.ToString(reader["FEENAME"]);
jm.JimiUsd = Convert.ToString(reader["AMOUNT"]);
break;
}
}
return jm;
}
else
{
return null;
}
}
}
}