public int UpdateLableDetail(T_LableDetail model)
 {
     using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr))
     {
         string updateSql = "UPDATE T_LableDetail SET parentID=@parentID,lable=@lable WHERE id=@id;";
         return(conn.Execute(updateSql, model));
     }
 }
 public int SaveLableDetail(T_LableDetail model)
 {
     using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr))
     {
         string addSQL = @"INSERT INTO T_LableDetail (parentID,lable,createTime,updateTime) VALUE (@parentID,@lable,@createTime,@updateTime);";
         return(conn.Execute(addSQL, model));
     }
 }
        public ActionResult EditDetail(int pid, int id)
        {
            T_LableDetail lable = this._lable.GetLableDetail(id);

            if (null == lable)
            {
                lable = new T_LableDetail();
            }
            lable.parentID = pid;
            return(View(lable));
        }
        public ActionResult SaveLableDetail(T_LableDetail model)
        {
            int result = 0;

            if (model.id == 0)
            {
                model.createTime = DateTime.Now;
                model.updateTime = DateTime.Now;
                result           = this._lable.SaveLableDetail(model);
            }
            else
            {
                result = this._lable.UpdateLableDetail(model);
            }
            return(Response(result));
        }
        public ActionResult GetDetailPageList(string pagination, int pid)
        {
            Pagination    paginationobj = pagination.ToObject <Pagination>();
            T_LableDetail lable         = new T_LableDetail();

            lable.pageIndex  = paginationobj.page;
            lable.pageSize   = paginationobj.rows;
            lable.totalCount = paginationobj.total;
            lable.orderBy    = paginationobj.sidx + " " + paginationobj.sord;
            lable.parentID   = pid;
            List <T_LableDetail> list = this._lable.GetlableDetailPage(lable);
            var jsonData = new
            {
                rows    = list,
                total   = list.Count > 0 ? list[0].total : 0,
                page    = paginationobj.page,
                records = list.Count > 0 ? list[0].totalCount : 0
            };

            return(Success(jsonData));
        }
        public List <T_LableDetail> GetlableDetailPage(T_LableDetail model)
        {
            using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr))
            {
                DynamicParameters param = new DynamicParameters();
                StringBuilder     sb    = new StringBuilder();
                sb.Append("SELECT * FROM T_LableDetail where parentid= @pid");
                param.Add("@pid", model.parentID);

                string sqlCount = sb.ToString().Replace("SELECT * ", "SELECT COUNT(1) totalCount ");
                var    list     = conn.Query <T_LableDetail>(sb.ToString(), param).ToList();
                if (list != null && list.Count() > 0)
                {
                    dynamic identity = conn.Query(sqlCount, param).Single();
                    list[0].totalCount = Convert.ToInt64(identity.totalCount);
                    list[0].pageIndex  = model.pageIndex;
                    list[0].pageSize   = model.pageSize;
                }
                return(list);
            }
        }