/// <summary> /// 我的文档 /// </summary> public void MyDoc(int first, string keyword, int?userCataId) { PropertyBag["cur_page_index"] = true; int rows = 10; PropertyBag["cur_page_index"] = true; UserService us = Context.GetService <UserService>(); U_UserInfo logonUser = base.GetUser(); int count = 0; IList <DDocInfo> list = us.DocInfoBll.GetListByUser(logonUser.UserId, out count, first, rows, keyword, userCataId, null); ListPage lp = new ListPage((IList)list, first, rows, count); PropertyBag["lp"] = lp; //总文档量 PropertyBag["allDocCount"] = count; //未分类文档总数 PropertyBag["unCatalogDocCount"] = us.DocInfoBll.GetCataDocCount(logonUser.UserId, 0); //总浏览量 PropertyBag["allViewCount"] = us.DocInfoBll.GetViewCount(logonUser.UserId); //我的文件夹列表 PropertyBag["folders"] = us.MCatalogBll.GetListByUser(logonUser.UserId, 1); if (userCataId.HasValue) { if (userCataId.Value != 0) { MCatalog mc = us.MCatalogBll.Get(userCataId.Value); PropertyBag["mc"] = mc; } } RenderView("mydoc"); }
public ActionResult AddTableCatalog(MCatalog objCatalog) { try { if (ModelState.IsValid) { string mensaje = ""; int resultDb = fnGNTranTableCatalog(objCatalog, "I", ref mensaje); if (resultDb != 0) { TempData["Success"] = mensaje; return(RedirectToAction("AddTableCatalog")); } else { ViewBag.ErrorSave = mensaje; return(View(objCatalog)); } } else { ViewBag.ErrorSave = "Error al grabar, Por favor verifique los datos ingresados."; return(View(objCatalog)); } } catch (Exception ex) { ViewBag.ErrorSave = "Error al grabar datos: " + ex.Message; return(View(objCatalog)); } }
/// <summary> /// 我的收藏 /// </summary> public void MyFav(int first, int?favCataId) { int rows = 10; PropertyBag["cur_page_fav"] = true; UserService us = Context.GetService <UserService>(); U_UserInfo logonUser = base.GetUser(); int count = 0; IList <MFavorite> list = us.MFavoriteBll.GetListByUserId(first, rows, out count, logonUser.UserId, favCataId); ListPage lp = new ListPage((IList)list, first, rows, count); PropertyBag["lp"] = lp; //未分类文档总数 PropertyBag["unCatalogDocCount"] = us.MFavoriteBll.GetCataDocCount(logonUser.UserId, 0); //我的文件夹列表 PropertyBag["folders"] = us.MCatalogBll.GetListByUser(logonUser.UserId, 2); if (favCataId.HasValue) { if (favCataId.Value != 0) { MCatalog mc = us.MCatalogBll.Get(favCataId.Value); PropertyBag["mc"] = mc; } } }
// GET: TableCatalog/AddTableCatalog public ActionResult AddTableCatalog() { if (Session["Usuario"] == null) { return(RedirectToAction("Login", "User")); } var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces; var ObjAcces = ObjAccesUser.Where(p => p.Action == "ListTableCatalog").First(); if (ObjAcces != null) { if (ObjAcces.Create == false) { return(RedirectToAction("Index", "Home")); } } MCatalog objMCatalog = new MCatalog(); objMCatalog.TableDetails = new List <MCatalogDetail>(); if (TempData["Success"] != null) { ViewBag.SuccessSave = TempData["Success"]; } return(View(objMCatalog)); }
public static MCatalog GetMyCatalog(int cataId) { UserService us = new UserService(); us.Initialize(); MCatalog mc = us.MCatalogBll.Get(cataId); return(mc); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(MCatalog obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "MCatalog.Insert"; return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(MCatalog obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "MCatalog.Update"; int result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj); return(result > 0 ? true : false); }
// GET: TableCatalog/EditTableCatalog/5 public ActionResult EditTableCatalog(int?id) { if (Session["Usuario"] == null) { return(RedirectToAction("Login", "User")); } var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces; var ObjAcces = ObjAccesUser.Where(p => p.Action == "ListTableCatalog").First(); if (ObjAcces != null) { if (ObjAcces.Edit == false) { return(RedirectToAction("Index", "Home")); } } //Aqui se trae el modelo enviado por POST desde la Lista, para que no se vea en la Url if (TempData["DataTableCatalog"] != null) { var objTempData = Newtonsoft.Json.JsonConvert.DeserializeObject <MCatalog>((string)TempData["DataTableCatalog"]); if (objTempData != null && objTempData.IdCatalog > 0) { id = objTempData.IdCatalog; } else { return(RedirectToAction("ListTableCatalog", "TableCatalog")); } } if (id == null) { return(RedirectToAction("ListTableCatalog", "TableCatalog")); } //----------------------------------------------------- MCatalog objMCatalog = new MCatalog(); objMCatalog = fnListTableCatalog(id).First(); if (TempData["Success"] != null) { ViewBag.SuccessSave = TempData["Success"]; } return(View(objMCatalog)); }
public ActionResult EditTableCatalog(MCatalog objCatalog) { try { if (ModelState.IsValid) { string mensaje = ""; int resultDb = fnGNTranTableCatalog(objCatalog, "U", ref mensaje); if (resultDb != 0) { TempData["Success"] = mensaje; //Para evitar que se vea el id en la Url------------ MCatalog objMCatalog = new MCatalog(); objMCatalog.IdCatalog = objCatalog.IdCatalog; var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(objMCatalog); TempData["DataTableCatalog"] = jsonString; return(RedirectToAction("EditTableCatalog")); //--------------------------------------------------- } else { ViewBag.ErrorSave = mensaje; return(View(objCatalog)); } } else { ViewBag.ErrorSave = "Error al grabar, Por favor verifique los datos ingresados."; return(View(objCatalog)); } } catch (Exception ex) { ViewBag.ErrorSave = "Error al grabar datos: " + ex.Message; return(View(objCatalog)); } }
public ActionResult ListTableCatalog() { if (Session["Usuario"] == null) { return(RedirectToAction("Login", "User")); } var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces; var ObjAcces = ObjAccesUser.Where(p => p.Action == "ListTableCatalog").First(); if (ObjAcces != null) { if (ObjAcces.Visible == false) { return(RedirectToAction("Index", "Home")); } } MCatalog objMCatalog = new MCatalog(); return(View(objMCatalog)); }
public ActionResult ListTableCatalog(string submit, MCatalog objMCatalog) { if (objMCatalog == null || objMCatalog.IdCatalog == 0) { return(View()); } var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(objMCatalog); TempData["DataTableCatalog"] = jsonString; switch (submit) { case "searchRow": return(RedirectToAction("DetailTableCatalog", "TableCatalog")); case "editRow": return(RedirectToAction("EditTableCatalog", "TableCatalog")); default: return(View()); } }
public void DoMydoc(string opType, string folderName, string docIds, int applyFolderId, int folderType) { try { UserService us = Context.GetService <UserService>(); U_UserInfo u = base.GetUser(); switch (opType.ToLower()) { #region 新增文件夹 case "addfolder": MCatalog mc = new MCatalog() { CateText = folderName, CatalogType = folderType, CreateTime = DateTime.Now, DocCount = 0, UserId = u.UserId }; us.MCatalogBll.Insert(mc); break; #endregion #region 除文件夹 case "deletefolder": MCatalog dmc = us.MCatalogBll.Get(applyFolderId, u.UserId); if (dmc != null) { us.MCatalogBll.Delete(dmc.CateId); us.DocInfoBll.UpdateUserCatalog(u.UserId, dmc.CateId); } else { throw new Exception("操作失败"); } break; #endregion #region 重命名文件夹 case "updatefolder": MCatalog dmc2 = us.MCatalogBll.Get(applyFolderId, u.UserId); if (dmc2 != null) { dmc2.CateText = folderName; us.MCatalogBll.Update(dmc2); } else { throw new Exception("操作失败"); } break; #endregion #region 多选删除 case "deleteall": string[] strDocIds = docIds.Split(','); strDocIds.ToList().ForEach(s => { DDocInfo d = us.DocInfoBll.Get(int.Parse(s), u.UserId); if (d != null) { us.DocInfoBll.Delete(d.DocId); if (d.UserCateId != 0) { //文件夹文档数量减一 MCatalog dsmc = us.MCatalogBll.Get(d.UserCateId); dsmc.DocCount -= 1; us.MCatalogBll.Update(dsmc); } } else { throw new Exception("可能删除了不是自己的文档"); } }); break; #endregion #region 移动到文件夹 case "moveall": string[] strDocIds2 = docIds.Split(','); strDocIds2.ToList().ForEach(s => { us.DocInfoBll.MoveFolder(int.Parse(s), applyFolderId); }); break; #endregion #region 单个删除 case "deletesingle": string[] strDocIds3 = docIds.Split(','); strDocIds3.ToList().ForEach(s => { DDocInfo d = us.DocInfoBll.Get(int.Parse(s), u.UserId); if (d != null) { us.DocInfoBll.Delete(d.DocId); if (d.UserCateId != 0) { //文件夹文档数量减一 MCatalog dsmc = us.MCatalogBll.Get(d.UserCateId); dsmc.DocCount -= 1; us.MCatalogBll.Update(dsmc); } } else { throw new Exception("可能删除了不是自己的文档"); } }); break; #endregion #region 移动到收藏夹 case "moveallfav": string[] strDocIds4 = docIds.Split(','); strDocIds4.ToList().ForEach(s => { us.MFavoriteBll.MoveFolder(int.Parse(s), applyFolderId); }); break; #endregion #region 除收藏 case "deleteallfav": string[] strDocIds5 = docIds.Split(','); strDocIds5.ToList().ForEach(s => { us.MFavoriteBll.Delete(int.Parse(s)); }); break; #endregion } AddSuccess("操作成功"); } catch (Exception ex) { Utils.Log4Net.Error(ex); AddError("操作失败"); } RedirectToReferrer(); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(MCatalog obj) { return(dal.Insert(obj)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(MCatalog obj) { return(dal.Update(obj)); }
public static int fnGNTranTableCatalog(MCatalog objCatalog, string TransactionType, ref string Mensaje) { try { //TextInfo ti = CultureInfo.CurrentCulture.TextInfo; //para capitalizar textos MMEnterprisesEntities db = new MMEnterprisesEntities(); int IdCatalog; int IdCatalogDetail; int SqlResultCatalog; int SqlResult; SqlParameter paramOutIdCatalog = new SqlParameter(); paramOutIdCatalog.ParameterName = "@IdCatalog"; paramOutIdCatalog.SqlDbType = System.Data.SqlDbType.Int; paramOutIdCatalog.Direction = System.Data.ParameterDirection.InputOutput; paramOutIdCatalog.Value = objCatalog.IdCatalog; SqlResultCatalog = db.Database.ExecuteSqlCommand("GNTranCatalog @TransactionType, @IdCatalog OUT, @IdTable, @Description ", new SqlParameter[] { new SqlParameter("@TransactionType", TransactionType), paramOutIdCatalog, new SqlParameter("@IdTable", objCatalog.IdTable.ToUpper()), new SqlParameter("@Description", objCatalog.Description) } ); IdCatalog = Int32.Parse(paramOutIdCatalog.Value.ToString()); if (IdCatalog != 0) { if (objCatalog.TableDetails != null && objCatalog.TableDetails.Count() > 0) { foreach (var item in objCatalog.TableDetails) { SqlParameter paramOutIdCatalogDetail = new SqlParameter(); paramOutIdCatalogDetail.ParameterName = "@IdCatalogDetail"; paramOutIdCatalogDetail.SqlDbType = System.Data.SqlDbType.Int; paramOutIdCatalogDetail.Direction = System.Data.ParameterDirection.InputOutput; paramOutIdCatalogDetail.Value = item.IdCatalogDetail; SqlParameter paramDescription = new SqlParameter(); paramDescription.ParameterName = "@Description"; if (item.Description != null) { paramDescription.Value = item.Description; } else { paramDescription.Value = DBNull.Value; } SqlParameter paramIdTableDetail = new SqlParameter(); paramIdTableDetail.ParameterName = "@IdTableDetail"; //paramIdTableDetail.SqlDbType = System.Data.SqlDbType.Int; paramIdTableDetail.Direction = System.Data.ParameterDirection.Input; paramIdTableDetail.IsNullable = true; if (!string.IsNullOrEmpty(item.IdTableDetail)) { paramIdTableDetail.Value = item.IdTableDetail.ToUpper(); } else { paramIdTableDetail.Value = DBNull.Value; } bool blStatus = TransactionType == "I" ? true : item.Status; int intIdCatalog = TransactionType == "I" ? IdCatalog : item.IdCatalog; SqlResult = db.Database.ExecuteSqlCommand("GNTranCatalogDetail @TransactionType, @IdCatalogDetail OUT, @IdTableDetail " + ", @IdCatalog, @Description, @Status ", new SqlParameter[] { new SqlParameter("@TransactionType", TransactionType), paramOutIdCatalogDetail, paramIdTableDetail, new SqlParameter("@IdCatalog", intIdCatalog), paramDescription, new SqlParameter("@Status", blStatus) } ); IdCatalogDetail = Int32.Parse(paramOutIdCatalogDetail.Value.ToString()); } } Mensaje = "Datos grabados exitosamente."; } else { Mensaje = "No se pudo realizar la transaccion, intente nuevamente."; } return(SqlResultCatalog); } catch (SqlException ex) { Mensaje = "Error al grabar datos: " + ex.Message; return(0); } }