protected void btnUpload_onclick(object sender, EventArgs e) { //Save information in the database OMMDataContext context = new OMMDataContext(); int contactID = WebUtil.GetQueryStringInInt("ID"); if (btnUpload.Text == "Save") { ContactsNextOfKin conNextKin = new ContactsNextOfKin(); conNextKin.MothersName = (tbxMotherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : tbxMotherName.Text.ToString().Trim(); conNextKin.FathersName = (tbxFatherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : tbxFatherName.Text.ToString().Trim(); conNextKin.ChildrensNames = (tbxChildName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : tbxChildName.Text.ToString().Trim(); conNextKin.ChangedByUserID = SessionCache.CurrentUser.ID; conNextKin.ChangedOn = System.DateTime.Today; context.ContactsNextOfKins.InsertOnSubmit(conNextKin); context.SubmitChanges(); } else { var ContactsNextOfKins = context.ContactsNextOfKins.FirstOrDefault(P => P.ContactID == contactID); if (ContactsNextOfKins == null || contactID == 0) { } else { ContactsNextOfKins.MothersName = (tbxMotherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : tbxMotherName.Text.ToString().Trim(); ContactsNextOfKins.FathersName = (tbxFatherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : tbxFatherName.Text.ToString().Trim(); ContactsNextOfKins.ChildrensNames = (tbxChildName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : tbxChildName.Text.ToString().Trim(); ContactsNextOfKins.ChangedByUserID = SessionCache.CurrentUser.ID; ContactsNextOfKins.ChangedOn = System.DateTime.Today; context.SubmitChanges(); } } loadImmediateFamilyDetails(contactID); }
protected void SaveFamilyDetails() { //Save information in the database OMMDataContext context = new OMMDataContext(); //int contactID = WebUtil.GetQueryStringInInt("ID"); //if (tbxSaveUpdate.Text == "Save") { ContactsNextOfKin conNextOfKin = context.ContactsNextOfKins.FirstOrDefault(P => P.ContactID == _ContactID); if (conNextOfKin == null) { conNextOfKin = new ContactsNextOfKin(); conNextOfKin.ContactID = _ContactID; context.ContactsNextOfKins.InsertOnSubmit(conNextOfKin); } conNextOfKin.MothersName = tbxMotherName.Text.Trim(); //(tbxMotherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : //tbxMotherName.Text.ToString().Trim(); conNextOfKin.FathersName = tbxFatherName.Text.Trim(); //(tbxFatherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : //tbxFatherName.Text.ToString().Trim(); conNextOfKin.ChildrensNames = tbxChildName.Text.Trim(); //(tbxChildName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : //tbxChildName.Text.ToString().Trim(); conNextOfKin.ChangedByUserID = SessionCache.CurrentUser.ID; conNextOfKin.ChangedOn = DateTime.Now; //context.ContactsNextOfKins.InsertOnSubmit(conNextOfKin); context.SubmitChanges(); } //if (tbxSaveUpdate.Text == "Update") //{ // var ContactsNextOfKin = context.ContactsNextOfKins.FirstOrDefault(P => P.ContactID == _ContactID); // if (ContactsNextOfKin == null || _ContactID == 0) // { // } // else // { // ContactsNextOfKin.MothersName = // (tbxMotherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : // tbxMotherName.Text.ToString().Trim(); // ContactsNextOfKin.FathersName = // (tbxFatherName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : // tbxFatherName.Text.ToString().Trim(); // ContactsNextOfKin.ChildrensNames = // (tbxChildName.Text.ToString().Trim().IsNullOrEmpty()) ? "" : // tbxChildName.Text.ToString().Trim(); // ContactsNextOfKin.ChangedByUserID = SessionCache.CurrentUser.ID; // ContactsNextOfKin.ChangedOn = System.DateTime.Today; // context.SubmitChanges(); // } //} //ShowSuccessMessage(); RedirectToShowSuccessMessage(); }