コード例 #1
0
ファイル: WxSendInfoDAL.cs プロジェクト: snoopy83101/Uzor001
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WxSendInfoModel GetModel(decimal WxSendId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select WxSendId, FmImgId, WxSuCaiId, SendContent, InputCode, WxSendTitle, CreateTime, CreateUser, WxSendType, WxSendClassId, WxPtId, Memo  ");
            strSql.Append("  from CORE.dbo.WxSendInfo ");
            strSql.Append(" where WxSendId=@WxSendId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WxSendId", SqlDbType.Decimal)
            };
            parameters[0].Value = WxSendId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["WxSendId"].ToString() != "")
                {
                    model.WxSendId = decimal.Parse(ds.Tables[0].Rows[0]["WxSendId"].ToString());
                }
                model.FmImgId = ds.Tables[0].Rows[0]["FmImgId"].ToString();
                if (ds.Tables[0].Rows[0]["WxSuCaiId"].ToString() != "")
                {
                    model.WxSuCaiId = decimal.Parse(ds.Tables[0].Rows[0]["WxSuCaiId"].ToString());
                }
                model.SendContent = ds.Tables[0].Rows[0]["SendContent"].ToString();
                model.InputCode   = ds.Tables[0].Rows[0]["InputCode"].ToString();
                model.WxSendTitle = ds.Tables[0].Rows[0]["WxSendTitle"].ToString();
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                model.CreateUser = ds.Tables[0].Rows[0]["CreateUser"].ToString();
                model.WxSendType = ds.Tables[0].Rows[0]["WxSendType"].ToString();
                if (ds.Tables[0].Rows[0]["WxSendClassId"].ToString() != "")
                {
                    model.WxSendClassId = int.Parse(ds.Tables[0].Rows[0]["WxSendClassId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WxPtId"].ToString() != "")
                {
                    model.WxPtId = decimal.Parse(ds.Tables[0].Rows[0]["WxPtId"].ToString());
                }
                model.Memo = ds.Tables[0].Rows[0]["Memo"].ToString();

                return(model);
            }
            else
            {
                return(model);
            }
        }
コード例 #2
0
ファイル: WxSendInfoDAL.cs プロジェクト: snoopy83101/Uzor001
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WxSendInfoModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.WxSendInfo (");
            strSql.Append("FmImgId,WxSuCaiId,SendContent,InputCode,WxSendTitle,CreateTime,CreateUser,WxSendType,WxSendClassId,WxPtId,Memo");
            strSql.Append(") values (");
            strSql.Append("@FmImgId,@WxSuCaiId,@SendContent,@InputCode,@WxSendTitle,@CreateTime,@CreateUser,@WxSendType,@WxSendClassId,@WxPtId,@Memo");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FmImgId",       SqlDbType.VarChar,    50),
                new SqlParameter("@WxSuCaiId",     SqlDbType.Decimal,     9),
                new SqlParameter("@SendContent",   SqlDbType.NText),
                new SqlParameter("@InputCode",     SqlDbType.VarChar,   500),
                new SqlParameter("@WxSendTitle",   SqlDbType.VarChar,    50),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUser",    SqlDbType.VarChar,    50),
                new SqlParameter("@WxSendType",    SqlDbType.VarChar,    50),
                new SqlParameter("@WxSendClassId", SqlDbType.Int,         4),
                new SqlParameter("@WxPtId",        SqlDbType.Decimal,     9),
                new SqlParameter("@Memo",          SqlDbType.VarChar, 500)
            };

            parameters[0].Value  = model.FmImgId;
            parameters[1].Value  = model.WxSuCaiId;
            parameters[2].Value  = model.SendContent;
            parameters[3].Value  = model.InputCode;
            parameters[4].Value  = model.WxSendTitle;
            parameters[5].Value  = model.CreateTime;
            parameters[6].Value  = model.CreateUser;
            parameters[7].Value  = model.WxSendType;
            parameters[8].Value  = model.WxSendClassId;
            parameters[9].Value  = model.WxPtId;
            parameters[10].Value = model.Memo;

            bool result = false;

            try
            {
                model.WxSendId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "WxSendId", parameters));
                result         = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
コード例 #3
0
    private void SaveSendInfo()
    {
        #region 事务开启

        TransactionOptions transactionOption = new TransactionOptions();
        transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
        using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOption))
        {
            #endregion

            Model.WxSendInfoModel model = new WxSendInfoModel();
            BLL.WxBLL             bll   = new BLL.WxBLL();
            model.WxSendId = ReDecimal("WxSendId", 0);

            if (model.WxSendId == 0)
            {
                model.WxPtId = ReDecimal("WxPtId");
            }
            else
            {
                //如果是修改, 选取出原来的数据
                model = bll.GetWxSendModel(model.WxSendId);
            }
            model.WxSendTitle   = ReStr("WxSendTitle");
            model.WxSendType    = ReStr("WxSendType");
            model.WxSendClassId = ReInt("WxSendClassId");
            model.Memo          = ReStr("Memo");
            model.FmImgId       = ReStr("FmImgId");
            model.WxSuCaiId     = ReDecimal("WxSuCaiId", 0);
            model.SendContent   = ReStrDeCode("SendContent");
            bll.SaveSendInfo(model);



            DataTable dtKeys = ReTable("KeysAreray");

            if (dtKeys.Rows.Count == 0)
            {
                throw new Exception("没有添加激发时间, 这个回应没有触发将没有意义!");
            }


            DAL.WxKeyDAL keyDal = new DAL.WxKeyDAL();
            keyDal.DeleteList(" WxSendId='" + model.WxSendId + "' ");  //首先删除所有的key关联关系

            foreach (DataRow drKeys in dtKeys.Rows)
            {
                if (model.WxSendId == 0)
                {
                    throw new Exception("在执行插入之后,WxSendId不能为0!");
                }

                Model.WxKeyModel KeyModel = new WxKeyModel();
                KeyModel.WxSendId        = model.WxSendId;
                KeyModel.KeyTitle        = drKeys["KeyTitle"].ToString();
                KeyModel.KeyTypeId       = drKeys["KeyTypeId"].ToString();
                KeyModel.KeyTypeDetailId = drKeys["KeyTypeDetailId"].ToString();
                keyDal.Add(KeyModel);   //逐个添加新的关联关系
            }

            ReDict.Add("WxSendId", model.WxSendId);
            #region 事务关闭

            transactionScope.Complete();
        }
        #endregion


        ReTrue();
    }
コード例 #4
0
ファイル: WxSendInfoDAL.cs プロジェクト: snoopy83101/Uzor001
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WxSendInfoModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

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

            strSql.Append(" FmImgId = @FmImgId , ");
            strSql.Append(" WxSuCaiId = @WxSuCaiId , ");
            strSql.Append(" SendContent = @SendContent , ");
            strSql.Append(" InputCode = @InputCode , ");
            strSql.Append(" WxSendTitle = @WxSendTitle , ");
            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" CreateUser = @CreateUser , ");
            strSql.Append(" WxSendType = @WxSendType , ");
            strSql.Append(" WxSendClassId = @WxSendClassId , ");
            strSql.Append(" WxPtId = @WxPtId , ");
            strSql.Append(" Memo = @Memo  ");
            strSql.Append(" where WxSendId=@WxSendId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@WxSendId",      SqlDbType.Decimal,     9),
                new SqlParameter("@FmImgId",       SqlDbType.VarChar,    50),
                new SqlParameter("@WxSuCaiId",     SqlDbType.Decimal,     9),
                new SqlParameter("@SendContent",   SqlDbType.NText),
                new SqlParameter("@InputCode",     SqlDbType.VarChar,   500),
                new SqlParameter("@WxSendTitle",   SqlDbType.VarChar,    50),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUser",    SqlDbType.VarChar,    50),
                new SqlParameter("@WxSendType",    SqlDbType.VarChar,    50),
                new SqlParameter("@WxSendClassId", SqlDbType.Int,         4),
                new SqlParameter("@WxPtId",        SqlDbType.Decimal,     9),
                new SqlParameter("@Memo",          SqlDbType.VarChar, 500)
            };

            parameters[0].Value  = model.WxSendId;
            parameters[1].Value  = model.FmImgId;
            parameters[2].Value  = model.WxSuCaiId;
            parameters[3].Value  = model.SendContent;
            parameters[4].Value  = model.InputCode;
            parameters[5].Value  = model.WxSendTitle;
            parameters[6].Value  = model.CreateTime;
            parameters[7].Value  = model.CreateUser;
            parameters[8].Value  = model.WxSendType;
            parameters[9].Value  = model.WxSendClassId;
            parameters[10].Value = model.WxPtId;
            parameters[11].Value = model.Memo; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }