コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJSLog.Model.SmsSendLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SmsSendLog(");
            strSql.Append("SendResult,SmsTemplateId,SendType,SmsContent,Mobile,Status,IsDeleted,CreateDate,SendDate");
            strSql.Append(") values (");
            strSql.Append("@SendResult,@SmsTemplateId,@SendType,@SmsContent,@Mobile,@Status,@IsDeleted,@CreateDate,@SendDate");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SendResult",    model.SendResult),
                new SqlParameter("@SmsTemplateId", model.SmsTemplateId),
                new SqlParameter("@SendType",      model.SendType),
                new SqlParameter("@SmsContent",    model.SmsContent),
                new SqlParameter("@Mobile",        model.Mobile),
                new SqlParameter("@Status",        model.Status),
                new SqlParameter("@IsDeleted",     model.IsDeleted),
                new SqlParameter("@CreateDate",    model.CreateDate),
                new SqlParameter("@SendDate",      model.SendDate)
            };


            object obj = BWJSLogHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJSLog.Model.SmsSendLog GetModel(int SmsLogId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SmsLogId, SendResult, SmsTemplateId, SendType, SmsContent, Mobile, Status, IsDeleted, CreateDate, SendDate  ");
            strSql.Append("  from SmsSendLog ");
            strSql.Append(" where SmsLogId=@SmsLogId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SmsLogId", SqlDbType.Int, 4)
            };
            parameters[0].Value = SmsLogId;


            BWJSLog.Model.SmsSendLog model = new BWJSLog.Model.SmsSendLog();
            DataSet ds = BWJSLogHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJSLog.Model.SmsSendLog DataRowToModel(DataRow row)
        {
            BWJSLog.Model.SmsSendLog model = new BWJSLog.Model.SmsSendLog();

            if (row != null)
            {
                if (row["SmsLogId"].ToString() != "")
                {
                    model.SmsLogId = int.Parse(row["SmsLogId"].ToString());
                }
                model.SendResult = row["SendResult"].ToString();
                if (row["SmsTemplateId"].ToString() != "")
                {
                    model.SmsTemplateId = int.Parse(row["SmsTemplateId"].ToString());
                }
                if (row["SendType"].ToString() != "")
                {
                    model.SendType = int.Parse(row["SendType"].ToString());
                }
                model.SmsContent = row["SmsContent"].ToString();
                model.Mobile     = row["Mobile"].ToString();
                if (row["Status"].ToString() != "")
                {
                    model.Status = int.Parse(row["Status"].ToString());
                }
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                if (row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["SendDate"].ToString() != "")
                {
                    model.SendDate = DateTime.Parse(row["SendDate"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJSLog.Model.SmsSendLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SmsSendLog set ");

            strSql.Append(" SendResult = @SendResult , ");
            strSql.Append(" SmsTemplateId = @SmsTemplateId , ");
            strSql.Append(" SendType = @SendType , ");
            strSql.Append(" SmsContent = @SmsContent , ");
            strSql.Append(" Mobile = @Mobile , ");
            strSql.Append(" Status = @Status , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" CreateDate = @CreateDate , ");
            strSql.Append(" SendDate = @SendDate  ");
            strSql.Append(" where SmsLogId=@SmsLogId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@SmsLogId",      model.SmsLogId),
                new SqlParameter("@SendResult",    model.SendResult),
                new SqlParameter("@SmsTemplateId", model.SmsTemplateId),
                new SqlParameter("@SendType",      model.SendType),
                new SqlParameter("@SmsContent",    model.SmsContent),
                new SqlParameter("@Mobile",        model.Mobile),
                new SqlParameter("@Status",        model.Status),
                new SqlParameter("@IsDeleted",     model.IsDeleted),
                new SqlParameter("@CreateDate",    model.CreateDate),
                new SqlParameter("@SendDate",      model.SendDate)
            };

            int rows = BWJSLogHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }