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.
DS7/DSWeb/Areas/MvcShipping/DAL/MsOp_InternalTrade/MsOp_InternalTradeDAL.cs

161 lines
4.9 KiB
C#

2 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsOp_InternalTrade;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Web.Mvc;//ContentResult
using DSWeb.TruckMng.Helper.Repository;//ModelObjectRepository
using DSWeb.MvcShipping.Helper;
using DSWeb.Areas.CommMng.DAL;//使用获取权限子句
using DSWeb.Areas.SysMng.DAL.SysTask;
namespace DSWeb.Areas.MvcShipping.DAL.MsOp_InternalTrade
{
public class MsOp_InternalTradeDAL
{
#region 内贸业务 头表/明细表 查询
static public List<MsOp_INTERNALTRADEmb> GetDataList (int start,int limit, string strCondition,string USERID,out int count, string sort = "" )
{
var strSql = "";
MsOp_INTERNALTRADEmb qo = new MsOp_INTERNALTRADEmb();
strSql = qo.getSQL(start,limit, strCondition,USERID,out count, sort);
return SetData(strSql);
}
public static MsOp_INTERNALTRADEmb GetData(string condition, string USERID)
{
var _count = 0;
var dataList = GetDataList(0,1,condition, USERID, out _count);
var result = new MsOp_INTERNALTRADEmb();
if (dataList.Count > 0)
{
result = dataList[0];
}
else {
result.getDef(USERID);
}
return result;
}
public static string getHeadListStr(string condition)
{
MsOp_INTERNALTRADEmb qo = new MsOp_INTERNALTRADEmb();
var result = qo.getSQL_all(0, 999, condition);
return result;
}
public static string getBodyListStr(string condition)
{
string result = MsOp_INTERNALTRADE_Detailmb.getSQL() ;
if (!string.IsNullOrWhiteSpace(condition)) {
result += condition;
}
return result;
}
private static List<MsOp_INTERNALTRADEmb> SetData(string strSql)
{
var headList = new List<MsOp_INTERNALTRADEmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsOp_INTERNALTRADEmb data = new MsOp_INTERNALTRADEmb();
data.SetExtendValue(reader);
if (data.GetDecimal("TTLINVDR") == 0)
{
data.SetValue("DRINVSTATUS", "未开票");
}
else
{
var _TTLINVDR = data.GetDecimal("TTLINVDR");
var _TTLDR = data.GetDecimal("_TTLDR");
if (_TTLINVDR == _TTLDR)
{
data.SetValue("DRINVSTATUS", "已开票");
}
else
if (_TTLINVDR != _TTLDR)
{
data.SetValue("DRINVSTATUS", "部分开票");
}
}
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public List<MsOp_INTERNALTRADE_Detailmb> GetBodyList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by GOODSNAME,LOTNO ");
}
return SetBodyData(strSql);
}
private static List<MsOp_INTERNALTRADE_Detailmb> SetBodyData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
{
var headList = new List<MsOp_INTERNALTRADE_Detailmb>();
Database db = DatabaseFactory.CreateDatabase();
string sql = getBodyListStr(strSql.ToString());
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsOp_INTERNALTRADE_Detailmb data = new MsOp_INTERNALTRADE_Detailmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
}
}