add newitem ambil class.cs dan rename terserah anda di classnya dan masukan code di bawah ini:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace FormRegisterSolution
{
public class Bases : System.Data.Linq.DataContext
{
public FormRegisterSolution.Entitas.RelationDataContext datacontext;
public Bases()
: base(System.Configuration.ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString)
{
datacontext = new FormRegisterSolution.Entitas.RelationDataContext(this.Connection.ConnectionString);
}
}
}
Controler Untuk masing masing table yang di diambil dari database
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FormRegisterSolution.Controler
{
public class Rsscontroler : Bases
{
public List<FormRegisterSolution.Entitas.RSS> RSSlist
{
get
{
return datacontext.RSSes.ToList<FormRegisterSolution.Entitas.RSS>();
}
}
public void addbskaryawan(FormRegisterSolution.Entitas.RSS obj)
{
datacontext.RSSes.InsertOnSubmit(obj);
datacontext.SubmitChanges();
}
public void updaterss(int objguid, string objlocationstore, string objcategory, string objstory, string objdescription, string objlink, string objimage, string objtitle, DateTime objpubdate)
{
var verified = (from v in datacontext.RSSes where v.guid == objguid select v).Single();
//verified.discount = objdiscount;
verified.locationstore = objlocationstore;
verified.category = objcategory;
verified.story = objstory;
verified.description = objdescription;
verified.link = objlink;
verified.imagepath = objimage;
verified.title = objtitle;
verified.pubdate = objpubdate;
datacontext.SubmitChanges();
}
}
}
Tidak ada komentar:
Posting Komentar