public ActionResult Create(ModelPictures model, FormCollection fc)
        {
            var resultMsg = string.Empty;
            ViewBag.Categorys = base.QueryCategoryAll(model.Categoryid.ToString());
            ViewBag.CategoryOwner = base.QueryCategoryAll(model.Owner);
            var result = new ResultBase();
            var fileName = CommonMethod.ImageUpload(out result, this.HttpContext);
            if (result.result == -2)
            {
                ViewBag.CustomScript = UtilityScript.ShowMessage(result.resultMsg, isCreate: true);
                return View(model);
            }
            model.Picuri = string.IsNullOrWhiteSpace(fileName) ? model.Picuri : fileName;

            LogicPictures logic = new LogicPictures();
            var res = logic.PicturesInsertUpdate(out resultMsg,base.AuthorizeInfo, model);
            if (res > 0)
            {
                resultMsg = "操作成功!";
                ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true, funName: "Goto");
            }
            else
            {
                resultMsg = "操作失败,请检查数据是否正确后重新操作!";
                ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true, funName: "BtnShow");
            }
            return View(model);
        }
 public ActionResult Create(string Id = null)
 {
     var resultMsg = string.Empty;
     ModelPictures model = new ModelPictures();
     if (string.IsNullOrWhiteSpace(Id))
     {
         ViewBag.Categorys = base.QueryCategoryAll();
         ViewBag.CategoryOwner = base.QueryCategoryAll();
     }
     else
     {
         LogicPictures logic = new LogicPictures();
         model = logic.PicturesDetail(out resultMsg,base.AuthorizeInfo, int.Parse(Id));
         if (model != null)
         {
             ViewBag.Categorys = base.QueryCategoryAll();
             ViewBag.CategoryOwner = base.QueryCategoryAll();
         }
         else
         {
             ViewBag.Categorys = base.QueryCategoryAll(model.Categoryid.ToString());
             ViewBag.CategoryOwner = base.QueryCategoryAll(model.Owner);
         }
     }
     return View(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// ���� ���/����
        /// </summary>
        /// <param name="pictures">ʵ��</param>
        /// <returns>ִ�н��</returns>
        public int PicturesInsertUpdate(out string resultMsg,ModelPictures pictures,DbTransaction tran =null)
        {
            resultMsg = string.Empty;
            int res = 0;
            try
            {
                //�洢��������
                string sql = "USP_PICTURES_INSERT_UPDATE";
                //�������
                IList<DBParameter> parm = new List<DBParameter>();
                parm.Add(new DBParameter() { ParameterName = "ID", ParameterValue = pictures.Id, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });
                parm.Add(new DBParameter() { ParameterName = "NAME", ParameterValue = pictures.Name, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CATEGORYID", ParameterValue = pictures.Categoryid, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });
                parm.Add(new DBParameter() { ParameterName = "OWNER", ParameterValue = pictures.Owner, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });
                parm.Add(new DBParameter() { ParameterName = "PICURI", ParameterValue = pictures.Picuri, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "PICLINK", ParameterValue = pictures.Piclink, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "STATUS", ParameterValue = pictures.Status, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });

                //����/����ִ��
                res = DBHelper.ExecuteNonQuery(sql, true, parm, tran);

            }
            catch (Exception ex)
            {
                if(tran != null)
                    tran.Rollback();
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }
            return res;
        }
Exemplo n.º 4
0
        /// <summary>
        ///  ��ѯʵ��
        /// </summary>
        /// <param name="id">ModelId ���</param>
        /// <returns>ModelPictures</returns>
        public ModelPictures PicturesDetail(out string resultMsg,Int32 id )
        {
            resultMsg = string.Empty;
            var model = new ModelPictures();
            try
            {
                //�洢��������
                string sql = "usp_pictures_select_detail_by_id";

                //�������
                IList<DBParameter> parm = new List<DBParameter>();
                parm.Add(new DBParameter() { ParameterName = "ID", ParameterValue = id, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });

                //��ѯִ��
                using (IDataReader dr = DBHelper.ExecuteReader(sql, true, parm))
                {
                    IList<ModelPictures> list = GetModel(dr);
                    model = list.First();
                }
            }
            catch (Exception ex)
            {
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }
            return model;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Model ��ֵ IDataReader
        /// </summary>
        private IList<ModelPictures> GetModel(IDataReader dr)
        {
            var modelList = new List<ModelPictures>();

            while (dr.Read())
            {
                var model = new ModelPictures();
                model.Id = dr["Id"]== DBNull.Value ? 0 : Convert.ToInt32(dr["Id"]);
                model.Name = dr["Name"] == DBNull.Value ? string.Empty : dr["Name"].ToString();
                model.CategoryName = dr["OwnerCategoryName"] == DBNull.Value ? string.Empty : dr["OwnerCategoryName"].ToString();
                model.OwnerCategoryName = dr["CategoryName"] == DBNull.Value ? string.Empty : dr["CategoryName"].ToString();
                model.Categoryid = dr["CategoryId"]== DBNull.Value ? 0 : Convert.ToInt32(dr["CategoryId"]);
                model.Owner = dr["Owner"]== DBNull.Value ? string.Empty : Convert.ToString(dr["Owner"]);
                model.Picuri = dr["PicUri"]== DBNull.Value ? string.Empty : dr["PicUri"].ToString();
                model.Piclink = dr["PicLink"]== DBNull.Value ? string.Empty : dr["PicLink"].ToString();
                model.Status = dr["Status"]== DBNull.Value ? 0 : Convert.ToInt32(dr["Status"]);
                model.Createdate = dr["CreateDate"]== DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(dr["CreateDate"]);
                modelList.Add(model);
            }
            return modelList;
        }
Exemplo n.º 6
0
        public IList<ModelPictures> QueryPicturesListByOwner(out string resultMsg, string CategoryCode, string ownerCode)
        {
            resultMsg = string.Empty;
            var model = new ModelPictures();
            IList<ModelPictures> list = new List<ModelPictures>();
            try
            {
                //�洢��������
                string sql = "usp_pictures_select_by_owner";

                //�������
                IList<DBParameter> parm = new List<DBParameter>();
                parm.Add(new DBParameter() { ParameterName = "CategoryCode", ParameterValue = CategoryCode, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "OwnerCode", ParameterValue = ownerCode, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });

                //��ѯִ��
                using (IDataReader dr = DBHelper.ExecuteReader(sql, true, parm))
                {
                    list = GetModel(dr);
                }
            }
            catch (Exception ex)
            {
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }
            return list;
        }