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.
189 lines
8.2 KiB
C#
189 lines
8.2 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using DSWeb.EntityDA;
|
|
using HcUtility.Comm;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.Areas.Account.Models.Chfee_Bankdata;
|
|
using HcUtility.Core;
|
|
|
|
namespace DSWeb.Areas.Account.DAL.Chfee_bankdata
|
|
{
|
|
public class ChBankdataDAL
|
|
{
|
|
#region 列表
|
|
|
|
static public List<ChBankdata> GetDataList(string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null)
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(" SELECT [GID],[PCNO],[SFNO],[TRANSTYPE],[DRAWEE_BANCK] ,[DRAWEE_ACCOUNT],[DRAWEE_NAME],[PAYEE_BANK],[PAYEE_ACCOUNT]");
|
|
strSql.Append(",[PAYEE_NAME],[TRANSDATE],[CURRENCY],[AMOUNT],[TRANSNO],[IMPORTDATE],[IMPORTER],[ISFIT],[FITCOUNT],[INVNO],[FITDATE]");
|
|
strSql.Append(",[FITTYPE],[PRINTDATE],[ISPRINT],[PRINTER],[SALE],[ATTITIONAL],[REMARK],[SUMMARY],FITUSER,CREATEUSER,CREATETIME");
|
|
|
|
strSql.Append(" FROM ch_fee_bankdata where CORPID='"+orgcode+"' ");
|
|
|
|
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 PCNO DESC,SFNO");
|
|
|
|
}
|
|
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public ChBankdata GetData(string condition, string userid = "", string usercode = "", string orgcode = "")
|
|
{
|
|
var list = GetDataList(condition, userid, usercode, orgcode, "");
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new ChBankdata();
|
|
}
|
|
|
|
private static List<ChBankdata> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<ChBankdata>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ChBankdata data = new ChBankdata();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
if (reader["PCNO"] != DBNull.Value)
|
|
data.PCNO = Convert.ToInt32(reader["PCNO"]);
|
|
if (reader["SFNO"] != DBNull.Value)
|
|
data.SFNO = Convert.ToInt32(reader["SFNO"]);
|
|
|
|
data.TRANSTYPE = Convert.ToString(reader["TRANSTYPE"]);
|
|
data.DRAWEE_BANK = Convert.ToString(reader["DRAWEE_BANK"]);
|
|
data.DRAWEE_ACCOUNT = Convert.ToString(reader["DRAWEE_ACCOUNT"]);
|
|
data.DRAWEE_NAME = Convert.ToString(reader["DRAWEE_NAME"]);
|
|
data.PAYEE_BANK = Convert.ToString(reader["PAYEE_BANK"]);
|
|
data.PAYEE_ACCOUNT = Convert.ToString(reader["PAYEE_ACCOUNT"]);
|
|
data.PAYEE_NAME = Convert.ToString(reader["PAYEE_NAME"]);
|
|
if (reader["TRANSDATE"] != DBNull.Value)
|
|
data.TRANSDATE = Convert.ToDateTime(reader["TRANSDATE"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
if (reader["AMOUNT"] != DBNull.Value)
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
// data.CHEQUENO = Convert.ToString(reader["CHEQUENO"]);
|
|
data.TRANSNO = Convert.ToString(reader["TRANSNO"]);
|
|
if (reader["IMPORTDATE"] != DBNull.Value)
|
|
data.IMPORTDATE = Convert.ToDateTime(reader["IMPORTDATE"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.IMPORTER = Convert.ToString(reader["IMPORTER"]);
|
|
if (reader["ISFIT"] != DBNull.Value)
|
|
data.ISFIT = Convert.ToBoolean(reader["ISFIT"]);
|
|
if (reader["FITCOUNT"] != DBNull.Value)
|
|
data.FITCOUNT = Convert.ToInt32(reader["FITCOUNT"]);
|
|
|
|
data.INVNO = Convert.ToString(reader["INVNO"]);
|
|
if (reader["FITDATE"] != DBNull.Value)
|
|
data.FITDATE = Convert.ToDateTime(reader["FITDATE"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.FITTYPE = Convert.ToString(reader["FITTYPE"]);
|
|
if (reader["PRINTDATE"] != DBNull.Value)
|
|
data.PRINTDATE = Convert.ToDateTime(reader["PRINTDATE"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (reader["ISPRINT"] != DBNull.Value)
|
|
data.ISPRINT = Convert.ToBoolean(reader["ISPRINT"]);
|
|
data.PRINTER = Convert.ToString(reader["PRINTER"]);
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
data.ATTITIONAL = Convert.ToString(reader["ATTITIONAL"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
data.SUMMARY = Convert.ToString(reader["SUMMARY"]);
|
|
data.FITUSER = Convert.ToString(reader["FITUSER"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public static DBResult ImpBankData(DataTable table,string pcno, string userid, string username, string companyid)
|
|
{
|
|
var result = new DBResult();
|
|
var PreCUSTNO = "";
|
|
var BSNO = "";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into ch_fee_bankdata (GID,PCNO,SFNO,TRANSTYPE,DRAWEE_BANK,DRAWEE_ACCOUNT,DRAWEE_NAME,PAYEE_BANK
|
|
,PAYEE_ACCOUNT,PAYEE_NAME,TRANSDATE,CURRENCY,AMOUNT,TRANSNO,IMPORTDATE,IMPORTER,ATTITIONAL,SUMMARY)
|
|
values (@GID,@PCNO,@SFNO,@TRANSTYPE,@DRAWEE_BANK,@DRAWEE_ACCOUNT,@DRAWEE_NAME,@PAYEE_BANK
|
|
,@PAYEE_ACCOUNT,@PAYEE_NAME,@TRANSDATE,@CURRENCY,@AMOUNT,@TRANSNO,@IMPORTDATE,@IMPORTER,@ATTITIONAL,@SUMMARY) ");
|
|
|
|
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
try
|
|
{
|
|
var CUSTOMERNAME = "";
|
|
var TRUCKER = "";
|
|
var TRUCKER2 = "";
|
|
var CARRIER = "";
|
|
int num = 0;
|
|
foreach (DataRow row in table.Rows)
|
|
{
|
|
if (row[1].ToString() != "")
|
|
{
|
|
num = num + 1;
|
|
var CUSTNO = Convert.ToString(row["委托编号"]);
|
|
if (!string.IsNullOrEmpty(CUSTNO))
|
|
{
|
|
PreCUSTNO = CUSTNO;
|
|
num = 0;
|
|
var headData = new ChBankdata();
|
|
headData.GID = System.Guid.NewGuid().ToString();
|
|
headData.PCNO = Convert.ToInt32(pcno);
|
|
headData.SFNO = num;
|
|
headData.TRANSTYPE = "";
|
|
//var modb = new ModelObjectDB();
|
|
//result = modb.Save(headData);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
result.Success = true;
|
|
result.Message = "导入成功";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Success = false;
|
|
result.Message = "导入中出错:" + ex.Message;
|
|
}
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|