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.

131 lines
5.3 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.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.Import.Models.ImportTrade;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using System.Web;
using System.Data.Common;
using DSWeb.TruckMng.Comm.Cookie;
using WebSqlHelper;
using HcUtility.Core;
namespace DSWeb.Areas.Import.DAL.ReceiptDoc
{
public partial class ReceiptDocDAL
{
#region 单据信息列表
static public List<ReceiptDocmb> GetDocList ( string strCondition, string sortstr = "")
{ //合同信息/商品信息 ——每合同一行
var strSql = new StringBuilder();
strSql.Append(" SELECT [GID],RECEIPTTYPE,[R_GID],[BSNO],[URL],[Driect_URL] ");
strSql.Append(" ,[MODIFIEDUSER],(select SHOWNAME from [user] where gid=[Receipt_Doc].MODIFIEDUSER) MODIFIEDUSERRef ");
strSql.Append(" ,dbo.trimtime(MODIFIEDTIME)[MODIFIEDTIME]");
strSql.Append(" ,[documentAttachedCode],[documentAttachedNo],ISPUBLIC,REMARK ");//需求编号SR2017081100003
strSql.Append(" FROM [Receipt_Doc] ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
if (sortstr!="")
strSql.Append(" order by "+ sortstr);
else
strSql.Append(" order by MODIFIEDTIME ");
return SetDocList(strSql);
}
static public ReceiptDocmb GetDoc(string strCondition, string sortstr = "")
{ //合同信息/商品信息 ——每合同一行
var strSql = new StringBuilder();
strSql.Append(" SELECT [GID],RECEIPTTYPE,[R_GID],[BSNO],[URL],[Driect_URL] ");
strSql.Append(" ,[MODIFIEDUSER],(select SHOWNAME from [user] where gid=[Receipt_Doc].MODIFIEDUSER) MODIFIEDUSERRef ");
strSql.Append(" ,dbo.trimtime(MODIFIEDTIME)[MODIFIEDTIME]");
strSql.Append(" ,[documentAttachedCode],[documentAttachedNo],ISPUBLIC,REMARK ");//需求编号SR2017081100003
strSql.Append(" FROM [Receipt_Doc] ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
if (sortstr != "")
strSql.Append(" order by " + sortstr);
else
strSql.Append(" order by MODIFIEDTIME DESC ");
var list = SetDocList(strSql);
if (list.Count > 0)
return list[0];
return new ReceiptDocmb();
}
private static List<ReceiptDocmb> SetDocList ( StringBuilder strSql )
{
var headList = new List<ReceiptDocmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ReceiptDocmb data = new ReceiptDocmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.RECEIPTTYPE = Convert.ToString(reader["RECEIPTTYPE"]);
data.R_GID = Convert.ToString(reader["R_GID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.URL = Convert.ToString(reader["URL"]);
data.Driect_URL = Convert.ToString(reader["Driect_URL"]);
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
data.MODIFIEDUSERRef = Convert.ToString(reader["MODIFIEDUSERRef"]);
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
data.DOCUMENTATTACHEDCODE = (reader["DOCUMENTATTACHEDCODE"] == null ? "" : Convert.ToString(reader["DOCUMENTATTACHEDCODE"]));//易航线_随附单证代码//需求编号SR2017081100003
data.DOCUMENTATTACHEDNO = (reader["DOCUMENTATTACHEDNO"] == null ? "" : Convert.ToString(reader["DOCUMENTATTACHEDNO"]));//易航线_随附单证编//需求编号SR2017081100003
if (reader["ISPUBLIC"] != DBNull.Value)
data.ISPUBLIC = Convert.ToBoolean(reader["ISPUBLIC"]);//服务项目9
data.REMARK = Convert.ToString(reader["REMARK"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 公开临时表 的 单据信息列表
static public List<ReceiptDocmb> GetDocPubList ( string strCondition )
{ //合同信息/商品信息 ——每合同一行
var strSql = new StringBuilder();
strSql.Append(" SELECT [GID],RECEIPTTYPE,[R_GID],[BSNO],[URL],[Driect_URL] ");
strSql.Append(" ,'' [MODIFIEDUSER],'' MODIFIEDUSERRef ");
strSql.Append(" ,''[MODIFIEDTIME],0 ISPUBLIC ");
strSql.Append(" FROM [Receipt_Doc_public] ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetDocList(strSql);
}
#endregion
}
}