Example #1
0
        public Common.ClientResult.Result EditGroup(string ID, string Code, string GroupName, string Des)
        {
            ValidationErrors validationErrors = new ValidationErrors();
            StringBuilder    sbError          = new StringBuilder();
            SysEntities      SysEntitiesO2O   = new SysEntities();

            GroupName = HttpUtility.HtmlDecode(GroupName);
            Des       = HttpUtility.HtmlDecode(Des);
            Code      = HttpUtility.HtmlDecode(Code);
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    int IntId = 0;
                    int.TryParse(ID, out IntId);
                    var GropTable = SysEntitiesO2O.ORG_Group.FirstOrDefault(o => true && o.ID == IntId);
                    // GropTable = GropTable.FirstOrDefault(o => o.ID == IntId);
                    if (GropTable != null)
                    {
                        GropTable.Code      = Code;
                        GropTable.GroupName = GroupName;
                        GropTable.Des       = Des;
                        GropTable.XYBZ      = "Y";
                    }
                    else
                    {
                        var       ORG_GroupBLL = new BLL.ORG_GroupBLL();
                        ORG_Group Model        = new ORG_Group();
                        Model.Code      = Code;
                        Model.GroupName = GroupName;
                        Model.Des       = Des;
                        Model.XYBZ      = "Y";
                        ORG_GroupBLL.Create(ref validationErrors, Model);
                    }


                    //最后保存
                    SysEntitiesO2O.SaveChanges();
                    scope.Complete();
                    Common.ClientResult.Result result = new Common.ClientResult.Result();
                    result.Code    = ClientCode.Succeed;
                    result.Message = "保存成功";
                    return(result);
                }
            }
            catch (Exception er)
            {
                Common.ClientResult.Result result = new Common.ClientResult.Result();
                result.Code    = ClientCode.Fail;
                result.Message = "保存失败";
                return(result);
            }
        }
Example #2
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit(string id)
        {
            int idnow = 0;

            int.TryParse(id, out idnow);
            ORG_Group model  = new ORG_Group();
            ORG_Group model1 = m_BLL.GetById(idnow);

            if (model1 != null)
            {
                model = model1;
            }
            return(View(model));
        }
Example #3
0
 /// <summary>
 /// 创建一个ORG_Group
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个ORG_Group</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, ORG_Group entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Example #4
0
        public Common.ClientResult.Result Shanchu(string IDs)
        {
            ValidationErrors validationErrors = new ValidationErrors();
            StringBuilder    sbError          = new StringBuilder();
            SysEntities      SysEntitiesO2O   = new SysEntities();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    int[]    intArray; List <int> intArrayuser = new List <int>();
                    string[] strArray = IDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    intArray = Array.ConvertAll <string, int>(strArray, s => int.Parse(s));
                    var GropTable = SysEntitiesO2O.ORG_Group.FirstOrDefault(o => true && intArray.Contains(o.ID));
                    // GropTable = GropTable.FirstOrDefault(o => o.ID == IntId);
                    if (GropTable != null)
                    {
                        var       ORG_GroupBLL = new BLL.ORG_GroupBLL();
                        ORG_Group Model        = new ORG_Group();
                        Model = GropTable;
                        ORG_GroupBLL.DeleteCollection(ref validationErrors, intArray);
                    }
                    var GropUserTable = SysEntitiesO2O.ORG_GroupUser.Where(o => true && intArray.Contains(o.ORG_Group_ID)).ToList();
                    if (GropUserTable != null)
                    {
                        foreach (var item in GropUserTable)
                        {
                            int j = 0;
                            intArrayuser.Add(item.ID);
                            j++;
                        }
                    }
                    if (intArrayuser.Count > 0)
                    {
                        var   ORG_GroupUserBLL = new BLL.ORG_GroupUserBLL();
                        int[] allid            = new int[intArrayuser.Count];
                        for (int i = 0; i < intArrayuser.Count(); i++)
                        {
                            allid[i] = intArrayuser[i];
                        }

                        ORG_GroupUserBLL.DeleteCollection(ref validationErrors, allid);
                    }


                    SysEntitiesO2O.SaveChanges();
                    scope.Complete();
                    Common.ClientResult.Result result = new Common.ClientResult.Result();
                    result.Code    = ClientCode.Succeed;
                    result.Message = "删除成功";
                    return(result);
                }
            }
            catch (Exception er)
            {
                Common.ClientResult.Result result = new Common.ClientResult.Result();
                result.Code    = ClientCode.Fail;
                result.Message = "删除失败";
                return(result);
            }
        }