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.
557 lines
19 KiB
C#
557 lines
19 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_jinzhang;
|
|
|
|
|
|
namespace DSWeb.Areas.Account.DAL.Chfee_Jinzhang
|
|
{
|
|
public class ChJinzhangDAL
|
|
{
|
|
#region 支票列表
|
|
|
|
static public List<ChJinzhang> GetDataList(string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null)
|
|
{
|
|
|
|
var rangstr = GetRangDAListStr("", userid, usercode, orgcode);
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(" SELECT [GID],[BLNO],[BILLNO],[STLBILLNO],[CUSTOMERNAME],[JINZHANGCUSTNAME],[JINZHANGMAKETIME]");
|
|
strSql.Append(" ,[MAKETIMEUPPER],[YEAR],[MONTH],[DAY],[YEARUPPER],[MONTHUPPER],[DAYUPPER],[PURPOSE],[PASSWORD]");
|
|
strSql.Append(" ,[CURRENCY],[BLTYPE],[AMOUNT],[AMOUNTUPPER],[BAIYI],[SHIYI],[QIANWAN] ");
|
|
strSql.Append(" ,[BAIWAN],[SHIWAN],[WAN],[QIAN],[BAI],[SHI],[YUAN],[JIAO],[FEN],[UNIT],[DELETEOPERATOR]");
|
|
strSql.Append(",[DELETECAUSE],[DELETETIME],[PRINTTIME],[PRINTUSER],[BANK],COMPANYNAME,[BANKACCOUNT]");
|
|
strSql.Append(",[PAYEEBANK],[PAYEEBANKACCOUNT],[PAYEEADR],[ISAUDIT],[AUDITOPERATOR],[AUDITDATE] ,[CREATEUSER]");
|
|
strSql.Append(",[CREATETIME],[MODIFIEDUSER] ,[MODIFIEDTIME],BILLSTATUS,REMARK,COMPANYID,BANKID");
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97006 and EnumValueID=ch_fee_jinzhang.BILLSTATUS) as BILLSTATUSREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=ch_fee_jinzhang.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=ch_fee_jinzhang.DELETEOPERATOR) as DELOPERATORNAME");
|
|
strSql.Append(",CASE ISPRINT WHEN 1 THEN '是' ELSE '' END as ISPRINT");
|
|
strSql.Append(",CASE ISDELETE WHEN 1 THEN '是' ELSE '' END as ISDELETE");
|
|
|
|
strSql.Append(" FROM ch_fee_jinzhang 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 JINZHANGMAKETIME DESC");
|
|
|
|
}
|
|
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public ChJinzhang 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 ChJinzhang();
|
|
}
|
|
|
|
private static List<ChJinzhang> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<ChJinzhang>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ChJinzhang data = new ChJinzhang();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.BILLNO = Convert.ToString(reader["BILLNO"]);
|
|
data.STLBILLNO = Convert.ToString(reader["STLBILLNO"]);
|
|
data.BLNO = Convert.ToString(reader["BLNO"]);
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
data.JINZHANGCUSTNAME = Convert.ToString(reader["JINZHANGCUSTNAME"]);
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
if (reader["JINZHANGMAKETIME"] != DBNull.Value)
|
|
data.JINZHANGMAKETIME = Convert.ToDateTime(reader["JINZHANGMAKETIME"]).ToString("yyyy-MM-dd");
|
|
// data.CHEQUENO = Convert.ToString(reader["CHEQUENO"]);
|
|
data.MAKETIMEUPPER = Convert.ToString(reader["MAKETIMEUPPER"]);
|
|
data.YEAR = Convert.ToString(reader["YEAR"]);
|
|
data.MONTH = Convert.ToString(reader["MONTH"]);
|
|
data.DAY = Convert.ToString(reader["DAY"]);
|
|
data.YEARUPPER = Convert.ToString(reader["YEARUPPER"]);
|
|
data.MONTHUPPER = Convert.ToString(reader["MONTHUPPER"]);
|
|
data.DAYUPPER = Convert.ToString(reader["DAYUPPER"]);
|
|
data.PURPOSE = Convert.ToString(reader["PURPOSE"]);
|
|
data.PASSWORD = Convert.ToString(reader["PASSWORD"]);
|
|
data.BLTYPE = Convert.ToString(reader["BLTYPE"]);
|
|
if (reader["AMOUNT"] != DBNull.Value)
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
data.AMOUNTUPPER = Convert.ToString(reader["AMOUNTUPPER"]);
|
|
data.BAIYI = Convert.ToString(reader["BAIYI"]);
|
|
data.SHIYI = Convert.ToString(reader["SHIYI"]);
|
|
data.QIANWAN = Convert.ToString(reader["QIANWAN"]);
|
|
data.BAIWAN = Convert.ToString(reader["BAIWAN"]);
|
|
data.SHIWAN = Convert.ToString(reader["SHIWAN"]);
|
|
data.WAN = Convert.ToString(reader["WAN"]);
|
|
data.QIAN = Convert.ToString(reader["QIAN"]);
|
|
data.BAI = Convert.ToString(reader["BAI"]);
|
|
data.SHI = Convert.ToString(reader["SHI"]);
|
|
data.YUAN = Convert.ToString(reader["YUAN"]);
|
|
data.JIAO = Convert.ToString(reader["JIAO"]);
|
|
data.FEN = Convert.ToString(reader["FEN"]);
|
|
if (reader["ISDELETE"] != DBNull.Value)
|
|
data.ISDELETE = Convert.ToString(reader["ISDELETE"]);
|
|
data.DELETEOPERATOR = Convert.ToString(reader["DELETEOPERATOR"]);
|
|
data.DELOPERATORNAME = Convert.ToString(reader["DELOPERATORNAME"]);
|
|
if (reader["ISPRINT"] != DBNull.Value)
|
|
data.ISPRINT = Convert.ToString(reader["ISPRINT"]);
|
|
data.BANK = Convert.ToString(reader["BANK"]);
|
|
data.COMPANYNAME = Convert.ToString(reader["COMPANYNAME"]);
|
|
data.BANKACCOUNT = Convert.ToString(reader["BANKACCOUNT"]);
|
|
data.PAYEEBANK = Convert.ToString(reader["PAYEEBANK"]);
|
|
data.PAYEEBANKACCOUNT = Convert.ToString(reader["PAYEEBANKACCOUNT"]);
|
|
data.PAYEEADR = Convert.ToString(reader["PAYEEADR"]);
|
|
|
|
if (reader["ISAUDIT"] != DBNull.Value)
|
|
data.ISAUDIT = Convert.ToBoolean(reader["ISAUDIT"]);
|
|
|
|
data.AUDITOPERATOR = Convert.ToString(reader["AUDITOPERATOR"]);
|
|
// data.APPLICANTNAME = Convert.ToString(reader["APPLICANTNAME"]);
|
|
if (reader["AUDITDATE"] != DBNull.Value)
|
|
data.AUDITDATE = Convert.ToString(reader["AUDITDATE"]);
|
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["BILLSTATUS"] != DBNull.Value)
|
|
data.BILLSTATUS = Convert.ToInt16(reader["BILLSTATUS"]);
|
|
data.BILLSTATUSREF = Convert.ToString(reader["BILLSTATUSREF"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
|
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
data.BANKID = Convert.ToString(reader["BANKID"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult UpdatePrint(string billno)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"UPDATE ch_fee_cheque set ISPRINT=1 where BILLNO=@BILLNO");
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@BILLNO", DbType.String, billno);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "成功";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult UpdateDelete(string billno,string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"UPDATE ch_fee_cheque set ISDELETE=1,DELETEOPERATOR=@DELETEOPERATOR,DELETETIME=@DELETETIME where BILLNO=@BILLNO");
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@DELETEOPERATOR", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@DELETETIME", DbType.DateTime, DateTime.Now);
|
|
db.AddInParameter(cmdUpdate, "@BILLNO", DbType.String, billno);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "成功";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
#region 提交审核和撤销审核
|
|
|
|
public static DBResult Lock(String bill)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_cheque set BILLSTATUS=1 where BILLNO=@BILLNO");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "锁定成功";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "锁定错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult LockList(String bills)
|
|
{
|
|
var result = new DBResult();
|
|
var billList = bills.Split(',');
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var bill in billList)
|
|
{
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_cheque set BILLSTATUS=1 where BILLNO=@BILLNO");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "锁定成功";
|
|
|
|
}
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "锁定错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult UnLock(String bill)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_cheque set BILLSTATUS=0 where BILLNO=@BILLNO");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "撤销锁定成功";
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "撤销锁定错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult UnLockList(String bills)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var billList = bills.Split(',');
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
foreach (var bill in billList)
|
|
{
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_cheque set BILLSTATUS=0 where BILLNO=@BILLNO");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "撤销锁定成功";
|
|
|
|
}
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "撤销锁定错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public static string Amount2STR(string amount,int strindex,string curr)
|
|
{
|
|
var result = "";
|
|
if (strindex <= amount.Length + 3)
|
|
{
|
|
if (strindex >= amount.Length + 1)
|
|
{
|
|
if (strindex == amount.Length + 1)
|
|
{
|
|
result = "¥";
|
|
if (curr == "USD") result = "D";
|
|
}
|
|
else if (strindex == amount.Length + 2)
|
|
{
|
|
result = "";
|
|
if (curr == "USD") result = "S";
|
|
}
|
|
else if (strindex == amount.Length + 3)
|
|
{
|
|
result = "";
|
|
if (curr == "USD") result = "U";
|
|
}
|
|
}
|
|
else {
|
|
result = amount.Substring(amount.Length - strindex, 1);
|
|
}
|
|
}
|
|
else result = "";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
#region 支票列表权限范围
|
|
|
|
public static string GetRangDAListStr(string tb, string userid, string username, string companyid)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modJinzhang' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (visiblerange == "4")
|
|
{
|
|
str = " (CREATEUSER='" + userid + "')";
|
|
}
|
|
else if (visiblerange == "3")
|
|
{
|
|
str = " (CREATEUSER='" + userid + "')";
|
|
}
|
|
else if (visiblerange == "2")
|
|
{
|
|
var rangeDa = new RangeDA();
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
str = " OPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')";
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " COMPANYID='" + companyid + "' ";
|
|
}
|
|
else if (visiblerange == "0")
|
|
{
|
|
str = " 1=1 ";
|
|
}
|
|
|
|
|
|
return str;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|