protected void btnModifyRegion_Click(object sender, EventArgs e) { try { MSOPSClassesDataContext msops_dc = new MSOPSClassesDataContext(); Region ModRegion = msops_dc.GetTable<Region>().Single(r => r.RegionID == txtRegionID.Text); ModRegion.RegionID = txtRegionID.Text; ModRegion.RegionDesc = txtRegionDesc.Text; msops_dc.SubmitChanges(); lblMessage.Text = "Region Modified"; ClearText(); } catch (Exception exp) { lblMessage.Text = "Error : " + exp.Message; } }
protected void btnAddRegion_Click(object sender, EventArgs e) { try { MSOPSClassesDataContext msops_dc = new MSOPSClassesDataContext(); Table<Region> tblRegions = msops_dc.GetTable<Region>(); Region newRegion= new Region {RegionID=txtRegionID.Text, RegionDesc=txtRegionDesc.Text}; tblRegions.InsertOnSubmit(newRegion); msops_dc.SubmitChanges(); lblMessage.Text="Region Created"; ClearText(); } catch (Exception exp) { lblMessage.Text="Error : " + exp.Message; } }