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.

1092 lines
63 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.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DSWeb.Models;
using DSWeb.DataAccess;
using System.Collections;
namespace DSWeb.EntityDA
{
public class CwVouitemsDA
{
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(CwVouitemsEntity model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into cw_vouitems(");
strSql.Append("GID,AMTDR,AMTCR,ISFCY,FCYNO,FCYEXRATE,FCYDR,FCYCR,QTYUNIT,QTYDR,QTYCR,ORDNO,EXPLAN,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC,DEPTID,EMPLID,CORPID,PITEMID,ITEMID,ITEMNO,FIELD10,FIELD9,FIELD8,FIELD7,FIELD6,FIELD5,FIELD4,FIELD3,FIELD2,FIELD1,ACCID,ISSYS,FSETTLCODE,FSETTLENO,MODIFIEDUSER,MODIFIEDTIME,PACCID,ACCNAME,PROPERTY,GRADE,DC,CUSTOMERNAME,SALE,BLNO");
strSql.Append(") values (");
strSql.Append("newid(),@AMTDR,@AMTCR,@ISFCY,@FCYNO,@FCYEXRATE,@FCYDR,@FCYCR,@QTYUNIT,@QTYDR,@QTYCR,@ORDNO,@EXPLAN,@ISDEPTACC,@ISEMPLACC,@ISCORPACC,@ISITEMACC,@DEPTID,@EMPLID,@CORPID,@PITEMID,@ITEMID,@ITEMNO,@FIELD10,@FIELD9,@FIELD8,@FIELD7,@FIELD6,@FIELD5,@FIELD4,@FIELD3,@FIELD2,@FIELD1,@ACCID,@ISSYS,@FSETTLCODE,@FSETTLENO,@MODIFIEDUSER,getdate(),@PACCID,@ACCNAME,@PROPERTY,@GRADE,@DC,@CUSTOMERNAME,@SALE,@BLNO");
strSql.Append(") ");
SqlParameter[] parameters = {
//new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@AMTDR", SqlDbType.Decimal,9) ,
new SqlParameter("@AMTCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ISFCY", SqlDbType.Bit,1) ,
new SqlParameter("@FCYNO", SqlDbType.VarChar,8) ,
new SqlParameter("@FCYEXRATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYUNIT", SqlDbType.VarChar,10) ,
new SqlParameter("@QTYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ORDNO", SqlDbType.VarChar,36) ,
new SqlParameter("@EXPLAN", SqlDbType.VarChar,60) ,
new SqlParameter("@ISDEPTACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISEMPLACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISCORPACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISITEMACC", SqlDbType.Bit,1) ,
new SqlParameter("@DEPTID", SqlDbType.VarChar,18) ,
new SqlParameter("@EMPLID", SqlDbType.VarChar,18) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,18) ,
new SqlParameter("@PITEMID", SqlDbType.Int,4) ,
new SqlParameter("@ITEMID", SqlDbType.VarChar,50) ,
new SqlParameter("@ITEMNO", SqlDbType.Int,4) ,
new SqlParameter("@FIELD10", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD9", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD8", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD7", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD6", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD5", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD4", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD3", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD2", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD1", SqlDbType.VarChar,50) ,
new SqlParameter("@ACCID", SqlDbType.VarChar,16) ,
new SqlParameter("@ISSYS", SqlDbType.Bit,1) ,
new SqlParameter("@FSETTLCODE", SqlDbType.VarChar,20) ,
new SqlParameter("@FSETTLENO", SqlDbType.VarChar,20) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
//new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@PACCID", SqlDbType.VarChar,16) ,
new SqlParameter("@ACCNAME", SqlDbType.VarChar,60) ,
new SqlParameter("@PROPERTY", SqlDbType.Int,4) ,
new SqlParameter("@GRADE", SqlDbType.Int,4) ,
new SqlParameter("@DC", SqlDbType.VarChar,1),
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
new SqlParameter("@SALE", SqlDbType.VarChar,10),
new SqlParameter("@@BLNO", SqlDbType.VarChar,30)
};
//parameters[0].Value = model.GID;
parameters[0].Value = model.AMTDR;
parameters[1].Value = model.AMTCR;
parameters[2].Value = model.ISFCY;
parameters[3].Value = model.FCYNO;
parameters[4].Value = model.FCYEXRATE;
parameters[5].Value = model.FCYDR;
parameters[6].Value = model.FCYCR;
parameters[7].Value = model.QTYUNIT;
parameters[8].Value = model.QTYDR;
parameters[9].Value = model.QTYCR;
parameters[10].Value = model.ORDNO;
parameters[11].Value = model.EXPLAN;
parameters[12].Value = model.ISDEPTACC;
parameters[13].Value = model.ISEMPLACC;
parameters[14].Value = model.ISCORPACC;
parameters[15].Value = model.ISITEMACC;
parameters[16].Value = model.DEPTID;
parameters[17].Value = model.EMPLID;
parameters[18].Value = model.CORPID;
parameters[19].Value = model.PITEMID;
parameters[20].Value = model.ITEMID;
parameters[21].Value = model.ITEMNO;
parameters[22].Value = model.FIELD10;
parameters[23].Value = model.FIELD9;
parameters[24].Value = model.FIELD8;
parameters[25].Value = model.FIELD7;
parameters[26].Value = model.FIELD6;
parameters[27].Value = model.FIELD5;
parameters[28].Value = model.FIELD4;
parameters[29].Value = model.FIELD3;
parameters[30].Value = model.FIELD2;
parameters[31].Value = model.FIELD1;
parameters[32].Value = model.ACCID;
parameters[33].Value = model.ISSYS;
parameters[34].Value = model.FSETTLCODE;
parameters[35].Value = model.FSETTLENO;
parameters[36].Value = model.MODIFIEDUSER;
//parameters[37].Value = model.MODIFIEDTIME;
parameters[37].Value = model.PACCID;
parameters[38].Value = model.ACCNAME;
parameters[39].Value = model.PROPERTY;
parameters[40].Value = model.GRADE;
parameters[41].Value = model.DC;
parameters[42].Value = model.CUSTOMERNAME;
parameters[43].Value = model.SALE;
parameters[44].Value = model.BLNO;
//
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
if (existVal > 0)
{
iResult = 1;
//
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('增加信息','增加操作','GID=" + model.GID.ToString() + "','" + model.MODIFIEDUSER.ToString() + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
else
{
iResult = -1;//执行异常
}
}
return iResult;
}
/// <summary>
/// 增加一条数据
/// </summary>
public int AddAll(CwVouitemsEntity model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into cw_vouitems(");
strSql.Append("GID,AMTDR,AMTCR,ISFCY,FCYNO,FCYEXRATE,FCYDR,FCYCR,QTYUNIT,QTYDR,QTYCR,ORDNO,EXPLAN,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC,DEPTID,EMPLID,CORPID,PITEMID,ITEMID,ITEMNO,FIELD10,FIELD9,FIELD8,FIELD7,FIELD6,FIELD5,FIELD4,FIELD3,FIELD2,FIELD1,ACCID,ISSYS,FSETTLCODE,FSETTLENO,MODIFIEDUSER,MODIFIEDTIME,PACCID,ACCNAME,PROPERTY,GRADE,DC,CUSTOMERNAME,SALE,BLNO");
strSql.Append(") values (");
strSql.Append("@GID,@AMTDR,@AMTCR,@ISFCY,@FCYNO,@FCYEXRATE,@FCYDR,@FCYCR,@QTYUNIT,@QTYDR,@QTYCR,@ORDNO,@EXPLAN,@ISDEPTACC,@ISEMPLACC,@ISCORPACC,@ISITEMACC,@DEPTID,@EMPLID,@CORPID,@PITEMID,@ITEMID,@ITEMNO,@FIELD10,@FIELD9,@FIELD8,@FIELD7,@FIELD6,@FIELD5,@FIELD4,@FIELD3,@FIELD2,@FIELD1,@ACCID,@ISSYS,@FSETTLCODE,@FSETTLENO,@MODIFIEDUSER,getdate(),@PACCID,@ACCNAME,@PROPERTY,@GRADE,@DC,@CUSTOMERNAME,@SALE,@BLNO");
strSql.Append(") ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@AMTDR", SqlDbType.Decimal,9) ,
new SqlParameter("@AMTCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ISFCY", SqlDbType.Bit,1) ,
new SqlParameter("@FCYNO", SqlDbType.VarChar,8) ,
new SqlParameter("@FCYEXRATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYUNIT", SqlDbType.VarChar,10) ,
new SqlParameter("@QTYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ORDNO", SqlDbType.VarChar,36) ,
new SqlParameter("@EXPLAN", SqlDbType.VarChar,60) ,
new SqlParameter("@ISDEPTACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISEMPLACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISCORPACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISITEMACC", SqlDbType.Bit,1) ,
new SqlParameter("@DEPTID", SqlDbType.VarChar,18) ,
new SqlParameter("@EMPLID", SqlDbType.VarChar,18) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,18) ,
new SqlParameter("@PITEMID", SqlDbType.Int,4) ,
new SqlParameter("@ITEMID", SqlDbType.VarChar,50) ,
new SqlParameter("@ITEMNO", SqlDbType.Int,4) ,
new SqlParameter("@FIELD10", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD9", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD8", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD7", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD6", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD5", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD4", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD3", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD2", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD1", SqlDbType.VarChar,50) ,
new SqlParameter("@ACCID", SqlDbType.VarChar,16) ,
new SqlParameter("@ISSYS", SqlDbType.Bit,1) ,
new SqlParameter("@FSETTLCODE", SqlDbType.VarChar,20) ,
new SqlParameter("@FSETTLENO", SqlDbType.VarChar,20) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
//new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@PACCID", SqlDbType.VarChar,16) ,
new SqlParameter("@ACCNAME", SqlDbType.VarChar,60) ,
new SqlParameter("@PROPERTY", SqlDbType.Int,4) ,
new SqlParameter("@GRADE", SqlDbType.Int,4) ,
new SqlParameter("@DC", SqlDbType.VarChar,1),
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
new SqlParameter("@SALE", SqlDbType.VarChar,10),
new SqlParameter("@BLNO", SqlDbType.VarChar,30)
};
parameters[0].Value = model.GID;
parameters[1].Value = model.AMTDR;
parameters[2].Value = model.AMTCR;
parameters[3].Value = model.ISFCY;
parameters[4].Value = model.FCYNO;
parameters[5].Value = model.FCYEXRATE;
parameters[6].Value = model.FCYDR;
parameters[7].Value = model.FCYCR;
parameters[8].Value = model.QTYUNIT;
parameters[9].Value = model.QTYDR;
parameters[10].Value = model.QTYCR;
parameters[11].Value = model.ORDNO;
parameters[12].Value = model.EXPLAN;
parameters[13].Value = model.ISDEPTACC;
parameters[14].Value = model.ISEMPLACC;
parameters[15].Value = model.ISCORPACC;
parameters[16].Value = model.ISITEMACC;
parameters[17].Value = model.DEPTID;
parameters[18].Value = model.EMPLID;
parameters[19].Value = model.CORPID;
parameters[20].Value = model.PITEMID;
parameters[21].Value = model.ITEMID;
parameters[22].Value = model.ITEMNO;
parameters[23].Value = model.FIELD10;
parameters[24].Value = model.FIELD9;
parameters[25].Value = model.FIELD8;
parameters[26].Value = model.FIELD7;
parameters[27].Value = model.FIELD6;
parameters[28].Value = model.FIELD5;
parameters[29].Value = model.FIELD4;
parameters[30].Value = model.FIELD3;
parameters[31].Value = model.FIELD2;
parameters[32].Value = model.FIELD1;
parameters[33].Value = model.ACCID;
parameters[34].Value = model.ISSYS;
parameters[35].Value = model.FSETTLCODE;
parameters[36].Value = model.FSETTLENO;
parameters[37].Value = model.MODIFIEDUSER;
//parameters[38 ] .Value = model.MODIFIEDTIME;
parameters[38].Value = model.PACCID;
parameters[39].Value = model.ACCNAME;
parameters[40].Value = model.PROPERTY;
parameters[41].Value = model.GRADE;
parameters[42].Value = model.DC;
parameters[43].Value = model.CUSTOMERNAME;
parameters[44].Value = model.SALE;
parameters[45].Value = model.BLNO;
//
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
if (existVal > 0)
{
iResult = 1;
//
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('增加信息','增加操作','GID=" + model.GID.ToString() + "','" + model.MODIFIEDUSER.ToString() + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
else
{
iResult = -1;//执行异常
}
}
return iResult;
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(CwVouitemsEntity model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update cw_vouitems set ");
strSql.Append(" GID = @GID , ");
strSql.Append(" AMTDR = @AMTDR , ");
strSql.Append(" AMTCR = @AMTCR , ");
strSql.Append(" ISFCY = @ISFCY , ");
strSql.Append(" FCYNO = @FCYNO , ");
strSql.Append(" FCYEXRATE = @FCYEXRATE , ");
strSql.Append(" FCYDR = @FCYDR , ");
strSql.Append(" FCYCR = @FCYCR , ");
strSql.Append(" QTYUNIT = @QTYUNIT , ");
strSql.Append(" QTYDR = @QTYDR , ");
strSql.Append(" QTYCR = @QTYCR , ");
strSql.Append(" ORDNO = @ORDNO , ");
strSql.Append(" EXPLAN = @EXPLAN , ");
strSql.Append(" ISDEPTACC = @ISDEPTACC , ");
strSql.Append(" ISEMPLACC = @ISEMPLACC , ");
strSql.Append(" ISCORPACC = @ISCORPACC , ");
strSql.Append(" ISITEMACC = @ISITEMACC , ");
strSql.Append(" DEPTID = @DEPTID , ");
strSql.Append(" EMPLID = @EMPLID , ");
strSql.Append(" CORPID = @CORPID , ");
strSql.Append(" PITEMID = @PITEMID , ");
strSql.Append(" ITEMID = @ITEMID , ");
strSql.Append(" ITEMNO = @ITEMNO , ");
strSql.Append(" FIELD10 = @FIELD10 , ");
strSql.Append(" FIELD9 = @FIELD9 , ");
strSql.Append(" FIELD8 = @FIELD8 , ");
strSql.Append(" FIELD7 = @FIELD7 , ");
strSql.Append(" FIELD6 = @FIELD6 , ");
strSql.Append(" FIELD5 = @FIELD5 , ");
strSql.Append(" FIELD4 = @FIELD4 , ");
strSql.Append(" FIELD3 = @FIELD3 , ");
strSql.Append(" FIELD2 = @FIELD2 , ");
strSql.Append(" FIELD1 = @FIELD1 , ");
strSql.Append(" ACCID = @ACCID , ");
//strSql.Append(" ISSYS = @ISSYS , ");
strSql.Append(" FSETTLCODE = @FSETTLCODE , ");
strSql.Append(" FSETTLENO = @FSETTLENO , ");
strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER , ");
strSql.Append(" MODIFIEDTIME = getdate() , ");
strSql.Append(" PACCID = @PACCID , ");
strSql.Append(" ACCNAME = @ACCNAME , ");
strSql.Append(" PROPERTY = @PROPERTY , ");
strSql.Append(" GRADE = @GRADE , ");
strSql.Append(" DC = @DC , ");
strSql.Append(" CUSTOMERNAME = @CUSTOMERNAME , ");
strSql.Append(" SALE = @SALE , ");
strSql.Append(" BLNO = @BLNO ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@AMTDR", SqlDbType.Decimal,9) ,
new SqlParameter("@AMTCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ISFCY", SqlDbType.Bit,1) ,
new SqlParameter("@FCYNO", SqlDbType.VarChar,8) ,
new SqlParameter("@FCYEXRATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYUNIT", SqlDbType.VarChar,10) ,
new SqlParameter("@QTYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ORDNO", SqlDbType.VarChar,36) ,
new SqlParameter("@EXPLAN", SqlDbType.VarChar,60) ,
new SqlParameter("@ISDEPTACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISEMPLACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISCORPACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISITEMACC", SqlDbType.Bit,1) ,
new SqlParameter("@DEPTID", SqlDbType.VarChar,18) ,
new SqlParameter("@EMPLID", SqlDbType.VarChar,18) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,18) ,
new SqlParameter("@PITEMID", SqlDbType.Int,4) ,
new SqlParameter("@ITEMID", SqlDbType.VarChar,50) ,
new SqlParameter("@ITEMNO", SqlDbType.Int,4) ,
new SqlParameter("@FIELD10", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD9", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD8", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD7", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD6", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD5", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD4", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD3", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD2", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD1", SqlDbType.VarChar,50) ,
new SqlParameter("@ACCID", SqlDbType.VarChar,16) ,
//new SqlParameter("@ISSYS", SqlDbType.Bit,1) ,
new SqlParameter("@FSETTLCODE", SqlDbType.VarChar,20) ,
new SqlParameter("@FSETTLENO", SqlDbType.VarChar,20) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
//new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@PACCID", SqlDbType.VarChar,16) ,
new SqlParameter("@ACCNAME", SqlDbType.VarChar,60) ,
new SqlParameter("@PROPERTY", SqlDbType.Int,4) ,
new SqlParameter("@GRADE", SqlDbType.Int,4) ,
new SqlParameter("@DC", SqlDbType.VarChar,1),
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
new SqlParameter("@SALE", SqlDbType.VarChar,10),
new SqlParameter("@BLNO", SqlDbType.VarChar,30)
};
parameters[0].Value = model.GID;
parameters[1].Value = model.AMTDR;
parameters[2].Value = model.AMTCR;
parameters[3].Value = model.ISFCY;
parameters[4].Value = model.FCYNO;
parameters[5].Value = model.FCYEXRATE;
parameters[6].Value = model.FCYDR;
parameters[7].Value = model.FCYCR;
parameters[8].Value = model.QTYUNIT;
parameters[9].Value = model.QTYDR;
parameters[10].Value = model.QTYCR;
parameters[11].Value = model.ORDNO;
parameters[12].Value = model.EXPLAN;
parameters[13].Value = model.ISDEPTACC;
parameters[14].Value = model.ISEMPLACC;
parameters[15].Value = model.ISCORPACC;
parameters[16].Value = model.ISITEMACC;
parameters[17].Value = model.DEPTID;
parameters[18].Value = model.EMPLID;
parameters[19].Value = model.CORPID;
parameters[20].Value = model.PITEMID;
parameters[21].Value = model.ITEMID;
parameters[22].Value = model.ITEMNO;
parameters[23].Value = model.FIELD10;
parameters[24].Value = model.FIELD9;
parameters[25].Value = model.FIELD8;
parameters[26].Value = model.FIELD7;
parameters[27].Value = model.FIELD6;
parameters[28].Value = model.FIELD5;
parameters[29].Value = model.FIELD4;
parameters[30].Value = model.FIELD3;
parameters[31].Value = model.FIELD2;
parameters[32].Value = model.FIELD1;
parameters[33].Value = model.ACCID;
//parameters[34].Value = model.ISSYS;
parameters[34].Value = model.FSETTLCODE;
parameters[35].Value = model.FSETTLENO;
parameters[36].Value = model.MODIFIEDUSER;
//parameters[38].Value = model.MODIFIEDTIME;
parameters[37].Value = model.PACCID;
parameters[38].Value = model.ACCNAME;
parameters[39].Value = model.PROPERTY;
parameters[40].Value = model.GRADE;
parameters[41].Value = model.DC;
parameters[42].Value = model.CUSTOMERNAME;
parameters[43].Value = model.SALE;
parameters[44].Value = model.BLNO;
//
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
if (existVal > 0)
{
iResult = 1;
//
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('更新信息表','更新操作','GID=" + model.GID.ToString() + "','" + model.MODIFIEDUSER.ToString() + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
else
{
iResult = -1;//执行异常
}
}
return iResult;
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from cw_vouitems ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
//
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString(), parameters);
iResult = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
iResult = -1;//有异常,删除失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public CwVouitemsEntity GetModel(string GID)
{
//初始化返回变量
CwVouitemsEntity model = null;
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID, ORDNO,ITEMNO,ACCID,PACCID,ACCNAME,PROPERTY,GRADE,DC,AMTDR,AMTCR,ISFCY,FCYNO,FCYEXRATE,FCYDR,FCYCR,QTYUNIT,QTYDR,QTYCR,EXPLAN,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC,DEPTID,EMPLID,CORPID,PITEMID,ITEMID,FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,FIELD6,FIELD7,FIELD8,FIELD9,FIELD10,ISSYS,FSETTLCODE,FSETTLENO,MODIFIEDUSER,MODIFIEDTIME,CUSTOMERNAME,SALE,BLNO from cw_vouitems ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
//
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString(), parameters))
{
try
{
model = new CwVouitemsEntity();
//读取字段值
while (sqlRead.Read())
{
if (!sqlRead.IsDBNull(0)) { model.GID = sqlRead.GetString(0); } // 唯一编码 newid()
if (!sqlRead.IsDBNull(1)) { model.ORDNO = sqlRead.GetString(1); } // 关联cw_vouchers
if (!sqlRead.IsDBNull(2)) { model.ITEMNO = sqlRead.GetInt32(2); } // 行号
if (!sqlRead.IsDBNull(3)) { model.ACCID = sqlRead.GetString(3); } // 科目代码
if (!sqlRead.IsDBNull(4)) { model.PACCID = sqlRead.GetString(4); } // 父级科目代码
if (!sqlRead.IsDBNull(5)) { model.ACCNAME = sqlRead.GetString(5); } // 科目名称
if (!sqlRead.IsDBNull(6)) { model.PROPERTY = sqlRead.GetInt32(6); } // 科目属性
if (!sqlRead.IsDBNull(7)) { model.GRADE = sqlRead.GetInt32(7); } // 科目级别
if (!sqlRead.IsDBNull(8)) { model.DC = sqlRead.GetString(8); } // 借贷方向
if (!sqlRead.IsDBNull(9)) { model.AMTDR = sqlRead.GetDecimal(9); } // 本位币借方金额(互斥)
if (!sqlRead.IsDBNull(10)) { model.AMTCR = sqlRead.GetDecimal(10); } // 本位币贷方金额(互斥)
if (!sqlRead.IsDBNull(11)) { model.ISFCY = sqlRead.GetBoolean(11); } // 是否外币
if (!sqlRead.IsDBNull(12)) { model.FCYNO = sqlRead.GetString(12); } // 外币编号usd
if (!sqlRead.IsDBNull(13)) { model.FCYEXRATE = sqlRead.GetDecimal(13); } // 汇率
if (!sqlRead.IsDBNull(14)) { model.FCYDR = sqlRead.GetDecimal(14); } // 外币借方金额
if (!sqlRead.IsDBNull(15)) { model.FCYCR = sqlRead.GetDecimal(15); } // 外币贷方金额
if (!sqlRead.IsDBNull(16)) { model.QTYUNIT = sqlRead.GetString(16); } // 数量包装单位
if (!sqlRead.IsDBNull(17)) { model.QTYDR = sqlRead.GetDecimal(17); } // 借方数量
if (!sqlRead.IsDBNull(18)) { model.QTYCR = sqlRead.GetDecimal(18); } // 贷方数量
if (!sqlRead.IsDBNull(19)) { model.EXPLAN = sqlRead.GetString(19); } // 摘要,规则生成
if (!sqlRead.IsDBNull(20)) { model.ISDEPTACC = sqlRead.GetBoolean(20); } // 核算部门,按规则设置生成
if (!sqlRead.IsDBNull(21)) { model.ISEMPLACC = sqlRead.GetBoolean(21); } // 核算人员,按规则设置生成
if (!sqlRead.IsDBNull(22)) { model.ISCORPACC = sqlRead.GetBoolean(22); } // 核算客户,按规则设置生成
if (!sqlRead.IsDBNull(23)) { model.ISITEMACC = sqlRead.GetBoolean(23); } // 核算项目,按规则设置生成
if (!sqlRead.IsDBNull(24)) { model.DEPTID = sqlRead.GetString(24); } // 部门(系统)
if (!sqlRead.IsDBNull(25)) { model.EMPLID = sqlRead.GetString(25); } // 人员(系统)
if (!sqlRead.IsDBNull(26)) { model.CORPID = sqlRead.GetString(26); } // 客户(系统)
if (!sqlRead.IsDBNull(27)) { model.PITEMID = sqlRead.GetInt32(27); } // 父级项目编号
if (!sqlRead.IsDBNull(28)) { model.ITEMID = sqlRead.GetString(28); } // 项目编号
if (!sqlRead.IsDBNull(29)) { model.FIELD1 = sqlRead.GetString(29); } // 预留字段1
if (!sqlRead.IsDBNull(30)) { model.FIELD2 = sqlRead.GetString(30); } // 预留字段2
if (!sqlRead.IsDBNull(31)) { model.FIELD3 = sqlRead.GetString(31); } // 预留字段3
if (!sqlRead.IsDBNull(32)) { model.FIELD4 = sqlRead.GetString(32); } // 预留字段4
if (!sqlRead.IsDBNull(33)) { model.FIELD5 = sqlRead.GetString(33); } // 预留字段5
if (!sqlRead.IsDBNull(34)) { model.FIELD6 = sqlRead.GetString(34); } // 预留字段6
if (!sqlRead.IsDBNull(35)) { model.FIELD7 = sqlRead.GetString(35); } // 预留字段7
if (!sqlRead.IsDBNull(36)) { model.FIELD8 = sqlRead.GetString(36); } // 预留字段8
if (!sqlRead.IsDBNull(37)) { model.FIELD9 = sqlRead.GetString(37); } // 预留字段9
if (!sqlRead.IsDBNull(38)) { model.FIELD10 = sqlRead.GetString(38); } // 预留字段10
if (!sqlRead.IsDBNull(39)) { model.ISSYS = sqlRead.GetBoolean(39); } // 是否手动录入
if (!sqlRead.IsDBNull(40)) { model.FSETTLCODE = sqlRead.GetString(40); } // 结算方式
if (!sqlRead.IsDBNull(41)) { model.FSETTLENO = sqlRead.GetString(41); } // 财务辅助编号
if (!sqlRead.IsDBNull(42)) { model.MODIFIEDUSER = sqlRead.GetString(42); } // 最后一次更新操作人
if (!sqlRead.IsDBNull(43)) { model.MODIFIEDTIME = sqlRead.GetDateTime(43); } // 最后一次更新操作时间
if (!sqlRead.IsDBNull(44)) { model.CUSTOMERNAME = sqlRead.GetString(44); } // 最后一次更新操作人
if (!sqlRead.IsDBNull(45)) { model.SALE = sqlRead.GetString(45); } //
if (!sqlRead.IsDBNull(46)) { model.BLNO = sqlRead.GetString(46); } //
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return model;
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * FROM cw_vouitems ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
//
DataSet DS = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, strSql.ToString());
try
{
if (DS.Tables[0].Rows.Count <= 0)
{
DS = null;
}
}
catch
{
DS = null;
}
return DS;
}
/// <summary>
/// 返回 某字段
/// </summary>
/// <returns></returns>
public string GetStrSQL(string strfield, string strSQL)
{
string alt = "";
DataSet DS = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, strSQL);
if (DS != null)
{
if (DS.Tables[0].Rows.Count > 0)
{
alt = DS.Tables[0].Rows[0]["" + strfield + ""].ToString();
}
}
return alt;
}
/// <summary>
/// 根据SQL语句查询数据集
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetExcuteSql(string strSql)
{
DataSet userSet = new DataSet();
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return userSet;
}
/// <summary>
/// 删除明细表数据,用事务
/// </summary>
/// <param name="strGids">多个gid组成的字符串例如 111,222,333</param>
/// <returns></returns>
public int DeleteAll(string strGids)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from cw_vouitems where GID in (" + strGids + ") ");
iResult = -2;//删除明细表
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
/// <summary>
/// 金蝶迷你凭证导出
/// </summary>
/// <param name="strGids">多个gid组成的字符串例如 111,222,333</param>
/// <returns></returns>
public int setExcelReport1(string strGids, string sPath, string sName)
{
int iResult = 0;
try
{
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO"
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
+ "select "
+ " VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
//+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,''"//财务说不需要提单号字段的内容导入金蝶中
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO"
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
+ ",null,null,null,null "
+ " from VW_cw_vouchers_vouitems where ORDNO in('" + strGids + "') order by ORDNO,ITEMNO";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
iResult = 1;
sSql = " update cw_vouchers set ISEXPORT=1 where ORDNO in('" + strGids + "')";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
}
else
{
iResult = -1;
}
}
else
{
iResult = -1;
}
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
return iResult;
}
/// <summary>
/// 金蝶标准凭证导出
/// </summary>
/// <param name="strGids">多个gid组成的字符串例如 111,222,333</param>
/// <returns></returns>
public int setExcelReport2(string strGids, string sPath, string sName)
{
int iResult = 0;
try
{
//string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
string sSql = "delete from OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
//sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
sSql = "insert into OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO"
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
+ "select "
+ " VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO"
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
+ ",null,null,null,null "
+ " from VW_cw_vouchers_vouitems where ORDNO in('" + strGids + "') order by ORDNO,ITEMNO";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
iResult = 1;
sSql = " update cw_vouchers set ISEXPORT=1 where ORDNO in('" + strGids + "')";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
}
else
{
iResult = -1;
}
}
else
{
iResult = -1;
}
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
return iResult;
}
/// <summary>
/// 金蝶K3凭证导出
/// </summary>
/// <param name="strGids">多个gid组成的字符串例如 111,222,333</param>
/// <returns></returns>
public int setExcelReport3(string strGids, string sPath, string sName)
{
int iResult = 0;
try
{
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
+ " FDATE,FTRANSDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1"
+ ",FOBJNAME1,FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4"
+ ",FCLSNAME5,FOBJID5,FOBJNAME5,FCLSNAME6,FOBJID6,FOBJNAME6,FCLSNAME7,FOBJID7,FOBJNAME7,FCLSNAME8"
+ ",FOBJID8,FOBJNAME8,FOBJNAME9,FOBJID9,FCLSNAME9,FCLSNAME10,FOBJID10,FOBJNAME10,FCLSNAME11,FOBJID11"
+ ",FOBJNAME11,FCLSNAME12,FOBJID12,FOBJNAME12,FCLSNAME13,FOBJID13,FOBJNAME13,FCLSNAME14,FOBJID14,FOBJNAME14"
+ ",FCLSNAME15,FOBJID15,FOBJNAME15,FTRANSID,FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE"
+ ",FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO,FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT"
+ ",FPOSTED,FMODULE,FDELETED,FSERIALNO,FUNITNAME,FREFERENCE,FCASHFLOW) "
+ "select "
+ " VouDate,VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID"
+ ",CorpID,null,CorpID,CorpID,null,null,null,null,null,null"
+ ",null,null,null,null,null,null,null,null,null,null"
+ ",null,null,null,null,null,null,null,null,null,null"
+ ",null,null,null,null,null,null,null,null,null,null"
+ ",null,null,null,BLNO,FCYNO,FCYEXRATE,DC,AMTDR+AMTCR,null,0"
+ ",AMTDR,AMTCR,FSETTLCODE,FSETTLENO,PREPARED,null,null,null,null,ATTACHS"
+ ",'False',null,'False',VOUNO,null,null,null "
+ " from VW_cw_vouchers_vouitems where ORDNO in('" + strGids + "') order by ORDNO,ITEMNO";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
iResult = 1;
}
else
{
iResult = -1;
}
}
else
{
iResult = -1;
}
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
return iResult;
}
/// <summary>
/// 金蝶专业版凭证导出
/// </summary>
/// <param name="strGids">多个gid组成的字符串例如 111,222,333</param>
/// <returns></returns>
public int setExcelReport8(string strGids, string sPath, string sName)
{
int iResult = 0;
try
{
//string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
string sSql = "delete from OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
//sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
sSql = "insert into OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
+ " FDATE,FTRANSDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID"
+ ",FCLSNAME1,FOBJID1,FOBJNAME1,FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4"
+ ",FCLSNAME5,FOBJID5,FOBJNAME5,FCLSNAME6,FOBJID6,FOBJNAME6,FCLSNAME7,FOBJID7,FOBJNAME7,FCLSNAME8,FOBJID8,FOBJNAME8"
+ ",FCLSNAME9,FOBJID9,FOBJNAME9,FCLSNAME10,FOBJID10,FOBJNAME10,FCLSNAME11,FOBJID11,FOBJNAME11,FCLSNAME12,FOBJID12,FOBJNAME12"
+ ",FCLSNAME13,FOBJID13,FOBJNAME13,FCLSNAME14,FOBJID14,FOBJNAME14,FCLSNAME15,FOBJID15,FOBJNAME15"
+ ",FTRANSID,FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO"
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
+ ",FUNITNAME,FREFERENCE,FCASHFLOW,FHANDLER) "
+ "select "
+ " VouDate,VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID"
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,null,null,null"
+ ",null,null,null,null,null,null,null,null,null,null,null,null"
+ ",null,null,null,null,null,null,null,null,null,null,null,null"
+ ",null,null,null,null,null,null,null,null,null"
+ ",BLNO,FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO"
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
+ ",null,null,null,null "
+ " from VW_cw_vouchers_vouitems where ORDNO in('" + strGids + "') order by ORDNO,ITEMNO";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
if (bl)
{
iResult = 1;
sSql = " update cw_vouchers set ISEXPORT=1 where ORDNO in('" + strGids + "')";
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
}
else
{
iResult = -1;
}
}
else
{
iResult = -1;
}
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
return iResult;
}
//
#region 更新账户列表信息
/// <summary>
/// 更新账户列表信息
/// </summary>
/// <param name="sqlList">更新SQL语句组,将所有要执行的更新语句写入ArrayList,每个索引对应一条SQL语句,执行时需要遍历操作</param>
/// <returns>返回状态值 为1表示更新完成;为-1更新出现异常但未正确回滚事务;为-2更新异常,事务已经成功回滚;默认状态为0</returns>
public int UpdateFromGrid(List<CwVouitemsEntity> CwVouitemsEntities)
{
int result = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (CwVouitemsEntity model in CwVouitemsEntities)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update cw_vouitems set ");
//strSql.Append(" GID = @GID , ");
strSql.Append(" AMTDR = @AMTDR , ");
strSql.Append(" AMTCR = @AMTCR , ");
strSql.Append(" ISFCY = @ISFCY , ");
strSql.Append(" FCYNO = @FCYNO , ");
strSql.Append(" FCYEXRATE = @FCYEXRATE , ");
strSql.Append(" FCYDR = @FCYDR , ");
strSql.Append(" FCYCR = @FCYCR , ");
strSql.Append(" QTYUNIT = @QTYUNIT , ");
strSql.Append(" QTYDR = @QTYDR , ");
strSql.Append(" QTYCR = @QTYCR , ");
strSql.Append(" ORDNO = @ORDNO , ");
strSql.Append(" EXPLAN = @EXPLAN , ");
strSql.Append(" ISDEPTACC = @ISDEPTACC , ");
strSql.Append(" ISEMPLACC = @ISEMPLACC , ");
strSql.Append(" ISCORPACC = @ISCORPACC , ");
strSql.Append(" ISITEMACC = @ISITEMACC , ");
strSql.Append(" DEPTID = @DEPTID , ");
strSql.Append(" EMPLID = @EMPLID , ");
strSql.Append(" CORPID = @CORPID , ");
strSql.Append(" PITEMID = @PITEMID , ");
strSql.Append(" ITEMID = @ITEMID , ");
strSql.Append(" ITEMNO = @ITEMNO , ");
strSql.Append(" FIELD10 = @FIELD10 , ");
strSql.Append(" FIELD9 = @FIELD9 , ");
strSql.Append(" FIELD8 = @FIELD8 , ");
strSql.Append(" FIELD7 = @FIELD7 , ");
strSql.Append(" FIELD6 = @FIELD6 , ");
strSql.Append(" FIELD5 = @FIELD5 , ");
strSql.Append(" FIELD4 = @FIELD4 , ");
strSql.Append(" FIELD3 = @FIELD3 , ");
strSql.Append(" FIELD2 = @FIELD2 , ");
strSql.Append(" FIELD1 = @FIELD1 , ");
strSql.Append(" ACCID = @ACCID , ");
//strSql.Append(" ISSYS = @ISSYS , ");
strSql.Append(" FSETTLCODE = @FSETTLCODE , ");
strSql.Append(" FSETTLENO = @FSETTLENO , ");
strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER , ");
strSql.Append(" MODIFIEDTIME = getdate() , ");
strSql.Append(" PACCID = @PACCID , ");
strSql.Append(" ACCNAME = @ACCNAME , ");
strSql.Append(" PROPERTY = @PROPERTY , ");
strSql.Append(" GRADE = @GRADE , ");
strSql.Append(" DC = @DC , ");
strSql.Append(" CUSTOMERNAME = @CUSTOMERNAME , ");
strSql.Append(" SALE = @SALE , ");
strSql.Append(" BLNO = @BLNO ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@AMTDR", SqlDbType.Decimal,9) ,
new SqlParameter("@AMTCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ISFCY", SqlDbType.Bit,1) ,
new SqlParameter("@FCYNO", SqlDbType.VarChar,8) ,
new SqlParameter("@FCYEXRATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@FCYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYUNIT", SqlDbType.VarChar,10) ,
new SqlParameter("@QTYDR", SqlDbType.Decimal,9) ,
new SqlParameter("@QTYCR", SqlDbType.Decimal,9) ,
new SqlParameter("@ORDNO", SqlDbType.VarChar,36) ,
new SqlParameter("@EXPLAN", SqlDbType.VarChar,60) ,
new SqlParameter("@ISDEPTACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISEMPLACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISCORPACC", SqlDbType.Bit,1) ,
new SqlParameter("@ISITEMACC", SqlDbType.Bit,1) ,
new SqlParameter("@DEPTID", SqlDbType.VarChar,18) ,
new SqlParameter("@EMPLID", SqlDbType.VarChar,18) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,18) ,
new SqlParameter("@PITEMID", SqlDbType.Int,4) ,
new SqlParameter("@ITEMID", SqlDbType.VarChar,50) ,
new SqlParameter("@ITEMNO", SqlDbType.Int,4) ,
new SqlParameter("@FIELD10", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD9", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD8", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD7", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD6", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD5", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD4", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD3", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD2", SqlDbType.VarChar,50) ,
new SqlParameter("@FIELD1", SqlDbType.VarChar,50) ,
new SqlParameter("@ACCID", SqlDbType.VarChar,16) ,
//new SqlParameter("@ISSYS", SqlDbType.Bit,1) ,
new SqlParameter("@FSETTLCODE", SqlDbType.VarChar,20) ,
new SqlParameter("@FSETTLENO", SqlDbType.VarChar,20) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
//new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@PACCID", SqlDbType.VarChar,16) ,
new SqlParameter("@ACCNAME", SqlDbType.VarChar,60) ,
new SqlParameter("@PROPERTY", SqlDbType.Int,4) ,
new SqlParameter("@GRADE", SqlDbType.Int,4) ,
new SqlParameter("@DC", SqlDbType.VarChar,1),
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
new SqlParameter("@SALE", SqlDbType.VarChar,10),
new SqlParameter("@BLNO", SqlDbType.VarChar,30)
};
parameters[0].Value = model.GID;
parameters[1].Value = model.AMTDR;
parameters[2].Value = model.AMTCR;
parameters[3].Value = model.ISFCY;
parameters[4].Value = model.FCYNO;
parameters[5].Value = model.FCYEXRATE;
parameters[6].Value = model.FCYDR;
parameters[7].Value = model.FCYCR;
parameters[8].Value = model.QTYUNIT;
parameters[9].Value = model.QTYDR;
parameters[10].Value = model.QTYCR;
parameters[11].Value = model.ORDNO;
parameters[12].Value = model.EXPLAN;
parameters[13].Value = model.ISDEPTACC;
parameters[14].Value = model.ISEMPLACC;
parameters[15].Value = model.ISCORPACC;
parameters[16].Value = model.ISITEMACC;
parameters[17].Value = model.DEPTID;
parameters[18].Value = model.EMPLID;
parameters[19].Value = model.CORPID;
parameters[20].Value = model.PITEMID;
parameters[21].Value = model.ITEMID;
parameters[22].Value = model.ITEMNO;
parameters[23].Value = model.FIELD10;
parameters[24].Value = model.FIELD9;
parameters[25].Value = model.FIELD8;
parameters[26].Value = model.FIELD7;
parameters[27].Value = model.FIELD6;
parameters[28].Value = model.FIELD5;
parameters[29].Value = model.FIELD4;
parameters[30].Value = model.FIELD3;
parameters[31].Value = model.FIELD2;
parameters[32].Value = model.FIELD1;
parameters[33].Value = model.ACCID;
//parameters[34].Value = model.ISSYS;
parameters[34].Value = model.FSETTLCODE;
parameters[35].Value = model.FSETTLENO;
parameters[36].Value = model.MODIFIEDUSER;
//parameters[38].Value = model.MODIFIEDTIME;
parameters[37].Value = model.PACCID;
parameters[38].Value = model.ACCNAME;
parameters[39].Value = model.PROPERTY;
parameters[40].Value = model.GRADE;
parameters[41].Value = model.DC;
parameters[42].Value = model.CUSTOMERNAME;
parameters[43].Value = model.SALE;
parameters[44].Value = model.BLNO;
//
int existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), parameters);
}
sqlTran.Commit();
result = 1;//状态为1表示更新成功
}
catch (Exception execError)
{
result = -1;//有异常,更新失败
sqlTran.Rollback();
result = -2;//更新异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
//
}
}