Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LingLong.Admin.Model.t_templatemessage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_templatemessage set ");
            strSql.Append("Type=@Type,");
            strSql.Append("OpenId=@OpenId,");
            strSql.Append("Message=@Message,");
            strSql.Append("IsDeleted=@IsDeleted,");
            strSql.Append("DeleterUserId=@DeleterUserId,");
            strSql.Append("LastModificationTime=@LastModificationTime,");
            strSql.Append("LastModifierUserId=@LastModifierUserId,");
            strSql.Append("CreationTime=@CreationTime");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Type",                 MySqlDbType.Int16,      4),
                new MySqlParameter("@OpenId",               MySqlDbType.LongText),
                new MySqlParameter("@Message",              MySqlDbType.LongText),
                new MySqlParameter("@IsDeleted",            MySqlDbType.Int16,      4),
                new MySqlParameter("@DeleterUserId",        MySqlDbType.Int64,     20),
                new MySqlParameter("@LastModificationTime", MySqlDbType.DateTime),
                new MySqlParameter("@LastModifierUserId",   MySqlDbType.Int64,     20),
                new MySqlParameter("@CreationTime",         MySqlDbType.DateTime),
                new MySqlParameter("@ID",                   MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.Type;
            parameters[1].Value = model.OpenId;
            parameters[2].Value = model.Message;
            parameters[3].Value = model.IsDeleted;
            parameters[4].Value = model.DeleterUserId;
            parameters[5].Value = model.LastModificationTime;
            parameters[6].Value = model.LastModifierUserId;
            parameters[7].Value = model.CreationTime;
            parameters[8].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LingLong.Admin.Model.t_templatemessage DataRowToModel(DataRow row)
 {
     LingLong.Admin.Model.t_templatemessage model = new LingLong.Admin.Model.t_templatemessage();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
         if (row["OpenId"] != null)
         {
             model.OpenId = row["OpenId"].ToString();
         }
         if (row["Message"] != null)
         {
             model.Message = row["Message"].ToString();
         }
         if (row["IsDeleted"] != null && row["IsDeleted"].ToString() != "")
         {
             model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
         }
         if (row["DeleterUserId"] != null && row["DeleterUserId"].ToString() != "")
         {
             model.DeleterUserId = long.Parse(row["DeleterUserId"].ToString());
         }
         if (row["LastModificationTime"] != null && row["LastModificationTime"].ToString() != "")
         {
             model.LastModificationTime = DateTime.Parse(row["LastModificationTime"].ToString());
         }
         if (row["LastModifierUserId"] != null && row["LastModifierUserId"].ToString() != "")
         {
             model.LastModifierUserId = long.Parse(row["LastModifierUserId"].ToString());
         }
         if (row["CreationTime"] != null && row["CreationTime"].ToString() != "")
         {
             model.CreationTime = DateTime.Parse(row["CreationTime"].ToString());
         }
     }
     return(model);
 }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LingLong.Admin.Model.t_templatemessage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_templatemessage(");
            strSql.Append("Type,OpenId,Message,IsDeleted,DeleterUserId,LastModificationTime,LastModifierUserId,CreationTime)");
            strSql.Append(" values (");
            strSql.Append("@Type,@OpenId,@Message,@IsDeleted,@DeleterUserId,@LastModificationTime,@LastModifierUserId,@CreationTime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Type",                 MySqlDbType.Int16,      4),
                new MySqlParameter("@OpenId",               MySqlDbType.LongText),
                new MySqlParameter("@Message",              MySqlDbType.LongText),
                new MySqlParameter("@IsDeleted",            MySqlDbType.Int16,      4),
                new MySqlParameter("@DeleterUserId",        MySqlDbType.Int64,     20),
                new MySqlParameter("@LastModificationTime", MySqlDbType.DateTime),
                new MySqlParameter("@LastModifierUserId",   MySqlDbType.Int64,     20),
                new MySqlParameter("@CreationTime",         MySqlDbType.DateTime)
            };
            parameters[0].Value = model.Type;
            parameters[1].Value = model.OpenId;
            parameters[2].Value = model.Message;
            parameters[3].Value = model.IsDeleted;
            parameters[4].Value = model.DeleterUserId;
            parameters[5].Value = model.LastModificationTime;
            parameters[6].Value = model.LastModifierUserId;
            parameters[7].Value = model.CreationTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LingLong.Admin.Model.t_templatemessage GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,Type,OpenId,Message,IsDeleted,DeleterUserId,LastModificationTime,LastModifierUserId,CreationTime from t_templatemessage ");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32)
            };
            parameters[0].Value = ID;

            LingLong.Admin.Model.t_templatemessage model = new LingLong.Admin.Model.t_templatemessage();
            DataSet ds = DbHelperMySql.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(LingLong.Admin.Model.t_templatemessage model)
 {
     //发送消息
     BLL.t_message meaagebll = new BLL.t_message();
     if (model.Type == 1)
     {
         //服务人员 需要门店信息
         BLL.t_business businessbll = new BLL.t_business();
         var            result      = businessbll.GetListOther(string.Format(" b.OpenId='{0}' ", model.OpenId));
         if (result.Tables[0].Rows.Count == 0)
         {
             meaagebll.Add(new Model.t_message
             {
                 StoreId      = 1,
                 SendOpenId   = "System",
                 SendUserId   = 1,
                 AcceptOpenId = model.OpenId,
                 AcceptUserId = 1,
                 Content      = model.Message,
                 MessageType  = 0,
                 SendTime     = DateTime.Now,
                 State        = 0,
                 IsDeleted    = 0,
                 CreationTime = DateTime.Now
             });
         }
         else
         {
             for (int i = 0; i < result.Tables[0].Rows.Count; i++)
             {
                 var openid  = result.Tables[0].Rows[i]["OpenId"].ToString();
                 var storeid = result.Tables[0].Rows[i]["StoreId"].ToString();
                 var id      = result.Tables[0].Rows[i]["BusinessId"].ToString();
                 meaagebll.Add(new Model.t_message
                 {
                     StoreId      = int.Parse(storeid),
                     SendOpenId   = "System",
                     SendUserId   = 1,
                     AcceptOpenId = openid,
                     AcceptUserId = int.Parse(id),
                     Content      = model.Message,
                     MessageType  = 0,
                     SendTime     = DateTime.Now,
                     State        = 0,
                     IsDeleted    = 0,
                     CreationTime = DateTime.Now
                 });
             }
         }
     }
     if (model.Type == 2)
     {
         //客户
         BLL.t_customer customerbll = new BLL.t_customer();
         var            result      = customerbll.GetList(" IsDeleted=0 and CustomerType=0");
         for (int i = 0; i < result.Tables[0].Rows.Count; i++)
         {
             var openid = result.Tables[0].Rows[i]["OpenId"].ToString();
             var id     = result.Tables[0].Rows[i]["ID"].ToString();
             meaagebll.Add(new Model.t_message
             {
                 StoreId      = 1,
                 SendOpenId   = "System",
                 SendUserId   = 1,
                 AcceptOpenId = openid,
                 AcceptUserId = int.Parse(id),
                 Content      = model.Message,
                 MessageType  = 0,
                 SendTime     = DateTime.Now,
                 State        = 0,
                 IsDeleted    = 0,
                 CreationTime = DateTime.Now
             });
         }
     }
     if (model.Type == 3)
     {
         //服务人员 需要门店信息
         BLL.t_business businessbll = new BLL.t_business();
         var            result      = businessbll.GetListOther("");
         for (int i = 0; i < result.Tables[0].Rows.Count; i++)
         {
             var openid  = result.Tables[0].Rows[i]["OpenId"].ToString();
             var storeid = result.Tables[0].Rows[i]["StoreId"].ToString();
             var id      = result.Tables[0].Rows[i]["BusinessId"].ToString();
             meaagebll.Add(new Model.t_message
             {
                 StoreId      = int.Parse(storeid),
                 SendOpenId   = "System",
                 SendUserId   = 1,
                 AcceptOpenId = openid,
                 AcceptUserId = int.Parse(id),
                 Content      = model.Message,
                 MessageType  = 0,
                 SendTime     = DateTime.Now,
                 State        = 0,
                 IsDeleted    = 0,
                 CreationTime = DateTime.Now
             });
         }
     }
     return(dal.Add(model));
 }
Example #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LingLong.Admin.Model.t_templatemessage model)
 {
     return(dal.Update(model));
 }