예제 #1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        public string Save2()
        {
            string Orgcode = System.Web.HttpContext.Current.Request.Params["Orgcode"];
            string data    = System.Web.HttpContext.Current.Request.Params["data"];

            Dictionary <string, object> dicWhere = new Dictionary <string, object>();

            new CreateCriteria(dicWhere).Add(ORMRestrictions <string> .Eq("Orgcode", Orgcode));
            IList <ProjectThresholdModel> projectThresholdModels = ProjectThresholdService.Find(dicWhere).Data;
            List <long> phidList = projectThresholdModels.ToList().Select(x => x.PhId).ToList();
            List <ProjectThresholdModel> SaveData = new List <ProjectThresholdModel>();

            if (data.EndsWith("|"))
            {
                data = data.Substring(0, data.Length - 1);
            }
            String[] Items = data.Split('|');
            foreach (String item in Items)
            {
                //取到item,即序列化对象
                String[] attrs = item.Split(':');
                if (string.IsNullOrEmpty(attrs[0]) || attrs[0] == "0")
                {
                    var p1 = new ProjectThresholdModel();
                    p1.Orgcode         = attrs[1];
                    p1.FThreshold      = attrs[2];
                    p1.ProjTypeId      = attrs[3];
                    p1.ProjTypeName    = attrs[4];
                    p1.Orgid           = long.Parse(attrs[5]);
                    p1.PersistentState = PersistentState.Added;
                    SaveData.Add(p1);
                }
                else
                {
                    if (phidList.Contains(long.Parse(attrs[0])))
                    {
                        phidList.Remove(long.Parse(attrs[0]));
                    }
                    var p1 = projectThresholdModels.ToList().Find(x => x.PhId == long.Parse(attrs[0]));
                    p1.FThreshold      = attrs[2];
                    p1.ProjTypeId      = attrs[3];
                    p1.ProjTypeName    = attrs[4];
                    p1.PersistentState = PersistentState.Modified;
                    SaveData.Add(p1);
                }
            }
            if (phidList.Count > 0)
            {
                foreach (var phid in phidList)
                {
                    var p1 = projectThresholdModels.ToList().Find(x => x.PhId == phid);
                    p1.PersistentState = PersistentState.Deleted;
                    SaveData.Add(p1);
                }
            }

            SavedResult <Int64> savedresult = ProjectThresholdService.Save <Int64>(SaveData, "");

            return(DataConverterHelper.SerializeObject(savedresult));
        }
예제 #2
0
        /// <summary>
        /// 右边的已选项目类型
        /// </summary>
        /// <returns></returns>
        public String GetRightExpenseCategoryModel()
        {
            string Orgcode = System.Web.HttpContext.Current.Request.Params["Orgcode"];
            string PhId    = System.Web.HttpContext.Current.Request.Params["PhId"];
            List <ExpenseCategoryModel> expenseCategoryModels = new List <ExpenseCategoryModel>();

            if (!string.IsNullOrEmpty(PhId))
            {
                ProjectThresholdModel projectThreshold = ProjectThresholdService.Find(long.Parse(PhId)).Data;
                expenseCategoryModels = this.GetAllExpenseCategoryModel(Orgcode).ToList();
                IList <String> useCodeList = (projectThreshold.ProjTypeId ?? "").Split(',').ToList <String>();
                expenseCategoryModels = expenseCategoryModels.Where(x => useCodeList.Contains(x.Dm)).ToList();
                expenseCategoryModels.Sort((ExpenseCategoryModel a, ExpenseCategoryModel b) => a.Dm.CompareTo(b.Dm));
            }

            return(DataConverterHelper.EntityListToJson <ExpenseCategoryModel>(expenseCategoryModels, (Int32)expenseCategoryModels.Count));
        }