Beispiel #1
0
 public static bool AddLink(Models.Links model)
 {
     using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
     {
         return(db.Insert(model) != null);
     }
 }
Beispiel #2
0
 public static bool UpdateLink(Models.Links model)
 {
     using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
     {
         var entity = db.Query <Models.Links>("where id=@0", model.Id).SingleOrDefault();
         entity.IsHidden = model.IsHidden;
         entity.Logo     = model.Logo;
         entity.Name     = model.Name;
         entity.Url      = model.Url;
         return(db.Update(entity) > 0);
     }
 }
Beispiel #3
0
 //提交保存
 protected void btnsave_Click(object sender, EventArgs e)
 {
     if (Request["type"] == "Edit")
     {
         long Id   = Convert.ToInt64(Request["ID"]);
         var  item = db.Find(Id);
         if (item != null)
         {
             item.Title   = txtbt.Text;
             item.LinkStr = txtdz.Text;
             if (db.Edit(item))
             {
                 Page.ClientScript.RegisterStartupScript(GetType(), "e1", "edOK();", true);
             }
             else
             {
                 Page.ClientScript.RegisterStartupScript(GetType(), "e2", "layer.alert('修改失败');", true);
             }
         }
         else
         {
             //找不到数据就返回列表
             Response.Redirect("LinksListPG.aspx");
         }
     }
     else
     {
         Models.Links item = new Models.Links();
         item.Title   = txtbt.Text;
         item.LinkStr = txtdz.Text;
         if (db.Add(item))
         {
             Page.ClientScript.RegisterStartupScript(GetType(), "a1", "adOK()", true);
         }
         else
         {
             Page.ClientScript.RegisterStartupScript(GetType(), "a2", "layer.alert('添加失败');", true);
         }
     }
 }
Beispiel #4
0
        public ActionResult UpdateLink(Models.Links model)
        {
            bool result = false;

            if (model.Id == 0)
            {
                result = DataProvider.AdminDataProvider.AddLink(model);
            }
            else
            {
                result = DataProvider.AdminDataProvider.UpdateLink(model);
            }
            if (result)
            {
                TempData["result"] = "操作成功";
            }
            else
            {
                TempData["result"] = "操作失败";
            }
            return(RedirectToAction("Links"));
        }