|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsCompanysAccount;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsCompanysAccountDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsCompanysAccountDAL
|
|
|
|
|
{
|
|
|
|
|
#region 查询
|
|
|
|
|
static public List<MsCompanysAccount> GetDataList(string strCondition, string userid, string usercode, string companyid,string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=sys_bank.MODIFIEDUSER) from sys_bank where 1=1");
|
|
|
|
|
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 CODENAME,MODIFIEDTIME");
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsCompanysAccount GetData(string condition, string companyid)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=sys_bank.MODIFIEDUSER) from sys_bank where 1=1");
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
var list=SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
return list[0];
|
|
|
|
|
return new MsCompanysAccount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsCompanysAccount> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsCompanysAccount>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsCompanysAccount data = new MsCompanysAccount();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
|
|
|
|
|
data.LINKID = (reader["LINKID"] == null ? "" : Convert.ToString(reader["LINKID"]));//公司关联id
|
|
|
|
|
data.CODENAME = (reader["CODENAME"] == null ? "" : Convert.ToString(reader["CODENAME"]));//CODENAME
|
|
|
|
|
data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//CURRENCY
|
|
|
|
|
data.BANKNAME = (reader["BANKNAME"] == null ? "" : Convert.ToString(reader["BANKNAME"]));//BANKNAME
|
|
|
|
|
data.ACCOUNT = (reader["ACCOUNT"] == null ? "" : Convert.ToString(reader["ACCOUNT"]));//ACCOUNT
|
|
|
|
|
data.ACCOUNTNAME = (reader["ACCOUNTNAME"] == null ? "" : Convert.ToString(reader["ACCOUNTNAME"]));//ACCOUNT
|
|
|
|
|
data.SUBJECTCODE = (reader["SUBJECTCODE"] == null ? "" : Convert.ToString(reader["SUBJECTCODE"]));//银行账户
|
|
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//REMARK
|
|
|
|
|
data.FINANCESOFTCODE = (reader["FINANCESOFTCODE"] == null ? "" : Convert.ToString(reader["FINANCESOFTCODE"]));//FINANCESOFTCODE
|
|
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//CREATEUSER
|
|
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid
|
|
|
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间
|
|
|
|
|
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人
|
|
|
|
|
data.CWGLACCID = (reader["CWGLACCID"] == null ? "" : Convert.ToString(reader["CWGLACCID"]));//CWGLACCID
|
|
|
|
|
data.ISSTOP = (reader["ISSTOP"] == null ? "" : Convert.ToString(reader["ISSTOP"]));//CWGLACCID
|
|
|
|
|
if (reader["ISDEF"] != DBNull.Value)
|
|
|
|
|
data.ISDEF = (reader["ISDEF"] == null ? "" : Convert.ToString(reader["ISDEF"]));//CWGLACCID
|
|
|
|
|
data.BANKNAME2 = (reader["BANKNAME2"] == null ? "" : Convert.ToString(reader["BANKNAME2"]));//CWGLACCID
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除
|
|
|
|
|
public static DBResult Delete(MsCompanysAccount headData, string LINKID)
|
|
|
|
|
{
|
|
|
|
|
DBResult result = new DBResult();
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
|
|
|
|
|
string strSql = "SELECT count(*) as inum from [ch_fee_settlement] where ACCOUNTRMB='" + headData.GID.ToString().Trim() + "' or ACCOUNTUSD='" + headData.GID.ToString().Trim() + "'";
|
|
|
|
|
int inum = int.Parse(T_ALL_DA.GetStrSQL("inum", strSql));
|
|
|
|
|
if (inum > 0)
|
|
|
|
|
{
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "账户已在结算时使用,不允许删除!";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from [sys_bank] where GID='" + headData.GID + "'");
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|