示例#1
0
 public ActionResult CreateJQ(CornerTeamName newCtn)
 {
     if (!string.IsNullOrEmpty(newCtn.SpName) &&
              !string.IsNullOrEmpty(newCtn.TsName)
              )
     {
         string txtSpName = newCtn.SpName;
         string txtTsName = newCtn.TsName;
         try
         {
             XElement doc = XElement.Load(path);
             string result = "<data SpName=\"" + txtSpName + "\"  TsName=\"" + txtTsName + "\"/>";
             XElement xElement = XElement.Parse(result);
             doc.Add(xElement);
             //保存到XML文件中
             doc.Save(path);
             return Json("ok");
         }
         catch(Exception e)
         {
             return Json("error:"+e.Message+e.StackTrace);
         }
     }
     return Json("0");
 }
示例#2
0
 public ActionResult DeleteJQ(CornerTeamName ctn)
 {
     XElement doc = XElement.Load(path);
     try
     {
         var item = (from c in doc.Descendants("data")
                     where c.Attribute("TsName").Value == ctn.TsName &&
                           c.Attribute("SpName").Value == ctn.SpName
                     select c).FirstOrDefault();
         item.Remove();
         doc.Save(path);
         return Json("ok");
     }
     catch
     {
         return Json("error:error");
     }
 }
示例#3
0
 public ActionResult EditJQ(CornerTeamName newCtn, string HdlSpName, string HdlTsName)
 {
     if (newCtn != null &&
         !string.IsNullOrEmpty(newCtn.SpName) &&
         !string.IsNullOrEmpty(newCtn.TsName) &&
         !string.IsNullOrEmpty(HdlSpName) &&
         !string.IsNullOrEmpty(HdlTsName)
        )
     {
         string txtSpName = newCtn.SpName;
         string txtTsName = newCtn.TsName;
         string oldSpName = HdlSpName;
         string oldTsName = HdlTsName;
         XElement doc = XElement.Load(path);
         try
         {
             var item = (from c in doc.Descendants("data")
                         where c.Attribute("TsName").Value == oldTsName &&
                              c.Attribute("SpName").Value == oldSpName
                         select c).FirstOrDefault();
             item.SetAttributeValue("TsName", txtTsName);
             item.SetAttributeValue("SpName", txtSpName);
             doc.Save(path);
             return Json("ok");
         }
         catch
         {
             return Json("error");
         }
     }
     return Json("0");
 }
示例#4
0
 /// <summary>
 /// 加載xml
 /// </summary>
 private void LoadXml()
 {
     TeamNameMap.Clear();
     XElement doc = XElement.Load(path);
     foreach (var item in doc.Descendants("data"))
     {
         CornerTeamName cornerModel = new CornerTeamName();
         cornerModel.TsName = item.Attribute("TsName").Value;
         cornerModel.SpName = item.Attribute("SpName").Value;
         if (!TeamNameMap.ContainsKey(cornerModel.TsName))
         {
             TeamNameMap.AddOrUpdate(cornerModel.SpName, cornerModel.TsName, (m, n) => cornerModel.TsName);
         }
     }
 }
示例#5
0
 public ActionResult FoolballCornerUpdate(CornerTeamName ctn, string operation = "")
 {
     ViewBag.IsUpdate = operation.ToLower() == "update";
     ViewBag.navigation = new Navigation
     {
         Level = new List<string> { "足球", "角球隊伍" },
         HaveButton = false
     };
     return View(ctn);
 }