149 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			149 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
using System.Collections;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// 工种表
 | 
						|
    /// </summary>
 | 
						|
   public static class PostService
 | 
						|
    {
 | 
						|
       public static Model.SGGLDB db = Funs.DB;
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 记录数
 | 
						|
       /// </summary>
 | 
						|
       private static int count
 | 
						|
       {
 | 
						|
           get;
 | 
						|
           set;
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 获取分页列表
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="postName"></param>
 | 
						|
       /// <param name="startRowIndex"></param>
 | 
						|
       /// <param name="maximumRows"></param>
 | 
						|
       /// <returns></returns>
 | 
						|
       public static IEnumerable GetListData(string postName, int startRowIndex, int maximumRows)
 | 
						|
       {
 | 
						|
           IQueryable<Model.Base_Post> q = from x in db.Base_Post orderby x.PostName select x;
 | 
						|
           if (!string.IsNullOrEmpty(postName))
 | 
						|
           {
 | 
						|
               q = q.Where(e => e.PostName.Contains(postName));
 | 
						|
           }
 | 
						|
           count = q.Count();
 | 
						|
           if (count==0)
 | 
						|
           {
 | 
						|
               return new object[] { "" };
 | 
						|
           }
 | 
						|
           return from x in q.Skip(startRowIndex).Take(maximumRows)
 | 
						|
                  select new
 | 
						|
                  {
 | 
						|
                      x.PostId,
 | 
						|
                      x.PostName,
 | 
						|
                      x.Remark
 | 
						|
                  };
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 获取分页列表数
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="postName"></param>
 | 
						|
       /// <returns></returns>
 | 
						|
       public static int GetListCount(string postName)
 | 
						|
       {
 | 
						|
           return count;
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 根据主键获取岗位信息
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="postId"></param>
 | 
						|
       /// <returns></returns>
 | 
						|
       public static Model.Base_Post GetPostById(string postId)
 | 
						|
       {
 | 
						|
           return Funs.DB.Base_Post.FirstOrDefault(e => e.PostId == postId);
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 添加工种信息
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="post"></param>
 | 
						|
       public static void AddPost(Model.Base_Post post)
 | 
						|
       {
 | 
						|
           Model.SGGLDB db = Funs.DB;
 | 
						|
           Model.Base_Post newPost = new Model.Base_Post();
 | 
						|
           newPost.PostId = post.PostId;
 | 
						|
           newPost.PostName = post.PostName;
 | 
						|
           newPost.Remark = post.Remark;
 | 
						|
           db.Base_Post.InsertOnSubmit(newPost);
 | 
						|
           db.SubmitChanges();
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 修改工种信息
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="post"></param>
 | 
						|
       public static void UpdatePost(Model.Base_Post post)
 | 
						|
       {
 | 
						|
           Model.SGGLDB db = Funs.DB;
 | 
						|
           Model.Base_Post newPost = db.Base_Post.FirstOrDefault(e => e.PostId == post.PostId);
 | 
						|
           if (newPost != null)
 | 
						|
           {
 | 
						|
               newPost.PostName = post.PostName;
 | 
						|
               newPost.Remark = post.Remark;
 | 
						|
               db.SubmitChanges();
 | 
						|
           }
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       /// 根据主键删除工种信息
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="postId"></param>
 | 
						|
       public static void DeletePost(string postId)
 | 
						|
       {
 | 
						|
           Model.SGGLDB db = Funs.DB;
 | 
						|
           Model.Base_Post newPost = db.Base_Post.FirstOrDefault(e => e.PostId == postId);
 | 
						|
           if (newPost != null)
 | 
						|
           {
 | 
						|
               db.Base_Post.DeleteOnSubmit(newPost);
 | 
						|
               db.SubmitChanges();
 | 
						|
           }
 | 
						|
       }
 | 
						|
 | 
						|
       /// <summary>
 | 
						|
       ///  获取工种名称项
 | 
						|
       /// </summary>
 | 
						|
       /// <param name="projectId"></param>
 | 
						|
       /// <returns></returns>
 | 
						|
       public static ListItem[] drpPostNameItemList()
 | 
						|
       {
 | 
						|
           var q = (from x in Funs.DB.Base_Post orderby x.PostName select x).ToList();
 | 
						|
           ListItem[] list = new ListItem[q.Count()];
 | 
						|
           for (int i = 0; i < list.Count(); i++)
 | 
						|
           {
 | 
						|
               list[i] = new ListItem(q[i].PostName ?? "", q[i].PostId);
 | 
						|
           }
 | 
						|
           return list;
 | 
						|
       }
 | 
						|
 | 
						|
        public static void InitPostDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
 | 
						|
        {
 | 
						|
            dropName.DataValueField = "Value";
 | 
						|
            dropName.DataTextField = "Text";
 | 
						|
            dropName.DataSource = drpPostNameItemList();
 | 
						|
            dropName.DataBind();
 | 
						|
            if (isShowPlease)
 | 
						|
            {
 | 
						|
                Funs.FineUIPleaseSelect(dropName);
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |