|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsCtBankDeploy;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using DSWeb.DataAccess;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsCtBankDeployDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsCtBankDeployDAL
|
|
|
|
|
{
|
|
|
|
|
#region 查询
|
|
|
|
|
static public List<MsCtBankDeploy> GetDataList(string strCondition, string userid, string usercode, string companyid,string sort = null)
|
|
|
|
|
{
|
|
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(userid);
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
//strSql.Append("SELECT *,BANKNAME=(select top 1 BANKNAME from [sys_bank] where LINKID='" + companyid + "' and gid=ct_bank_deploy.BANKGID),MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_deploy.MODIFIEDUSER) from ct_bank_deploy where STARTGID='" + strCtSTARTGID + "'");// and CORPID='" + companyid + "'
|
|
|
|
|
strSql.Append("SELECT *,ACCNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=ct_bank_deploy.ACCGID),MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_deploy.MODIFIEDUSER) from ct_bank_deploy where STARTGID='" + strCtSTARTGID + "'");// and CORPID='" + companyid + "'
|
|
|
|
|
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 CREATETIME");
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsCtBankDeploy GetData(string condition, string companyid, string userid)
|
|
|
|
|
{
|
|
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(userid);
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
//strSql.Append("SELECT *,BANKNAME=(select top 1 BANKNAME from [sys_bank] where LINKID='" + companyid + "' and gid=ct_bank_deploy.BANKGID),MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_deploy.MODIFIEDUSER) from ct_bank_deploy where STARTGID='" + strCtSTARTGID + "'");// and CORPID='" + companyid + "'
|
|
|
|
|
strSql.Append("SELECT *,ACCID=(select top 1 ACCID from [cw_accitems_gl] where gid=ct_bank_deploy.ACCGID),ACCNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=ct_bank_deploy.ACCGID),MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_deploy.MODIFIEDUSER) from ct_bank_deploy where STARTGID='" + strCtSTARTGID + "'");// and CORPID='" + companyid + "'
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
var list=SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
return list[0];
|
|
|
|
|
return new MsCtBankDeploy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsCtBankDeploy> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsCtBankDeploy>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsCtBankDeploy data = new MsCtBankDeploy();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//唯一编码
|
|
|
|
|
//data.BANKGID = (reader["BANKGID"] == null ? "" : Convert.ToString(reader["BANKGID"]));//银行GID
|
|
|
|
|
//data.BANKNAME = (reader["BANKNAME"] == null ? "" : Convert.ToString(reader["BANKNAME"]));//银行
|
|
|
|
|
data.ACCGID = (reader["ACCGID"] == null ? "" : Convert.ToString(reader["ACCGID"]));//银行GID
|
|
|
|
|
data.ACCNAME2 = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]));//银行
|
|
|
|
|
data.FCYNO = (reader["FCYNO"] == null ? "" : Convert.ToString(reader["FCYNO"]));//外币编号RMB
|
|
|
|
|
data.VOUDATE = (reader["VOUDATE"] == null ? "" : Convert.ToString(reader["VOUDATE"]));//结算日期
|
|
|
|
|
data.VOUTIME = (reader["VOUTIME"] == null ? "" : Convert.ToString(reader["VOUTIME"]));//结算时间
|
|
|
|
|
data.STARTROW = (reader["STARTROW"] == null ? "" : Convert.ToString(reader["STARTROW"]));//读取开始行
|
|
|
|
|
data.EXPLAN = (reader["EXPLAN"] == null ? "" : Convert.ToString(reader["EXPLAN"]));//摘要
|
|
|
|
|
data.DR = (reader["DR"] == null ? "" : Convert.ToString(reader["DR"]));//借方
|
|
|
|
|
data.CR = (reader["CR"] == null ? "" : Convert.ToString(reader["CR"]));//贷方
|
|
|
|
|
data.BLC = (reader["BLC"] == null ? "" : Convert.ToString(reader["BLC"]));//贷方
|
|
|
|
|
|
|
|
|
|
data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]));//借贷方向/交易类型
|
|
|
|
|
data.DRGJZ = (reader["DRGJZ"] == null ? "" : Convert.ToString(reader["DRGJZ"]));//借方关键字
|
|
|
|
|
data.CRGJZ = (reader["CRGJZ"] == null ? "" : Convert.ToString(reader["CRGJZ"]));//贷方关键字
|
|
|
|
|
|
|
|
|
|
data.STARTGID = (reader["STARTGID"] == null ? "" : Convert.ToString(reader["STARTGID"]));//账套启用GID
|
|
|
|
|
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//分公司代码
|
|
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人gid
|
|
|
|
|
if (data.CREATETIME != null)
|
|
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid
|
|
|
|
|
if (data.MODIFIEDTIME != null)
|
|
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间
|
|
|
|
|
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除
|
|
|
|
|
public static DBResult Delete(MsCtBankDeploy head, string strUSERID)
|
|
|
|
|
{
|
|
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(strUSERID);
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete ct_bank_deploy where STARTGID='" + strCtSTARTGID + "' and GID='" + head.GID.ToString().Trim() + "'");
|
|
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "删除出现错误,请重试!";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "操作成功";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|