Example #1
0
 public bool GetDeps(bool isWithIntro)
 {
     if (isWithIntro)
     {
         dalBase.sql = "SELECT * FROM db_department WHERE depid!=1";
     }
     else
     {
         dalBase.sql = "SELECT depid,depname FROM db_department WHERE depid!=1";
     }
     if (dalBase.Run(Behavious.SELECT_WITHOUT_PARAM, false))
     {
         while (dalBase.DataRead.Read())
         {
             depInfo = new Department()
             {
                 ID = Convert.ToInt32(dalBase.DataRead["depid"]),
                 Name = dalBase.DataRead["depname"].ToString()
             };
             if (isWithIntro)
             {
                 depInfo.Introduce = dalBase.DataRead["depintroduction"].ToString();
                 depInfo.WeiboId = dalBase.DataRead["weiboId"].ToString();
             }
             list_DepInfo.Add(depInfo);
         }
         dalBase.CloseConnect();
         return true;
     }
     else
     {
         dalBase.CloseConnect();
         return false;
     }
 }
 private void SetValue(HttpRequestBase req,Department dep)
 {
     dep.Name = req.Form["name"].ToString();
     dep.Introduce = req.Form["introduce"].ToString();
 }
 public ResponseStatus GetDepartment(int id, Department notice)
 {
     return service.GetSingle(id,
         () => notice,
         () => new DepDAL());
 }
Example #4
0
        public override ResponseStatus GetSingle(int id, object obj)
        {
            if (!(obj is Department)) return ResponseStatus.FAILED;
            depInfo = (Department)obj;

            dalBase.sql = "SELECT * FROM db_department WHERE depid=@depid";
            dalBase.Param = new MySqlParameter("@depid", id);
            bool isSuccess = dalBase.Run(Behavious.SELECT_WITH_SINGLEPARAM, false);
            return this.JudgeDBResult(isSuccess,
                ()=>
                {
                        dalBase.DataRead.Read();
                        depInfo.ID = Convert.ToInt32(dalBase.DataRead["depid"]);
                        depInfo.Name = dalBase.DataRead["depname"].ToString();
                        depInfo.Introduce = dalBase.DataRead["depintroduction"].ToString();
                },null);
        }
Example #5
0
 public override ResponseStatus GetMuti(object list_obj, Paginate paginate)
 {
     if (!(list_obj is List<Department>)) return ResponseStatus.FAILED;
     List<Department> list_Dep = (List<Department>)list_obj;
      	        dalBase.sql = "SELECT * FROM db_department";
     bool isSuccess = dalBase.Run(Behavious.SELECT_WITHOUT_PARAM, false);
     return this.JudgeDBResult(isSuccess,
         ()=>
         {
             while (dalBase.DataRead.Read())
             {
                 depInfo = new Department()
                 {
                     ID = Convert.ToInt32(dalBase.DataRead["depid"]),
                     Name = dalBase.DataRead["depname"].ToString(),
                     Introduce = dalBase.DataRead["depintroduction"].ToString(),
                     WeiboId = dalBase.DataRead["weiboId"] != DBNull.Value?
                         dalBase.DataRead["weiboId"].ToString():"0"
                 };
                 list_Dep.Add(depInfo);
             }
         },null);
 }