示例#1
0
 /// <summary>
 /// 发送通知提醒
 /// </summary>
 /// <param name="AccountId">接收人ID</param>
 /// <param name="Creater">发送人ID</param>
 /// <param name="PartitionId">接收人所属大区ID</param>
 /// <param name="Title">通知标题</param>
 /// <param name="Content">通知内容</param>
 /// <returns>返回是否发送成功 值:true false</returns>
 public static bool sendMsg(int AccountId, int Creater, int PartitionId, string Title, string Content)
 {
     Sys_Message model = new Sys_Message();
     model.AccountId = AccountId;
     model.Creater = Creater;
     model.PartitionId = PartitionId;
     model.Title = Title;
     model.Content = Content;
     model.Status = 0;
     model.Display = true;
     model.Delflag = false;
     model.CreateDate = DateTime.Now;
     return bll.AddMessage(model);
 }
示例#2
0
 /// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(Sys_Message model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("insert into [dbo].[Sys_Message] ([Title],[Content],[AccountId],[Creater],[Status],[Display],[Delflag],[CreateDate])");
     sql.Append(" values (@Title,@Content,@AccountId,@Creater,@Status,@Display,@Delflag,@CreateDate)");
     sql.Append(" set @Id=@@IDENTITY");
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id, Direction = ParameterDirection.Output },
         new SqlParameter("@Title", SqlDbType.VarChar, 50) { Value = model.Title },
         new SqlParameter("@Content", SqlDbType.VarChar, 500) { Value = model.Content },
         new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = model.AccountId },
         new SqlParameter("@Creater", SqlDbType.Int, 4) { Value = model.Creater },
         new SqlParameter("@Status", SqlDbType.Int, 4) { Value = model.Status },
         new SqlParameter("@Display", SqlDbType.Bit, 1) { Value = model.Display },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate }
     };
     int result = Convert.ToInt32(MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams));
     model.Id = Convert.ToInt32(cmdParams[0].Value);
     return result;
 }
示例#3
0
        public bool AddMessage(Sys_Message model)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append(" insert into dbo.Sys_Message (Title,Content,AccountId,Creater,Status,Display,Delflag,CreateDate,PartitionId) ");
            sql.Append(" values (@Title,@Content,@AccountId,@Creater,@Status,@Display,@Delflag,@CreateDate,@PartitionId)");
            SqlParameter[] para ={
                                        new SqlParameter("@Title",SqlDbType.VarChar),
                                        new SqlParameter("@Content",SqlDbType.VarChar),
                                        new SqlParameter("@AccountId",SqlDbType.Int),
                                        new SqlParameter("@Creater",SqlDbType.Int),
                                        new SqlParameter("@Status",SqlDbType.Int),
                                        new SqlParameter("@Display",SqlDbType.Bit),
                                        new SqlParameter("@Delflag",SqlDbType.Bit),
                                        new SqlParameter("@CreateDate",SqlDbType.DateTime),
                                        new SqlParameter("@PartitionId",SqlDbType.Int)
                                 };
            para[0].Value = model.Title;
            para[1].Value = model.Content;
            para[2].Value = model.AccountId;
            para[3].Value = model.Creater;
            para[4].Value = model.Status;
            para[5].Value = model.Display;
            para[6].Value = model.Delflag;
            para[7].Value = model.CreateDate;
            para[8].Value = model.PartitionId;

            int i = MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), para);
            if (i > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
示例#4
0
        private void ConvertToModel(IDataReader reader, Sys_Message model)
        {
            if (reader["Id"] != DBNull.Value)
                model.Id = Convert.ToInt32(reader["Id"]);

            if (reader["Title"] != DBNull.Value)
                model.Title = reader["Title"].ToString();

            if (reader["Content"] != DBNull.Value)
                model.Content = reader["Content"].ToString();

            if (reader["AccountId"] != DBNull.Value)
                model.AccountId = Convert.ToInt32(reader["AccountId"]);

            if (reader["Creater"] != DBNull.Value)
                model.Creater = Convert.ToInt32(reader["Creater"]);

            if (reader["Status"] != DBNull.Value)
                model.Status = Convert.ToInt32(reader["Status"]);

            if (reader["Display"] != DBNull.Value)
                model.Display = Convert.ToBoolean(reader["Display"]);

            if (reader["Delflag"] != DBNull.Value)
                model.Delflag = Convert.ToBoolean(reader["Delflag"]);

            if (reader["CreateDate"] != DBNull.Value)
                model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);

            if (reader["NickName"] != DBNull.Value)
                model.NickName = reader["NickName"].ToString();
        }
示例#5
0
 /// <summary>
 /// 更新一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(Sys_Message model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update [dbo].[Sys_Message] set ");
     sql.Append("[Title]=@Title,[Content]=@Content,[AccountId]=@AccountId,[Creater]=@Creater,[Status]=@Status,[Display]=@Display,[Delflag]=@Delflag,[CreateDate]=@CreateDate");
     sql.Append(" where [Id]=@Id");
     SqlParameter[] cmdParams = new SqlParameter[] {
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id },
         new SqlParameter("@Title", SqlDbType.VarChar, 50) { Value = model.Title },
         new SqlParameter("@Content", SqlDbType.VarChar, 500) { Value = model.Content },
         new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = model.AccountId },
         new SqlParameter("@Creater", SqlDbType.Int, 4) { Value = model.Creater },
         new SqlParameter("@Status", SqlDbType.Int, 4) { Value = model.Status },
         new SqlParameter("@Display", SqlDbType.Bit, 1) { Value = model.Display },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate }
     };
     return MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams);
 }
示例#6
0
 /// <summary>
 /// 取得一条记录
 /// </summary>
 /// <param name="id"></param>
 /// <param name="where"></param>
 /// <returns></returns>
 public Sys_Message GetModel(int id, string where)
 {
     string sql = "select b.NickName,a.* from [dbo].[Sys_Message] a left join Member_Account b on a.AccountId = b.Id where a.Id=@Id";
     if (!string.IsNullOrEmpty(where))
         sql += " and " + where;
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = id }
     };
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql, cmdParams))
     {
         if (reader.Read())
         {
             Sys_Message model = new Sys_Message();
             ConvertToModel(reader, model);
             return model;
         }
         else
         {
             return null;
         }
     }
 }
示例#7
0
 /// <summary>
 /// 获取分页数据集
 /// </summary>
 /// <param name="pageSize"></param>
 /// <param name="pageIndex"></param>
 /// <param name="where"></param>
 /// <param name="orderBy"></param>
 /// <param name="recordCount"></param>
 /// <returns></returns>
 public List<Sys_Message> GetList(int pageSize, int pageIndex, string where, string orderBy, out int recordCount)
 {
     if (string.IsNullOrEmpty(orderBy))
         throw new ArgumentNullException();
     StringBuilder sb = new StringBuilder();
     sb.Append("select count(1) from [dbo].[Sys_Message] a left join Member_Account b on a.AccountId = b.Id ");
     if (!string.IsNullOrEmpty(where))
         sb.Append(" where " + where);
     recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString()));
     int start = (pageIndex - 1) * pageSize + 1;
     int end = pageIndex * pageSize;
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from (select b.NickName,a.*,ROW_NUMBER() over (order by " + orderBy + ") as RowNum from [dbo].[Sys_Message] a left join Member_Account b on a.AccountId = b.Id");
     if (!string.IsNullOrEmpty(where))
         sql.Append(" where " + where);
     sql.Append(")as T where RowNum between @start and @end");
     SqlParameter[] para ={
                             new SqlParameter("@start",start),
                             new SqlParameter("@end",end)
                          };
     List<Sys_Message> list = new List<Sys_Message>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString(),para))
     {
         while (reader.Read())
         {
             Sys_Message model = new Sys_Message();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
示例#8
0
 /// <summary>
 /// 获取数据集
 /// </summary>
 /// <param name="where"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public List<Sys_Message> GetList(string where, string orderBy)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from [dbo].[Sys_Message]");
     if (!string.IsNullOrEmpty(where))
         sql.Append(" where " + where);
     if (!string.IsNullOrEmpty(orderBy))
         sql.Append(" order by " + orderBy);
     List<Sys_Message> list = new List<Sys_Message>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString()))
     {
         while (reader.Read())
         {
             Sys_Message model = new Sys_Message();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
示例#9
0
 /// <summary>
 /// 更新一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(Sys_Message model)
 {
     return dal.Update(model) > 0;
 }
示例#10
0
 public bool AddMessage(Sys_Message model)
 {
     return dal.AddMessage(model);
 }
示例#11
0
 /// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Add(Sys_Message model)
 {
     return dal.Add(model) > 0;
 }