Exemplo n.º 1
0
        public ActionResult Edit(int?SN, string kindName)
        {
            try
            {
                if (SN == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                if (kindName.Equals(string.Empty))
                {
                    ModelState.AddModelError("kindName", "請輸入物種");
                }

                Comm_Kind kind = KindModel.getKindBySN(Convert.ToInt32(SN));

                if (!ModelState.IsValid)
                {
                    return(View(kind));
                }

                kind.kindName = kindName;

                KindModel.Update(kind);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        // GET: Kind
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            List <Comm_Kind> kindList = KindModel.getKindList();
            var result = kindList.OrderBy(o => o.SN).ToPagedList();

            return(View(result));
        }
Exemplo n.º 3
0
 public IssuesFilterModel()
 {
     Kind     = new KindModel();
     Status   = new StatusModel();
     Priority = new PriorityModel();
     OrderBy  = (int)Order.Local_Id;
 }
        //添加分类数据
        public string AddKind(string ParentId, string Name)
        {
            int count = (from a in KindCodeOperation.KindData where a.ParentId == ParentId && a.Name == Name select a).ToList().Count;

            if (count > 0)
            {
                return("已存在该分类");
            }
            KindModel model = new KindModel
            {
                ParentId = ParentId,
                Name     = Name,
                fTable   = "Kind_tb"
            };
            string returnId = kind.Create(model);

            if (returnId != null)
            {
                model.objectId = returnId; KindCodeOperation.KindData.Add(model);
            }
            else
            {
                return(ToJson("添加分类失败"));
            }
            return(ToJson(returnId));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加分类
        /// </summary>
        /// <param name="ParentId"></param>
        /// <param name="Name"></param>
        /// <returns></returns>
        public string AddKind(string ParentId, string Name)
        {
            var query = new BmobQuery();

            query.WhereContainedIn <string>("ParentId", ParentId);
            query.WhereContainedIn <string>("Name", Name);
            var future = Bmob.FindTaskAsync <KindModel>("Kind_tb", query);

            if (future.Result.results.Count == 0)
            {
                KindModel kindModel = new KindModel("Kind_tb");
                kindModel.ParentId = ParentId;
                kindModel.Name     = Name;
                var future1 = Bmob.CreateTaskAsync(kindModel);
                if (future1.Result.objectId.Length > 0)
                {
                    DataRow row = Operation.Kind_Data.NewRow();
                    row["ID"] = future1.Result.objectId; row["ParentId"] = ParentId; row["Name"] = Name;
                    Operation.Kind_Data.Rows.Add(row);
                    DataSynchronous("Kind_tb");
                    return(future1.Result.objectId);
                }
                else
                {
                    return("添加失败");
                }
            }
            else
            {
                return("已存在该分类");
            }
        }
Exemplo n.º 6
0
        // GET: Kind/Edit/5
        public ActionResult Edit(int?SN)
        {
            if (SN == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Comm_Kind kind = KindModel.getKindBySN(Convert.ToInt32(SN));

            return(View(kind));
        }
        /// <summary>
        /// 添加代码
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Kind"></param>
        /// <param name="Code"></param>
        /// <param name="Author"></param>
        /// <returns></returns>
        public string AddData(CodeModel model)
        {
            try
            {
                string codeId, ParentId = model.objectId;//将model里的分类id提取出来作为父项分类id,之前暂存进去的
                string kindId;
                var    data = CodeData.Where(x => x.Title == model.Title).ToList();
                if (data.Count > 0)
                {
                    return("出错,此标题已存在");
                }
                KindModel kindmodel = new KindModel("Kind_tb");
                kindmodel.ParentId = ParentId;
                kindmodel.Name     = model.Title;
                kindId             = kind.Create(kindmodel);
                if (kindId != null)
                {
                    kindmodel.objectId = kindId;
                    KindData.Add(kindmodel);
                    model.KindObjectId = kindId;
                    codeId             = code.Create(model);;
                    if (codeId != null)
                    {
                        model.objectId = codeId;
                        CodeData.Add(model);
                        if (model.Visible == "Visible")
                        {
                            OperationModel operationModel = new OperationModel("OperationNews_tb");
                            operationModel.User = (string)SessionHelp.Get("UserName");
                            List <string> PathKind = new List <string>();
                            KindPath(ParentId, ref PathKind);
                            operationModel.Kind    = PathKind[PathKind.Count - 1];
                            operationModel.Operate = "添加了";
                            operationModel.Title   = model.Title;
                            operate.Create(operationModel);
                        }

                        return(kindId);
                    }
                    else
                    {
                        return("出错,添加代码成功,添加标题失败");
                    }
                }
                else
                {
                    return("出错,添加代码失败");
                }
            }
            catch (Exception e)
            {
                return("出错," + e.Message);
            }
        }
Exemplo n.º 8
0
        // GET: Pet/Create
        public ActionResult Create()
        {
            List <Comm_Customer> customerList = CustomerModel.getCustomerList();
            List <Comm_Kind>     kindList     = KindModel.getKindList();
            List <Comm_Variety>  varietyList  = new List <Comm_Variety>();

            ViewBag.customerSN = new SelectList(customerList, "SN", "customerName");
            ViewBag.kindSN     = new SelectList(kindList, "SN", "kindName");
            ViewBag.varietySN  = new SelectList(varietyList, "SN", "varietyName");

            return(View());
        }
        /// <summary>
        /// 修改代码数据
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Code"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public string ModifyCode(string Title, string Code, string Id, string OldTitle, string Visible)
        {
            if (Title != OldTitle)
            {
                var test = CodeData.Where(x => x.Title == Title).ToList();
                if (test.Count > 0)
                {
                    return(ToJson("出错,已存在改标题"));
                }
                KindModel kindmodel = new KindModel("Kind_tb");
                kindmodel.objectId = Id; kindmodel.Name = Title;
                if (kind.ModifyData(kindmodel))
                {
                    var data_ = KindData.Where(x => x.objectId == Id).Single();
                    data_.Name = Title;
                }
                else
                {
                    return(ToJson("出错,修改分类失败"));
                }
            }
            var       data  = CodeData.Where(x => x.Title == OldTitle).Single();
            CodeModel model = new CodeModel("Code_tb");

            model.objectId = data.objectId;
            model.Title    = Title;
            model.Code     = Code;
            model.Visible  = Visible;
            if (code.ModifyData(model))
            {
                data.Title = Title; data.Code = Code; data.Visible = Visible;
            }
            //添加修改记录--------------------
            if (Visible == "Visible")
            {
                OperationModel operationModel = new OperationModel("OperationNews_tb");
                operationModel.User    = (string)SessionHelp.Get("UserName");
                operationModel.Operate = "修改了";
                operationModel.Title   = Title;
                List <string> PathKind = new List <string>();
                string        id;
                id = KindData.Where(x => x.objectId == Id).Single().ParentId;
                KindPath(id, ref PathKind);
                operationModel.Kind = PathKind[PathKind.Count - 1];
                operate.Create(operationModel);
            }
            //添加修改记录-------------------
            return(ToJson("修改成功"));
        }
        //修改分类
        public string ModifyKind(string Name, string Key)
        {
            KindModel model = new KindModel("Kind_tb");

            model.objectId = Key;
            model.Name     = Name;
            if (kind.ModifyData(model))
            {
                var data = KindCodeOperation.KindData.Where(x => x.objectId == Key).Single();
                data.Name = Name;
                return(ToJson("修改成功"));
            }

            return(ToJson("修改失败"));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 添加代码
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Kind"></param>
        /// <param name="Code"></param>
        /// <param name="Author"></param>
        /// <returns></returns>
        public string AddData(string Title, string Kind, string Code, string Author)
        {
            try
            {
                var query = from r in Operation.Code_Data.AsEnumerable() where r.Field <string>("Title") == Title select r;
                if (query.Count <DataRow>() > 0)
                {
                    return("出错,已存在该标题");
                }
                CodeModel codeModel = new CodeModel("Code_tb");
                codeModel.Title  = Title;
                codeModel.Code   = Code;
                codeModel.Author = Author;
                var future = Bmob.CreateTaskAsync(codeModel);
                if (future.Result.objectId.Length > 0)
                {
                    DataRow row = Operation.Code_Data.NewRow();
                    row["Title"] = Title; row["Code"] = Code; row["Author"] = Author; row["ObjectId"] = future.Result.objectId;
                    Operation.Code_Data.Rows.Add(row);
                    DataSynchronous("Code_tb");
                    KindModel kindModel = new KindModel("Kind_tb");
                    kindModel.ParentId = Kind;
                    kindModel.Name     = Title;
                    var future1 = Bmob.CreateTaskAsync(kindModel);
                    if (future1.Result.objectId.Length > 0)
                    {
                        DataRow row_ = Operation.Kind_Data.NewRow();
                        row_["ID"] = future1.Result.objectId; row_["ParentId"] = Kind; row_["Name"] = Title;

                        Operation.Kind_Data.Rows.Add(row_);
                        DataSynchronous("Kind_tb");
                        return(future1.Result.objectId);
                    }
                    else
                    {
                        return("出错,添加代码成功,添加标题失败");
                    }
                }
                else
                {
                    return("出错,添加代码失败");
                }
            }catch (Exception e)
            {
                return("出错," + e.Message);
            }
        }
        public string MoveKind(string node, string newnode)
        {
            KindModel model = new KindModel("Kind_tb");

            model.objectId = node;
            model.ParentId = newnode;
            if (kind.ModifyData(model))
            {
                var data = KindCodeOperation.KindData.Where(x => x.objectId == node).Single();
                data.ParentId = newnode;
            }
            else
            {
                return(ToJson("移动失败"));
            }
            return(ToJson("移动成功"));
        }
Exemplo n.º 13
0
            public override bool Equals(object obj)
            {
                if (obj == null)
                {
                    return(false);
                }
                if (ReferenceEquals(this, obj))
                {
                    return(true);
                }
                if (obj.GetType() != typeof(KindModel))
                {
                    return(false);
                }
                KindModel other = (KindModel)obj;

                return(Bug == other.Bug && Enhancement == other.Enhancement && Proposal == other.Proposal && Task == other.Task);
            }
Exemplo n.º 14
0
        public ActionResult Create(string kindName)
        {
            try
            {
                if (kindName.Equals(string.Empty))
                {
                    ModelState.AddModelError("kindName", "請輸入物種名稱");
                }
                Comm_Kind kind = new Comm_Kind();
                kind.kindName = kindName;

                KindModel.Create(kind);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 修改分类
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public bool ModifyKind(string Name, string Id)
        {
            var    future1  = Bmob.GetTaskAsync <KindModel>("Kind_tb", Id);
            string ParentId = "";

            if (future1.Result is IBmobWritable)
            {
                ParentId = future1.Result.ParentId;
            }
            var linq = from r in Operation.Kind_Data.AsEnumerable() where r.Field <string>("ParentId") == ParentId && r.Field <string>("Name") == Name select r;

            if (linq.Count <DataRow>() > 0)
            {
                return(false);
            }
            KindModel kindModel = new KindModel("Kind_tb");

            kindModel.objectId = Id;
            kindModel.Name     = Name;
            var future = Bmob.UpdateTaskAsync <KindModel>(kindModel);

            if (future.Result is IBmobWritable)
            {
                linq = from r in Operation.Kind_Data.AsEnumerable() where r.Field <string>("Id") == Id select r;
                foreach (var data in Operation.Kind_Data.AsEnumerable())
                {
                    data.SetField <string>("Name", Name);
                }
                DataSynchronous("Kind_tb");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// 移动分类
 /// </summary>
 /// <param name="Node"></param>
 /// <param name="NewNode"></param>
 /// <returns></returns>
 public string MoveKind(string Node, string NewNode)
 {
     try
     {
         KindModel kindModel = new KindModel("Kind_tb");
         kindModel.objectId = Node;
         kindModel.ParentId = NewNode;
         var future = Bmob.UpdateTaskAsync <KindModel>(kindModel);
         if (future.Result is IBmobWritable)
         {
             var linq = from r in Operation.Kind_Data.AsEnumerable() where r.Field <string>("Id") == Node select r;
             foreach (var data in linq)
             {
                 data.SetField <string>("ParentId", NewNode);
             }
         }
         DataSynchronous("Kind_tb");
         return("移动成功");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Exemplo n.º 17
0
        // GET: Pet/Edit/5
        public ActionResult Edit(int?SN)
        {
            if (SN == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Comm_Pet pet = PetModel.getPetBySN(Convert.ToInt32(SN));

            if (pet == null)
            {
                return(HttpNotFound());
            }

            List <Comm_Customer> customerList = CustomerModel.getCustomerList();
            List <Comm_Kind>     kindList     = KindModel.getKindList();
            List <Comm_Variety>  varietyList  = VarietyModel.getVarietyListByKindSN(pet.kindSN);

            ViewBag.customerSN = new SelectList(customerList, "SN", "customerName", pet.customerSN);
            ViewBag.kindSN     = new SelectList(kindList, "SN", "kindName", pet.kindSN);
            ViewBag.varietySN  = new SelectList(varietyList, "SN", "varietyName", pet.varietySN);

            return(View(pet));
        }
Exemplo n.º 18
0
        public ActionResult Create(int?customerSN, string petName, int?petGender, int?kindSN, int?varietySN, string petRemark)
        {
            if (customerSN == null)
            {
                ModelState.AddModelError("customerSN", "請選擇飼主");
            }

            #region Validation
            if (petName == string.Empty)
            {
                ModelState.AddModelError("petName", "請輸入寵物姓名");
            }
            if (petGender == null)
            {
                ModelState.AddModelError("petGender", "請選擇性別");
            }
            if (kindSN == null)
            {
                ModelState.AddModelError("kindSN", "請選擇物種");
            }
            if (varietySN == null)
            {
                ModelState.AddModelError("varietySN", "請選擇品種");
            }
            if (!ModelState.IsValid)
            {
                List <Comm_Customer> customerList = CustomerModel.getCustomerList();
                List <Comm_Kind>     kindList     = KindModel.getKindList();
                List <Comm_Variety>  varietyList  = new List <Comm_Variety>();

                ViewBag.customerSN = new SelectList(customerList, "SN", "customerName");
                ViewBag.kindSN     = new SelectList(kindList, "SN", "kindName");
                ViewBag.varietySN  = new SelectList(varietyList, "SN", "varietyName");
                return(View());
            }

            #endregion

            try
            {
                Boolean gender = false;

                if (petGender == 1)
                {
                    gender = true;
                }

                Comm_Pet pet = new Comm_Pet();
                pet.customerSN = Convert.ToInt32(customerSN);
                pet.petName    = petName;
                pet.petGender  = gender;
                pet.kindSN     = Convert.ToInt32(kindSN);
                pet.varietySN  = Convert.ToInt32(varietySN);
                pet.petRemark  = petRemark;

                PetModel.Create(pet);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// 修改代码数据
 /// </summary>
 /// <param name="Title"></param>
 /// <param name="Code"></param>
 /// <param name="Id"></param>
 /// <returns></returns>
 public string ModifyCode(string Title, string Code, string Id, string OldTitle)
 {
     try
     {
         if (Title != OldTitle)
         {
             var linq_ = from r in Operation.Code_Data.AsEnumerable() where r.Field <string>("Title") == Title select r;
             if (linq_.Count <DataRow>() > 0)
             {
                 return("出错,此标题已添加");
             }
         }
         var       linq      = from r in Operation.Code_Data.AsEnumerable() where r.Field <string>("Title") == OldTitle select r;
         string    Objectid  = linq.First().Field <string>("ObjectId");
         CodeModel codeModel = new CodeModel("Code_tb");
         codeModel.objectId = Objectid;
         codeModel.Title    = Title;
         codeModel.Code     = Code;
         var future1 = Bmob.UpdateTaskAsync <CodeModel>(codeModel);
         if (future1.Result is IBmobWritable)
         {
             linq = from r in Operation.Code_Data.AsEnumerable() where r.Field <string>("Title") == OldTitle select r;
             foreach (var data in linq)
             {
                 data.SetField <string>("Title", Title);
                 data.SetField <string>("Code", Code);
             }
             DataSynchronous("Code_tb");
             if (Title != OldTitle)
             {
                 KindModel kindModel = new KindModel("Kind_tb");
                 kindModel.objectId = Id;
                 kindModel.Name     = Title;
                 future1            = Bmob.UpdateTaskAsync <KindModel>(kindModel);
                 if (future1.Result is IBmobWritable)
                 {
                     linq = from r in Operation.Kind_Data.AsEnumerable() where r.Field <string>("Id") == Id select r;
                     foreach (var data in linq)
                     {
                         data.SetField <string>("Name", Title);
                     }
                     DataSynchronous("Kind_tb");
                     return("成功");
                 }
                 else
                 {
                     return("出错,修改代码数据成功,修改标题失败");
                 }
             }
             else
             {
                 return("成功");
             }
         }
         else
         {
             return("出错,修改代码数据失败");
         }
     }
     catch (Exception e)
     {
         return("出错," + e.Message);
     }
 }
Exemplo n.º 20
0
        public ActionResult Edit(int?SN, int?customerSN, string petName, int?petGender, int?kindSN, int?varietySN, string petRemark)
        {
            try
            {
                if (SN == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                Comm_Pet pet = PetModel.getPetBySN(Convert.ToInt32(SN));

                if (pet == null)
                {
                    return(HttpNotFound());
                }

                #region Validation
                if (customerSN == null)
                {
                    ModelState.AddModelError("customerSN", "請選擇飼主");
                }

                if (petName == string.Empty)
                {
                    ModelState.AddModelError("petName", "請輸入寵物名稱");
                }

                if (petGender == null)
                {
                    ModelState.AddModelError("petGender", "請選擇寵物性別");
                }

                if (kindSN == null)
                {
                    ModelState.AddModelError("kindSN", "請選擇物種");
                }

                if (varietySN == null)
                {
                    ModelState.AddModelError("varietySN", "請選擇品種");
                }

                if (!ModelState.IsValid)
                {
                    List <Comm_Customer> customerList = CustomerModel.getCustomerList();
                    List <Comm_Kind>     kindList     = KindModel.getKindList();
                    List <Comm_Variety>  varietyList  = VarietyModel.getVarietyListByKindSN(pet.kindSN);

                    ViewBag.customerSN = new SelectList(customerList, "SN", "customerName", pet.customerSN);
                    ViewBag.kindSN     = new SelectList(kindList, "SN", "kindName", pet.kindSN);
                    ViewBag.varietySN  = new SelectList(varietyList, "SN", "varietyName", pet.varietySN);
                    return(View(pet));
                }
                #endregion

                Boolean gender = false;
                if (petGender == 1)
                {
                    gender = true;
                }

                pet.customerSN = Convert.ToInt32(customerSN);
                pet.petName    = petName;
                pet.petGender  = gender;
                pet.kindSN     = Convert.ToInt32(kindSN);
                pet.varietySN  = Convert.ToInt32(varietySN);
                pet.petRemark  = petRemark;

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 21
0
 public FilterModel()
 {
     Kind = new KindModel();
     Status = new StatusModel();
     Priority = new PriorityModel();
     OrderBy = (int)Order.Local_Id;
 }