Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ShortMsgTempModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_ShortMessage_Template set ");
            strSql.Append("flag=@flag,");
            strSql.Append("templateCode=@templateCode,");
            strSql.Append("templateParam=@templateParam,");
            strSql.Append("supplierId=@supplierId,");
            strSql.Append("supplierFlag=@supplierFlag,");
            strSql.Append("isUse=@isUse");
            strSql.Append(" where templateId=@templateId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@templateId",    SqlDbType.VarChar,  50),
                new SqlParameter("@flag",          SqlDbType.NVarChar, 50),
                new SqlParameter("@templateCode",  SqlDbType.NVarChar, 50),
                new SqlParameter("@templateParam", SqlDbType.NText),
                new SqlParameter("@supplierId",    SqlDbType.VarChar,  50),
                new SqlParameter("@supplierFlag",  SqlDbType.VarChar,  50),
                new SqlParameter("@isUse",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.templateId;
            parameters[1].Value = model.flag;
            parameters[2].Value = model.templateCode;
            parameters[3].Value = model.templateParam;
            parameters[4].Value = model.supplierId;
            parameters[5].Value = model.supplierFlag;
            parameters[6].Value = model.isUse;

            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ShortMsgTempModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_ShortMessage_Template(");
            strSql.Append("templateId,flag,templateCode,templateParam,supplierId,supplierFlag,isUse)");
            strSql.Append(" values (");
            strSql.Append("@templateId,@flag,@templateCode,@templateParam,@supplierId,@supplierFlag,@isUse)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@templateId",    SqlDbType.VarChar,  50),
                new SqlParameter("@flag",          SqlDbType.NVarChar, 50),
                new SqlParameter("@templateCode",  SqlDbType.NVarChar, 50),
                new SqlParameter("@templateParam", SqlDbType.NText),
                new SqlParameter("@supplierId",    SqlDbType.VarChar,  50),
                new SqlParameter("@supplierFlag",  SqlDbType.VarChar,  50),
                new SqlParameter("@isUse",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.templateId;
            parameters[1].Value = model.flag;
            parameters[2].Value = model.templateCode;
            parameters[3].Value = model.templateParam;
            parameters[4].Value = model.supplierId;
            parameters[5].Value = model.supplierFlag;
            parameters[6].Value = model.isUse;

            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShortMsgTempModel DataRowToModel(DataRow row)
        {
            ShortMsgTempModel model = new ShortMsgTempModel();

            if (row != null)
            {
                if (row["templateId"] != null)
                {
                    model.templateId = row["templateId"].ToString();
                }
                if (row["flag"] != null)
                {
                    model.flag = row["flag"].ToString();
                }
                if (row["templateCode"] != null)
                {
                    model.templateCode = row["templateCode"].ToString();
                }
                if (row["templateParam"] != null)
                {
                    model.templateParam = row["templateParam"].ToString();
                }
                if (row["supplierId"] != null)
                {
                    model.supplierId = row["supplierId"].ToString();
                }
                if (row["supplierFlag"] != null)
                {
                    model.supplierFlag = row["supplierFlag"].ToString();
                }
                if (row["isUse"] != null && row["isUse"].ToString() != "")
                {
                    model.isUse = int.Parse(row["isUse"].ToString());
                }
            }
            return(model);
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShortMsgTempModel GetModel(string templateId)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 templateId,flag,templateCode,templateParam,supplierId,supplierFlag,isUse from T_ShortMessage_Template ");
            strSql.Append(" where  templateId=@templateId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@templateId", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = templateId;
            ShortMsgTempModel model = new ShortMsgTempModel();
            DataSet           ds    = adoHelper.ExecuteSqlDataset(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 补充字段
        /// </summary>
        /// <param name="SMS"></param>
        private static void FillFeild(this ShortMsgModel SMS)
        {
            ShortMsgSupBll   supBll = new ShortMsgSupBll();
            ShortMsgSupModel supMod = supBll.GetDefault();

            if (supMod != null) //数据库没有数据
            {
                List <ShortMsgTempModel> tmpList = supMod.tempList;
                SMS.smsSign         = supMod.smsSign;
                SMS.supplier        = supMod.flag;
                SMS.sysnumber       = Guid.NewGuid().ToString();
                SMS.statu           = "sending";
                SMS.accessKeyID     = supMod.accessKeyID;
                SMS.accessKeySecret = supMod.accessKeySecret;

                //sms.flag  为 reg   or  login 注册登陆
                ShortMsgTempModel tmpMod = tmpList.Find(a => a.isUse == 1 && a.flag == SMS.flag);
                if (tmpMod != null)
                {
                    SMS.template      = tmpMod.templateCode;
                    SMS.templateParam = tmpMod.templateParam;
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ShortMsgTempModel model)
 {
     return(dal.Update(model));
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ShortMsgTempModel model)
 {
     return(dal.Add(model));
 }