Exemple #1
0
        public JsonResult AddRotation(RotationChartViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (ModelState.IsValid)
            {
                RotationChart downModel = new RotationChart()
                {
                    ImgSrc  = model.HeadImg,
                    Type    = model.RotationType,
                    WebLink = model.WebLink,
                    State   = PublishState.Upper
                };


                List <RotationChart> rlist = rotationService.GetAll(model.RotationType);
                if (rlist != null && model.RotationType == RotationType.Banner && rlist.Count >= 5)
                {
                    rmodel.message = "最多添加Banner轮播不可超过5条";
                    return(Json(rmodel));
                }

                if (rlist != null && model.RotationType == RotationType.Logo && rlist.Count >= 20)
                {
                    rmodel.message = "最多添加Logo轮播不可超过20条";
                    return(Json(rmodel));
                }

                rmodel.isSuccess = rotationService.Add(downModel);
            }

            return(Json(rmodel));
        }
Exemple #2
0
        public bool Update(RotationChart rotationChartInfo)
        {
            //参数验证
            if (rotationChartInfo == null)
            {
                ErrorMsg = ErrorCode.ParameterNull;
                return(false);
            }

            return(_rotationChartProvider.Update(rotationChartInfo));
        }
Exemple #3
0
        /// <summary>
        /// 从游标中读取数据
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private RotationChart GetRotationChartFromReader(DbDataReader reader)
        {
            RotationChart rotationInfo = new RotationChart();

            rotationInfo.Id         = Convert.ToInt32(reader["Id"]);
            rotationInfo.WebLink    = reader["WebLink"].ToString();
            rotationInfo.Type       = (RotationType)reader["Type"];
            rotationInfo.ImgSrc     = reader["ImgSrc"].ToString();
            rotationInfo.State      = Convert.ToInt32(reader["State"]) < 1 ? PublishState.Lower : PublishState.Upper;
            rotationInfo.CreateDate = Convert.ToDateTime(reader["CreateDate"]);

            return(rotationInfo);
        }
Exemple #4
0
        public RotationChart Get(int id)
        {
            //参数验证
            if (id < 1)
            {
                ErrorMsg = ErrorCode.ParameterNull;
                return(null);
            }

            //数据获取
            RotationChart rotationChartInfo = _rotationChartProvider.Get(id);

            return(rotationChartInfo);
        }
Exemple #5
0
        public JsonResult EditRotation(RotationChartViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (ModelState.IsValid)
            {
                RotationChart data = rotationService.Get(model.Id);
                data.ImgSrc  = model.HeadImg;
                data.Type    = model.RotationType;
                data.WebLink = model.WebLink;

                rmodel.isSuccess = rotationService.Update(data);
            }

            return(Json(rmodel));
        }
Exemple #6
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult EditRotation(int id)
        {
            RotationChart model = rotationService.Get(id);

            if (model != null)
            {
                return(View(new RotationChartViewModel()
                {
                    Id = model.Id,
                    HeadImg = model.ImgSrc,
                    WebLink = model.WebLink,
                    RotationType = model.Type,
                    SmallHeadImg = GetThumb(model.ImgSrc)
                }));
            }
            return(View());
        }
Exemple #7
0
        /// <summary>
        /// 根据ID获取轮播信息
        /// </summary>
        /// <param name="id">轮播ID</param>
        /// <returns>轮播信息</returns>
        public RotationChart Get(int id)
        {
            RotationChart rotationInfo = null;
            DBHelper      dbHelper     = new DBHelper(ConnectionString, DbProviderType.SqlServer);
            string        strSql       = @"SELECT Id, ImgSrc, WebLink, State, Type, CreateDate from RotationChart where IsDeleted=0 and id=@Id ";

            List <DbParameter> parametersList = new List <DbParameter>();

            parametersList.Add(new SqlParameter("@Id", id));

            using (DbDataReader reader = dbHelper.ExecuteReader(strSql, parametersList))
            {
                while (reader.Read())
                {
                    rotationInfo = GetRotationChartFromReader(reader);
                }
            }

            return(rotationInfo);
        }
Exemple #8
0
        /// <summary>
        /// 修改轮播
        /// </summary>
        /// <param name="rotationInfo">轮播信息</param>
        /// <returns>修改成功标识</returns>
        public bool Update(RotationChart rotationInfo)
        {
            DBHelper dbHelper = new DBHelper(ConnectionString, DbProviderType.SqlServer);
            string   strSql   = @"Update RotationChart
                              Set [ImgSrc]=@ImgSrc
                                  ,[WebLink]=@WebLink
                                  ,[State]=@State
                                  ,[Type]=@Type
                                  Where ID=@ID";

            List <DbParameter> parametersList = new List <DbParameter>();

            parametersList.Add(new SqlParameter("@ID", rotationInfo.Id));
            parametersList.Add(new SqlParameter("@ImgSrc", rotationInfo.ImgSrc));
            parametersList.Add(new SqlParameter("@WebLink", rotationInfo.WebLink));
            parametersList.Add(new SqlParameter("@State", (int)rotationInfo.State));
            parametersList.Add(new SqlParameter("@Type", (int)rotationInfo.Type));

            return(dbHelper.ExecuteNonQuery(strSql, parametersList) > 0);
        }
Exemple #9
0
        public bool Add(RotationChart rotationChartInfo)
        {
            //参数验证
            if (rotationChartInfo == null)
            {
                ErrorMsg = ErrorCode.ParameterNull;
                return(false);
            }

            bool isSuccess = _rotationChartProvider.Add(rotationChartInfo);

            if (isSuccess)
            {
                try
                {
                    List <RotationSort> sortList = GetRotationSorts();
                    if (sortList.Find(g => g.RotationType == rotationChartInfo.Type) != null)
                    {
                        sortList.Find(g => g.RotationType == rotationChartInfo.Type).SortList.Add(rotationChartInfo.Id);
                    }
                    else
                    {
                        sortList.Add(new RotationSort()
                        {
                            RotationType = rotationChartInfo.Type, SortList = new List <int>()
                            {
                                rotationChartInfo.Id
                            }
                        });
                    }

                    UpdateRotationSort(sortList);
                }
                catch
                {
                }
            }

            return(isSuccess);
        }
Exemple #10
0
        /// <summary>
        /// 获取所有轮播信息
        /// </summary>
        /// <param name="condition">筛选条件</param>
        /// <returns>轮播集合</returns>
        public List <RotationChart> GetAll(FilterEntityModel condition)
        {
            string whereSort = string.Empty;

            if (condition != null)
            {
                condition.DefaultSort = SortType.Desc;
                whereSort             = condition.Where + condition.OrderBy;
            }

            List <RotationChart> rotationList = null;
            DBHelper             dbHelper     = new DBHelper(ConnectionString, DbProviderType.SqlServer);

            string strSql = @"SELECT Id, ImgSrc, WebLink, State, Type, CreateDate from RotationChart where IsDeleted=0 " + whereSort;

            IList <DbParameter> parameList = null;

            if (condition != null && condition.SqlParList.Count > 0)
            {
                parameList = new List <DbParameter>();
                foreach (var item in condition.SqlParList)
                {
                    parameList.Add(new SqlParameter(item.Key, item.Value));
                }
            }

            using (DbDataReader reader = dbHelper.ExecuteReader(strSql, parameList))
            {
                rotationList = new List <RotationChart>();
                RotationChart rotationInfo = null;
                while (reader.Read())
                {
                    rotationInfo = GetRotationChartFromReader(reader);
                    rotationList.Add(rotationInfo);
                }
            }

            return(rotationList);
        }
Exemple #11
0
        /// <summary>
        /// 添加轮播
        /// </summary>
        /// <param name="rotationInfo">轮播信息</param>
        /// <returns>添加成功标识</returns>
        public bool Add(RotationChart rotationInfo)
        {
            bool     isSuccess = false;
            DBHelper dbHelper  = new DBHelper(ConnectionString, DbProviderType.SqlServer);
            string   strSql    = @"Insert Into RotationChart (ImgSrc, WebLink, State, Type) Values (@ImgSrc, @WebLink, @State, @Type);select SCOPE_IDENTITY()";

            List <DbParameter> parametersList = new List <DbParameter>();

            parametersList.Add(new SqlParameter("@ImgSrc", rotationInfo.ImgSrc));
            parametersList.Add(new SqlParameter("@WebLink", rotationInfo.WebLink));
            parametersList.Add(new SqlParameter("@State", (int)rotationInfo.State));
            parametersList.Add(new SqlParameter("@Type", (int)rotationInfo.Type));

            int iResultInsert = Convert.ToInt32(dbHelper.ExecuteScalar(strSql, parametersList));

            if (iResultInsert > 0)
            {
                //若成功,则记录成功信息:患者信息,发卡时间,索引信息
                rotationInfo.Id = iResultInsert;
                isSuccess       = true;
            }

            return(isSuccess);
        }
Exemple #12
0
        public async Task <IActionResult> Edit(int id)
        {
            RotationChart result = await _bll.GetById(id);

            return(PartialView(result));
        }