Example #1
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(SErrorDiaryData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into SErrorDiary(");
            strSql.Append("empId,functionId,errorText,operateDt)");
            strSql.Append(" values (");
            strSql.Append("@empId,@functionId,@errorText,@operateDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@functionId", SqlDbType.NVarChar,20),
                    new SqlParameter("@errorText", SqlDbType.NVarChar,200),
                    new SqlParameter("@operateDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.empId;
            parameters[1].Value = model.functionId;
            parameters[2].Value = model.errorText;
            parameters[3].Value = model.operateDt == string.Empty ? null : model.operateDt;

            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>
        /// 更新一条"排托单"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BArrangeBillData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.arrangeBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.arrangeBillBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "排托单修改一条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 = "排托单修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
        /// <summary>
        /// 删除多条"排托单"信息
        /// </summary>
        /// <param name="keyValues">主键值数组</param>
        public bool DeleteRecords(int[] keyValues)
        {
            bool ret = false;
            SqlTransaction trans = null;

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransDelete");
                    this.arrangeBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }
                foreach (int key in keyValues)
                {
                    this.arrangeBillBB.DeleteRecord(key);

                    SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                    operatDiaryData.empId = this.empId;
                    operatDiaryData.functionId = "";
                    operatDiaryData.recordId = key.ToString();
                    operatDiaryData.operateContent = "排托单删除一条主键为“" + key.ToString() + "”的记录";
                    this.operatDiaryBB.AddRecord(operatDiaryData);
                }
                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransDelete");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "排托单删除多条记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 增加一条"排托单"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BArrangeBillData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.arrangeBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.arrangeBillBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "排托单增加一条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 = "排托单增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }
        /// <summary>
        /// 删除一条"TSBarrivebill"信息
        /// </summary>
        /// <param name="arriveBillNo">主键值</param>
        public bool DeleteRecord(string arriveBillNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransDelete");
                    this.sBarrivebillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.sBarrivebillBB.DeleteRecord(arriveBillNo);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = arriveBillNo.ToString();
                operatDiaryData.operateContent = "TSBarrivebill删除一条主键为“" + arriveBillNo.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransDelete");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "TSBarrivebill删除记录“" + arriveBillNo.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
Example #6
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(SErrorDiaryData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SErrorDiary set ");
            strSql.Append("empId=@empId,");
            strSql.Append("functionId=@functionId,");
            strSql.Append("errorText=@errorText,");
            strSql.Append("operateDt=@operateDt");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@functionId", SqlDbType.NVarChar,20),
                    new SqlParameter("@errorText", SqlDbType.NVarChar,200),
                    new SqlParameter("@operateDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.empId;
            parameters[2].Value = model.functionId;
            parameters[3].Value = model.errorText;
            parameters[4].Value = model.operateDt == string.Empty ? null : model.operateDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Example #7
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="id">����ֵ</param>
        /// <returns>model</returns>
        public SErrorDiaryData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from SErrorDiary");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            SErrorDiaryData model = new SErrorDiaryData();
            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["empId"] != DBNull.Value)
                {
                    model.empId = Convert.ToInt32(row["empId"]);
                }
                if (row["functionId"] != DBNull.Value)
                {
                    model.functionId = Convert.ToString(row["functionId"]);
                }
                if (row["errorText"] != DBNull.Value)
                {
                    model.errorText = Convert.ToString(row["errorText"]);
                }
                if (row["operateDt"] != DBNull.Value)
                {
                    model.operateDt = Convert.ToString(row["operateDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Example #8
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(SErrorDiaryData model)
 {
     return this.errorDiaryDB.ModifyRecord(model);
 }
Example #9
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(SErrorDiaryData model)
 {
     return this.errorDiaryDB.AddRecord(model);
 }