/// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSBarrivebillData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into TSBarrivebill(");
            strSql.Append(@"arriveBillNo,financeBillNo,isrtEmpId,isrtDt,updtEmpId,updtDt,instantState,remark)");
            strSql.Append(" values (");
            strSql.Append(@"@arriveBillNo,@financeBillNo,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt,@instantState,@remark)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@instantState", SqlDbType.NVarChar,20),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500)
                };
            parameters[0].Value = model.arriveBillNo;
            parameters[1].Value = model.financeBillNo;
            parameters[2].Value = model.isrtEmpId;
            parameters[3].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[4].Value = model.updtEmpId;
            parameters[5].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[6].Value = model.instantState;
            parameters[7].Value = model.remark;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
        /// <summary>
        /// 更新一条"TSBarrivebill"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSBarrivebillData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.sBarrivebillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.sBarrivebillBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "TSBarrivebill修改一条id为“" + model.id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransModify");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "TSBarrivebill修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
        /// <summary>
        /// 增加一条"TSBarrivebill"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSBarrivebillData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.sBarrivebillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.sBarrivebillBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "TSBarrivebill增加一条id为“" + id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "TSBarrivebill增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(TSBarrivebillData model)
 {
     return this.sBarrivebillDB.ModifyRecord(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(TSBarrivebillData model)
 {
     return this.sBarrivebillDB.AddRecord(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSBarrivebillData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update TSBarrivebill set ");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt,");
            strSql.Append("instantState=@instantState,");
            strSql.Append("remark=@remark");
            strSql.Append(" where arriveBillNo = @arriveBillNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@instantState", SqlDbType.NVarChar,20),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500)
                };
            parameters[0].Value = model.arriveBillNo;
            parameters[1].Value = model.financeBillNo;
            parameters[2].Value = model.isrtEmpId;
            parameters[3].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[4].Value = model.updtEmpId;
            parameters[5].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[6].Value = model.instantState;
            parameters[7].Value = model.remark;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
        public TSBarrivebillData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,arriveBillNo,financeBillNo,isrtEmpId,isrtDt,updtEmpId,updtDt,instantState,remark from TSBarrivebill");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,20)
                };
            parameters[0].Value = id;

            TSBarrivebillData model = new TSBarrivebillData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["arriveBillNo"] != DBNull.Value)
                {
                    model.arriveBillNo = Convert.ToString(row["arriveBillNo"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                if (row["instantState"] != DBNull.Value)
                {
                    model.instantState = Convert.ToString(row["instantState"]);
                }
                if (row["remark"] != DBNull.Value)
                {
                    model.remark = Convert.ToString(row["remark"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }