Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSOutBillData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into TSOutBill(");
            strSql.Append(@"tsOutBill,stockupBillNo,remark,instantState,isrtEmpId,isrtDate,updateEmpId,udpateDate)");
            strSql.Append(" values (");
            strSql.Append(@"@tsOutBill,@stockupBillNo,@remark,@instantState,@isrtEmpId,@isrtDate,@updateEmpId,@udpateDate)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@tsOutBill", SqlDbType.NVarChar,50),
                    new SqlParameter("@stockupBillNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500),
                    new SqlParameter("@instantState", SqlDbType.NChar,10),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDate", SqlDbType.DateTime),
                    new SqlParameter("@updateEmpId", SqlDbType.Int),
                    new SqlParameter("@udpateDate", SqlDbType.DateTime)
                };
            parameters[0].Value = model.tsOutBill;
            parameters[1].Value = model.stockupBillNo;
            parameters[2].Value = model.remark;
            parameters[3].Value = model.instantState;
            parameters[4].Value = model.isrtEmpId;
            parameters[5].Value = model.isrtDate == string.Empty ? null : model.isrtDate;
            parameters[6].Value = model.updateEmpId;
            parameters[7].Value = model.udpateDate == string.Empty ? null : model.udpateDate;

            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;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSOutBillData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update TSOutBill set ");
            strSql.Append("stockupBillNo=@stockupBillNo,");
            strSql.Append("remark=@remark,");
            strSql.Append("instantState=@instantState,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDate=@isrtDate,");
            strSql.Append("updateEmpId=@updateEmpId,");
            strSql.Append("udpateDate=@udpateDate");
            strSql.Append(" where tsOutBill = @tsOutBill ");
            SqlParameter[] parameters = {
                    new SqlParameter("@tsOutBill", SqlDbType.NVarChar,50),
                    new SqlParameter("@stockupBillNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500),
                    new SqlParameter("@instantState", SqlDbType.NChar,10),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDate", SqlDbType.DateTime),
                    new SqlParameter("@updateEmpId", SqlDbType.Int),
                    new SqlParameter("@udpateDate", SqlDbType.DateTime)
                };
            parameters[0].Value = model.tsOutBill;
            parameters[1].Value = model.stockupBillNo;
            parameters[2].Value = model.remark;
            parameters[3].Value = model.instantState;
            parameters[4].Value = model.isrtEmpId;
            parameters[5].Value = model.isrtDate == string.Empty ? null : model.isrtDate;
            parameters[6].Value = model.updateEmpId;
            parameters[7].Value = model.udpateDate == string.Empty ? null : model.udpateDate;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Exemplo n.º 3
0
        public TSOutBillData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,tsOutBill,stockupBillNo,remark,instantState,isrtEmpId,isrtDate,updateEmpId,udpateDate from TSOutBill");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            TSOutBillData model = new TSOutBillData();
            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["tsOutBill"] != DBNull.Value)
                {
                    model.tsOutBill = Convert.ToString(row["tsOutBill"]);
                }
                if (row["stockupBillNo"] != DBNull.Value)
                {
                    model.stockupBillNo = Convert.ToString(row["stockupBillNo"]);
                }
                if (row["remark"] != DBNull.Value)
                {
                    model.remark = Convert.ToString(row["remark"]);
                }
                if (row["instantState"] != DBNull.Value)
                {
                    model.instantState = Convert.ToString(row["instantState"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDate"] != DBNull.Value)
                {
                    model.isrtDate = Convert.ToString(row["isrtDate"]);
                }
                if (row["updateEmpId"] != DBNull.Value)
                {
                    model.updateEmpId = Convert.ToInt32(row["updateEmpId"]);
                }
                if (row["udpateDate"] != DBNull.Value)
                {
                    model.udpateDate = Convert.ToString(row["udpateDate"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(TSOutBillData model)
 {
     return this.sOutBillDB.ModifyRecord(model);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(TSOutBillData model)
 {
     return this.sOutBillDB.AddRecord(model);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 更新一条"TSOutBill"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSOutBillData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.sOutBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.sOutBillBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "TSOutBill修改一条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 = "TSOutBill修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 增加一条"TSOutBill"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSOutBillData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.sOutBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.sOutBillBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "TSOutBill增加一条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 = "TSOutBill增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }