Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(OtherOutInDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into OtherOutInDetail(");
            strSql.Append(@"SAPDocEntry,MaterialNo,WareNO,Number,U_PCNo,UnitQty,Boxqty,BoxNumber,InstantSate,LineNumber)");
            strSql.Append(" values (");
            strSql.Append(@"@SAPDocEntry,@MaterialNo,@WareNO,@Number,@U_PCNo,@UnitQty,@Boxqty,@BoxNumber,@InstantSate,@LineNumber)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@SAPDocEntry", SqlDbType.NVarChar,50),
                    new SqlParameter("@MaterialNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@WareNO", SqlDbType.NChar,10),
                    new SqlParameter("@Number", SqlDbType.Decimal,9),
                    new SqlParameter("@U_PCNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@UnitQty", SqlDbType.Decimal,9),
                    new SqlParameter("@Boxqty", SqlDbType.Decimal,9),
                    new SqlParameter("@BoxNumber", SqlDbType.Int),
                    new SqlParameter("@InstantSate", SqlDbType.VarChar,10),
                    new SqlParameter("@LineNumber", SqlDbType.Int)
                };
            parameters[0].Value = model.SAPDocEntry;
            parameters[1].Value = model.MaterialNo;
            parameters[2].Value = model.WareNO;
            parameters[3].Value = model.Number;
            parameters[4].Value = model.U_PCNo;
            parameters[5].Value = model.UnitQty;
            parameters[6].Value = model.Boxqty;
            parameters[7].Value = model.BoxNumber;
            parameters[8].Value = model.InstantSate;
            parameters[9].Value = model.LineNumber;

            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;
        }
Пример #2
0
        /// <summary>
        /// 更新一条"其他出入库单据明细表"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(OtherOutInDetailData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.therOutInDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.therOutInDetailBB.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;
        }
Пример #3
0
        /// <summary>
        /// 增加一条"其他出入库单据明细表"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(OtherOutInDetailData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.therOutInDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.therOutInDetailBB.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;
        }
Пример #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(OtherOutInDetailData model)
 {
     return this.therOutInDetailDB.ModifyRecord(model);
 }
Пример #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(OtherOutInDetailData model)
 {
     return this.therOutInDetailDB.AddRecord(model);
 }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(OtherOutInDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update OtherOutInDetail set ");
            strSql.Append("SAPDocEntry=@SAPDocEntry,");
            strSql.Append("MaterialNo=@MaterialNo,");
            strSql.Append("WareNO=@WareNO,");
            strSql.Append("Number=@Number,");
            strSql.Append("U_PCNo=@U_PCNo,");
            strSql.Append("UnitQty=@UnitQty,");
            strSql.Append("Boxqty=@Boxqty,");
            strSql.Append("BoxNumber=@BoxNumber,");
            strSql.Append("InstantSate=@InstantSate,");
            strSql.Append("LineNumber=@LineNumber");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.BigInt),
                    new SqlParameter("@SAPDocEntry", SqlDbType.NVarChar,50),
                    new SqlParameter("@MaterialNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@WareNO", SqlDbType.NChar,10),
                    new SqlParameter("@Number", SqlDbType.Decimal,9),
                    new SqlParameter("@U_PCNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@UnitQty", SqlDbType.Decimal,9),
                    new SqlParameter("@Boxqty", SqlDbType.Decimal,9),
                    new SqlParameter("@BoxNumber", SqlDbType.Int),
                    new SqlParameter("@InstantSate", SqlDbType.VarChar,10),
                    new SqlParameter("@LineNumber", SqlDbType.Int)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.SAPDocEntry;
            parameters[2].Value = model.MaterialNo;
            parameters[3].Value = model.WareNO;
            parameters[4].Value = model.Number;
            parameters[5].Value = model.U_PCNo;
            parameters[6].Value = model.UnitQty;
            parameters[7].Value = model.Boxqty;
            parameters[8].Value = model.BoxNumber;
            parameters[9].Value = model.InstantSate;
            parameters[10].Value = model.LineNumber;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Пример #7
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public OtherOutInDetailData GetModel(long id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,SAPDocEntry,MaterialNo,WareNO,Number,U_PCNo,UnitQty,Boxqty,BoxNumber,InstantSate,LineNumber from OtherOutInDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.BigInt)
                };
            parameters[0].Value = id;

            OtherOutInDetailData model = new OtherOutInDetailData();
            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.ToInt64(row["id"]);
                }
                if (row["SAPDocEntry"] != DBNull.Value)
                {
                    model.SAPDocEntry = Convert.ToString(row["SAPDocEntry"]);
                }
                if (row["MaterialNo"] != DBNull.Value)
                {
                    model.MaterialNo = Convert.ToString(row["MaterialNo"]);
                }
                if (row["WareNO"] != DBNull.Value)
                {
                    model.WareNO = Convert.ToString(row["WareNO"]);
                }
                if (row["Number"] != DBNull.Value)
                {
                    model.Number = Convert.ToDecimal(row["Number"]);
                }
                if (row["U_PCNo"] != DBNull.Value)
                {
                    model.U_PCNo = Convert.ToString(row["U_PCNo"]);
                }
                if (row["UnitQty"] != DBNull.Value)
                {
                    model.UnitQty = Convert.ToDecimal(row["UnitQty"]);
                }
                if (row["Boxqty"] != DBNull.Value)
                {
                    model.Boxqty = Convert.ToDecimal(row["Boxqty"]);
                }
                if (row["BoxNumber"] != DBNull.Value)
                {
                    model.BoxNumber = Convert.ToInt32(row["BoxNumber"]);
                }
                if (row["InstantSate"] != DBNull.Value)
                {
                    model.InstantSate = Convert.ToString(row["InstantSate"]);
                }
                if (row["LineNumber"] != DBNull.Value)
                {
                    model.LineNumber = Convert.ToInt32(row["LineNumber"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }