using System; using System.Data; using System.Data.SqlClient; using System.Collections; using System.Collections.Generic; using DSWeb.Models; using DSWeb.DataAccess; namespace DSWeb.EntityDA { public class OpBlissueDA { private const string SQL_OPBLISSUE_ID = "@ID"; private const string SQL_OPBLISSUE_BSNO = "@BSNO"; private const string SQL_SELECT_OPBLISSUE_ID = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue where 1=1 and ID=@ID order by BLSTATUS"; private const string SQL_SELECT_OPBLISSUE_BSNO_FA = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue where 1=1 and BSNO=@BSNO and BLSTATUS='提单签出' and DElFLAG=0 order by BLSTATUS"; private const string SQL_SELECT_OPBLISSUE_BSNO_SH = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue where 1=1 and BSNO=@BSNO and BLSTATUS='提单签收' and DElFLAG=0 order by BLSTATUS"; private const string SQL_SELECT_OPBLISSUE_BSNO_DF1 = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue where 1=1 and BSNO=@BSNO and BLSTATUS='提单电放' and DElFLAG=0 order by BLSTATUS"; private const string SQL_SELECT_OPBLISSUE_BSNO_DF2 = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue where 1=1 and BSNO=@BSNO and BLSTATUS='申请电放' and DElFLAG=0 order by BLSTATUS"; private const string SQL_SELECT_OPBLISSUE_BSNO_DF3 = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue where 1=1 and BSNO=@BSNO and BLSTATUS='批准电放' and DElFLAG=0 order by BLSTATUS"; private const string SQL_SELECT_OPBLISSUE_BY_BSNO = " SELECT ID,BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,OPTIME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,PUTSINGLETIME,PUTSINGLE,PAYTIME,PAYRMB,PAYUSD FROM op_blissue WHERE BSNO = @bsno ORDER BY BLSTATUS"; private string strSqlInsert = "insert into [op_blissue](BSNO,BLNO,BLNAME,BLSTATUS,BLORDERNO,ISSUETYPE,OPNAME,BSINKNO,REMARK,DElFLAG,EXPRESSCORP,EXPRESSNO,ISADD,{0}{2}PUTSINGLE,PAYRMB,PAYUSD) values(@BSNO,@BLNO,@BLNAME,@BLSTATUS,@BLORDERNO,@ISSUETYPE,@OPNAME,@BSINKNO,@REMARK,@DElFLAG,@EXPRESSCORP,@EXPRESSNO,@ISADD,{1}{3}@PUTSINGLE,@PAYRMB,@PAYUSD)"; private const string SQL_DELETE_BY_ID = "DELETE FROM op_blissue WHERE ID = @ID"; #region BSNO获取批准电放信息 /// /// 根据委托业务BSNO获取提前签发所有信息 /// /// /// public IList GetOpBlissueByBSNO(string strBSNO) { IList OpBlissueEntities = new List(); SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_BSNO, SqlDbType.VarChar, 100); parm.Value = strBSNO; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_BY_BSNO, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity opBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { opBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { opBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { opBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { opBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { opBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { opBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { opBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { opBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { opBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { opBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { opBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { opBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { opBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { opBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } OpBlissueEntities.Add(opBlissueEntity); } } catch (Exception execError) { throw execError; } } return OpBlissueEntities; } #endregion /// /// 插入信息 /// /// 实体类 /// 值为1插入数据正常,-1操作异常 public int InserInfo(OpBlissueEntity infoEntity) { int iResult = 0; //获取参数 SqlParameter[] parms = GetInsertParms(); parms[0].Value = infoEntity.BSNO;//业务编号 parms[1].Value = infoEntity.BLNO;//单证编号 parms[2].Value = infoEntity.BLNAME;//单证名称 parms[3].Value = infoEntity.BLSTATUS;//处理状态 parms[4].Value = infoEntity.BLORDERNO;//单证流水号 parms[5].Value = infoEntity.ISSUETYPE;//签单方式 parms[6].Value = infoEntity.OPNAME;//处理人 //parms[7].Value = infoEntity.OPTIME;//处理时间 parms[7].Value = infoEntity.BSINKNO;//关联编号 parms[8].Value = infoEntity.REMARK;//备注 parms[9].Value = infoEntity.DElFLAG;//撤销标志 parms[10].Value = infoEntity.EXPRESSCORP;//快递公司 parms[11].Value = infoEntity.EXPRESSNO;//快递号 parms[12].Value = infoEntity.ISADD;// parms[13].Value = infoEntity.PUTSINGLE;// parms[14].Value = infoEntity.PAYRMB;// parms[15].Value = infoEntity.PAYUSD;// string strPUTSINGLETIME = infoEntity.PUTSINGLETIME.ToString().IndexOf("0001")>-1 ? "" : "'" + infoEntity.PUTSINGLETIME.ToString() + "',"; string strPUTSINGLETIME_name = strPUTSINGLETIME.Equals("") ? "" : "PUTSINGLETIME,"; string strPAYTIME = infoEntity.PAYTIME.ToString().IndexOf("0001")>-1 ? "" : "'" + infoEntity.PAYTIME.ToString() + "',"; string strPAYTIME_name = strPAYTIME.Equals("") ? "" : "PAYTIME,"; strSqlInsert = String.Format(strSqlInsert, strPUTSINGLETIME_name, strPUTSINGLETIME, strPAYTIME_name, strPAYTIME); // using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction)) { int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSqlInsert, parms); if (existVal > 0) { iResult = 1; } else { iResult = -1;//执行异常 } } return iResult; } #region 生成插入语句参数 /// /// 生成插入语句参数 /// /// 返回SqlParameter数组 private SqlParameter[] GetInsertParms() { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@BSNO",SqlDbType.VarChar,100),//委托编号 new SqlParameter("@BLNO",SqlDbType.VarChar,30),//单证编号 new SqlParameter("@BLNAME",SqlDbType.VarChar,50),//单证名称 new SqlParameter("@BLSTATUS",SqlDbType.VarChar,10),//处理状态 new SqlParameter("@BLORDERNO",SqlDbType.VarChar,30),//单证流水号 new SqlParameter("@ISSUETYPE",SqlDbType.VarChar,12),//签单方式 new SqlParameter("@OPNAME",SqlDbType.VarChar,10),//处理人 //new SqlParameter("@OPTIME",SqlDbType.DateTime),//处理时间 new SqlParameter("@BSINKNO",SqlDbType.VarChar,100),//关联编号 new SqlParameter("@REMARK",SqlDbType.VarChar,200),//备注 new SqlParameter("@DElFLAG",SqlDbType.Bit),//撤销标志 new SqlParameter("@EXPRESSCORP",SqlDbType.VarChar,50),//快递公司 new SqlParameter("@EXPRESSNO",SqlDbType.VarChar,50),//快递号 new SqlParameter("@ISADD",SqlDbType.Bit),// new SqlParameter("@PUTSINGLE",SqlDbType.VarChar,1024),// new SqlParameter("@PAYRMB",SqlDbType.Decimal),// new SqlParameter("@PAYUSD",SqlDbType.Decimal)// }; return parms; } #endregion #region BSNO获取批准电放信息 /// /// BSNO获取批准电放信息 /// /// /// public OpBlissueEntity GetOpBlissueBSNODF3(string strBSNO) { OpBlissueEntity OpBlissueEntity = null; SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_BSNO, SqlDbType.VarChar, 100); parm.Value = strBSNO; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_BSNO_DF3, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { OpBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { OpBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { OpBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { OpBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { OpBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { OpBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { OpBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { OpBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { OpBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { OpBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { OpBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { OpBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { OpBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { OpBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } if (!sqlRead.IsDBNull(14)) { OpBlissueEntity.ISADD = sqlRead.GetBoolean(14); } if (!sqlRead.IsDBNull(15)) { OpBlissueEntity.PUTSINGLETIME = sqlRead.GetDateTime(15); } if (!sqlRead.IsDBNull(16)) { OpBlissueEntity.PUTSINGLE = sqlRead.GetString(16); } if (!sqlRead.IsDBNull(17)) { OpBlissueEntity.PAYTIME = sqlRead.GetDateTime(17); } if (!sqlRead.IsDBNull(18)) { OpBlissueEntity.PAYRMB = sqlRead.GetDecimal(18); } if (!sqlRead.IsDBNull(19)) { OpBlissueEntity.PAYUSD = sqlRead.GetDecimal(19); } } } catch (Exception execError) { throw execError; } } return OpBlissueEntity; } #endregion #region BSNO获取提单电放信息 /// /// BSNO获取提单电放信息 /// /// /// public OpBlissueEntity GetOpBlissueBSNODF1(string strBSNO) { OpBlissueEntity OpBlissueEntity = null; SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_BSNO, SqlDbType.VarChar, 100); parm.Value = strBSNO; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_BSNO_DF1, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { OpBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { OpBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { OpBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { OpBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { OpBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { OpBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { OpBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { OpBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { OpBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { OpBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { OpBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { OpBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { OpBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { OpBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } if (!sqlRead.IsDBNull(14)) { OpBlissueEntity.ISADD = sqlRead.GetBoolean(14); } if (!sqlRead.IsDBNull(15)) { OpBlissueEntity.PUTSINGLETIME = sqlRead.GetDateTime(15); } if (!sqlRead.IsDBNull(16)) { OpBlissueEntity.PUTSINGLE = sqlRead.GetString(16); } if (!sqlRead.IsDBNull(17)) { OpBlissueEntity.PAYTIME = sqlRead.GetDateTime(17); } if (!sqlRead.IsDBNull(18)) { OpBlissueEntity.PAYRMB = sqlRead.GetDecimal(18); } if (!sqlRead.IsDBNull(19)) { OpBlissueEntity.PAYUSD = sqlRead.GetDecimal(19); } } } catch (Exception execError) { throw execError; } } return OpBlissueEntity; } #endregion #region BSNO获取申请电放信息 /// /// BSNO获取申请电放信息 /// /// /// public OpBlissueEntity GetOpBlissueBSNODF2(string strBSNO) { OpBlissueEntity OpBlissueEntity = null; SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_BSNO, SqlDbType.VarChar, 100); parm.Value = strBSNO; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_BSNO_DF2, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { OpBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { OpBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { OpBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { OpBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { OpBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { OpBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { OpBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { OpBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { OpBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { OpBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { OpBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { OpBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { OpBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { OpBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } if (!sqlRead.IsDBNull(14)) { OpBlissueEntity.ISADD = sqlRead.GetBoolean(14); } if (!sqlRead.IsDBNull(15)) { OpBlissueEntity.PUTSINGLETIME = sqlRead.GetDateTime(15); } if (!sqlRead.IsDBNull(16)) { OpBlissueEntity.PUTSINGLE = sqlRead.GetString(16); } if (!sqlRead.IsDBNull(17)) { OpBlissueEntity.PAYTIME = sqlRead.GetDateTime(17); } if (!sqlRead.IsDBNull(18)) { OpBlissueEntity.PAYRMB = sqlRead.GetDecimal(18); } if (!sqlRead.IsDBNull(19)) { OpBlissueEntity.PAYUSD = sqlRead.GetDecimal(19); } } } catch (Exception execError) { throw execError; } } return OpBlissueEntity; } #endregion #region BSNO获取提单签出信息 /// /// BSNO获取提单签出信息 /// /// /// public OpBlissueEntity GetOpBlissueBSNOFA(string strBSNO) { OpBlissueEntity OpBlissueEntity = null; SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_BSNO, SqlDbType.VarChar, 100); parm.Value = strBSNO; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_BSNO_FA, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { OpBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { OpBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { OpBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { OpBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { OpBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { OpBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { OpBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { OpBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { OpBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { OpBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { OpBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { OpBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { OpBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { OpBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } if (!sqlRead.IsDBNull(14)) { OpBlissueEntity.ISADD = sqlRead.GetBoolean(14); } if (!sqlRead.IsDBNull(15)) { OpBlissueEntity.PUTSINGLETIME = sqlRead.GetDateTime(15); } if (!sqlRead.IsDBNull(16)) { OpBlissueEntity.PUTSINGLE = sqlRead.GetString(16); } if (!sqlRead.IsDBNull(17)) { OpBlissueEntity.PAYTIME = sqlRead.GetDateTime(17); } if (!sqlRead.IsDBNull(18)) { OpBlissueEntity.PAYRMB = sqlRead.GetDecimal(18); } if (!sqlRead.IsDBNull(19)) { OpBlissueEntity.PAYUSD = sqlRead.GetDecimal(19); } } } catch (Exception execError) { throw execError; } } return OpBlissueEntity; } #endregion #region BSNO获取提单签收信息 /// /// BSNO获取提单签收信息 /// /// /// public OpBlissueEntity GetOpBlissueBSNOSH(string strBSNO) { OpBlissueEntity OpBlissueEntity = null; SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_BSNO, SqlDbType.VarChar, 100); parm.Value = strBSNO; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_BSNO_SH, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { OpBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { OpBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { OpBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { OpBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { OpBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { OpBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { OpBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { OpBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { OpBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { OpBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { OpBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { OpBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { OpBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { OpBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } if (!sqlRead.IsDBNull(14)) { OpBlissueEntity.ISADD = sqlRead.GetBoolean(14); } if (!sqlRead.IsDBNull(15)) { OpBlissueEntity.PUTSINGLETIME = sqlRead.GetDateTime(15); } if (!sqlRead.IsDBNull(16)) { OpBlissueEntity.PUTSINGLE = sqlRead.GetString(16); } if (!sqlRead.IsDBNull(17)) { OpBlissueEntity.PAYTIME = sqlRead.GetDateTime(17); } if (!sqlRead.IsDBNull(18)) { OpBlissueEntity.PAYRMB = sqlRead.GetDecimal(18); } if (!sqlRead.IsDBNull(19)) { OpBlissueEntity.PAYUSD = sqlRead.GetDecimal(19); } } } catch (Exception execError) { throw execError; } } return OpBlissueEntity; } #endregion #region ID获取信息 /// /// ID获取信息 /// /// /// public OpBlissueEntity GetOpBlissueID(string strID) { OpBlissueEntity OpBlissueEntity = null; SqlParameter parm = new SqlParameter(SQL_OPBLISSUE_ID, SqlDbType.VarChar, 36); parm.Value = strID; using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_OPBLISSUE_ID, parm)) { try { while (sqlRead.Read()) { OpBlissueEntity = new OpBlissueEntity(); if (!sqlRead.IsDBNull(0)) { OpBlissueEntity.ID = sqlRead.GetString(0); } if (!sqlRead.IsDBNull(1)) { OpBlissueEntity.BSNO = sqlRead.GetString(1); } if (!sqlRead.IsDBNull(2)) { OpBlissueEntity.BLNO = sqlRead.GetString(2); } if (!sqlRead.IsDBNull(3)) { OpBlissueEntity.BLNAME = sqlRead.GetString(3); } if (!sqlRead.IsDBNull(4)) { OpBlissueEntity.BLSTATUS = sqlRead.GetString(4); } if (!sqlRead.IsDBNull(5)) { OpBlissueEntity.BLORDERNO = sqlRead.GetString(5); } if (!sqlRead.IsDBNull(6)) { OpBlissueEntity.ISSUETYPE = sqlRead.GetString(6); } if (!sqlRead.IsDBNull(7)) { OpBlissueEntity.OPNAME = sqlRead.GetString(7); } if (!sqlRead.IsDBNull(8)) { OpBlissueEntity.OPTIME = sqlRead.GetDateTime(8); } if (!sqlRead.IsDBNull(9)) { OpBlissueEntity.BSINKNO = sqlRead.GetString(9); } if (!sqlRead.IsDBNull(10)) { OpBlissueEntity.REMARK = sqlRead.GetString(10); } if (!sqlRead.IsDBNull(11)) { OpBlissueEntity.DElFLAG = sqlRead.GetBoolean(11); } if (!sqlRead.IsDBNull(12)) { OpBlissueEntity.EXPRESSCORP = sqlRead.GetString(12); } if (!sqlRead.IsDBNull(13)) { OpBlissueEntity.EXPRESSNO = sqlRead.GetString(13); } if (!sqlRead.IsDBNull(14)) { OpBlissueEntity.ISADD = sqlRead.GetBoolean(14); } if (!sqlRead.IsDBNull(15)) { OpBlissueEntity.PUTSINGLETIME = sqlRead.GetDateTime(15); } if (!sqlRead.IsDBNull(16)) { OpBlissueEntity.PUTSINGLE = sqlRead.GetString(16); } if (!sqlRead.IsDBNull(17)) { OpBlissueEntity.PAYTIME = sqlRead.GetDateTime(17); } if (!sqlRead.IsDBNull(18)) { OpBlissueEntity.PAYRMB = sqlRead.GetDecimal(18); } if (!sqlRead.IsDBNull(19)) { OpBlissueEntity.PAYUSD = sqlRead.GetDecimal(19); } } } catch (Exception execError) { throw execError; } } return OpBlissueEntity; } #endregion #region 更新DElFLAG信息 /// /// 更新DElFLAG信息 /// /// 更新SQL语句 /// 返回状态值 为1表示更新完成;为-1更新出现异常但未正确回滚事务;为-2更新异常,事务已经成功回滚;默认状态为0 public int UpdateDElFLAG(string strSql) { int result = 0; using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql, null); sqlTran.Commit(); result = 1;//状态为1表示更新成功 } catch (Exception execError) { result = -1;//有异常,更新失败 sqlTran.Rollback(); result = -2;//更新异常,事务已回滚成功 throw execError; } finally { SqlHelper.CloseConnection(); } } return result; } #endregion #region 通过账户ID删除单条账户 public int DeleteById(string tempGid) { int result = 0; SqlParameter parm = new SqlParameter("@ID", SqlDbType.VarChar, 36); parm.Value = tempGid; using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_DELETE_BY_ID, parm); result = 1;//状态为1表示删除成功 sqlTran.Commit(); } catch (Exception execError) { result = -1;//有异常,插入失败 sqlTran.Rollback(); result = -2;//插入异常,事务已回滚成功 throw execError; } finally { SqlHelper.CloseConnection(); } } return result; } #endregion #region 根据SQL语句查询账户数据集 /// /// 根据SQL语句查询账户数据集 /// /// /// public DataSet GetOpBlissueByCondition(string strSql) { DataSet userSet = new DataSet(); userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql); return userSet; } #endregion #region 插入账户列表信息 /// /// 插入账户列表信息 /// /// 插入SQL语句组,将所有要执行的插入语句写入ArrayList,每个索引对应一条SQL语句,执行时需要遍历操作 /// 返回状态值 为1表示插入完成;为-1插入出现异常但未正确回滚事务;为-2插入异常,事务已经成功回滚;默认状态为0 public int InsertOpBlissueFromGrid(ArrayList sqlList) { int result = 0; using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { for (int i = 0; i < sqlList.Count; i++) { string strUpdateSql = sqlList[i].ToString(); SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strUpdateSql, null); } sqlTran.Commit(); result = 1;//状态为1表示插入成功 } catch (Exception execError) { result = -1;//有异常,插入失败 sqlTran.Rollback(); result = -2;//插入异常,事务已回滚成功 throw execError; } finally { SqlHelper.CloseConnection(); } } return result; } #endregion #region 更新账户列表信息 /// /// 更新账户列表信息 /// /// 更新SQL语句组,将所有要执行的更新语句写入ArrayList,每个索引对应一条SQL语句,执行时需要遍历操作 /// 返回状态值 为1表示更新完成;为-1更新出现异常但未正确回滚事务;为-2更新异常,事务已经成功回滚;默认状态为0 public int UpdateOpBlissueFromGrid(ArrayList sqlList) { int result = 0; using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { for (int i = 0; i < sqlList.Count; i++) { string strUpdateSql = sqlList[i].ToString(); SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strUpdateSql, null); } sqlTran.Commit(); result = 1;//状态为1表示更新成功 } catch (Exception execError) { result = -1;//有异常,更新失败 sqlTran.Rollback(); result = -2;//更新异常,事务已回滚成功 throw execError; } finally { SqlHelper.CloseConnection(); } } return result; } #endregion } }