Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BmTelModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update CORE.dbo.BmTel set ");

            strSql.Append(" BmTelNo = @BmTelNo , ");
            strSql.Append(" BmTelTitle = @BmTelTitle , ");
            strSql.Append(" BmTelTypeId = @BmTelTypeId , ");
            strSql.Append(" BmTelMemo = @BmTelMemo , ");
            strSql.Append(" OrderNo = @OrderNo  ");
            strSql.Append(" where BmTelId=@BmTelId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@BmTelId",     SqlDbType.Decimal,   9),
                new SqlParameter("@BmTelNo",     SqlDbType.VarChar,  50),
                new SqlParameter("@BmTelTitle",  SqlDbType.VarChar,  50),
                new SqlParameter("@BmTelTypeId", SqlDbType.Int,       4),
                new SqlParameter("@BmTelMemo",   SqlDbType.VarChar, 250),
                new SqlParameter("@OrderNo",     SqlDbType.Int, 4)
            };

            parameters[0].Value = model.BmTelId;
            parameters[1].Value = model.BmTelNo;
            parameters[2].Value = model.BmTelTitle;
            parameters[3].Value = model.BmTelTypeId;
            parameters[4].Value = model.BmTelMemo;
            parameters[5].Value = model.OrderNo; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(BmTelModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.BmTel (");
            strSql.Append("BmTelNo,BmTelTitle,BmTelTypeId,BmTelMemo,OrderNo");
            strSql.Append(") values (");
            strSql.Append("@BmTelNo,@BmTelTitle,@BmTelTypeId,@BmTelMemo,@OrderNo");
            strSql.Append(") ");
            strSql.Append(";");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BmTelNo",     SqlDbType.VarChar,  50),
                new SqlParameter("@BmTelTitle",  SqlDbType.VarChar,  50),
                new SqlParameter("@BmTelTypeId", SqlDbType.Int,       4),
                new SqlParameter("@BmTelMemo",   SqlDbType.VarChar, 250),
                new SqlParameter("@OrderNo",     SqlDbType.Int, 4)
            };

            parameters[0].Value = model.BmTelNo;
            parameters[1].Value = model.BmTelTitle;
            parameters[2].Value = model.BmTelTypeId;
            parameters[3].Value = model.BmTelMemo;
            parameters[4].Value = model.OrderNo;

            bool result = false;

            try
            {
                model.BmTelId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "BmTelId", parameters));


                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BmTelModel GetModel(decimal BmTelId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select BmTelId, BmTelNo, BmTelTitle, BmTelTypeId, BmTelMemo, OrderNo  ");
            strSql.Append("  from CORE.dbo.BmTel ");
            strSql.Append(" where BmTelId=@BmTelId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BmTelId", SqlDbType.Decimal)
            };
            parameters[0].Value = BmTelId;


            BmTelModel model = new BmTelModel();
            DataSet    ds    = helper.ExecSqlReDs(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["BmTelId"].ToString() != "")
                {
                    model.BmTelId = decimal.Parse(ds.Tables[0].Rows[0]["BmTelId"].ToString());
                }
                model.BmTelNo    = ds.Tables[0].Rows[0]["BmTelNo"].ToString();
                model.BmTelTitle = ds.Tables[0].Rows[0]["BmTelTitle"].ToString();
                if (ds.Tables[0].Rows[0]["BmTelTypeId"].ToString() != "")
                {
                    model.BmTelTypeId = int.Parse(ds.Tables[0].Rows[0]["BmTelTypeId"].ToString());
                }
                model.BmTelMemo = ds.Tables[0].Rows[0]["BmTelMemo"].ToString();
                if (ds.Tables[0].Rows[0]["OrderNo"].ToString() != "")
                {
                    model.OrderNo = int.Parse(ds.Tables[0].Rows[0]["OrderNo"].ToString());
                }

                return(model);
            }
            else
            {
                return(model);
            }
        }