public OwnersCompany updateCompany(string id, OwnersCompany comp) { try { using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { var query = (from acc in db.OWNERS_COMPANies where acc.COMP_ID.Equals(Convert.ToInt32(id)) select acc); if (query.Count() == 1) { OWNERS_COMPANY acc = query.Single(); comp = new OwnersCompany() { ContactNum = acc.CONTACT_NUM, Email = acc.EMAIL, CompanyName = acc.NAME, RegNum = acc.REG_NUM }; db.SubmitChanges(); return(comp); } else { return(null); } } } catch (Exception) { return(null); } }
protected void btnSubmit_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); OwnerServicesClient oServ = new OwnerServicesClient(); OwnersCompany comp = new OwnersCompany() { OwnerId = Convert.ToInt32(Session["ID"]), CompanyName = txtCompName.Text, ContactNum = txtTeleNo.Text, Email = txtEmail.Text, RegNum = txtCompRegNo.Text }; string outcome = oServ.insertCompany(comp); if (outcome.Contains("Success")) { ModalPopupExtenderSuccess.Show(); System.Threading.Thread.Sleep(2000); } else if (outcome.Contains("Failed")) { ModalPopupExtenderFailed.Show(); System.Threading.Thread.Sleep(2000); } }
public string insertCompany(OwnersCompany comp) { try { using (HotelManagementServerDataContext db = new HotelManagementServerDataContext()) { OWNERS_COMPANY companyLinq = ConvertToLinq.ConvertCompanyToLinq(comp); db.OWNERS_COMPANies.InsertOnSubmit(companyLinq); db.SubmitChanges(); return("Success Adding company was successful"); } } catch (Exception) { return("Failed Adding company failed, contact admin"); } }