protected void lbUpdate_Click(object sender, EventArgs e) { try { lblContact.Text = "Update Contact"; var argument = ((LinkButton)sender).CommandArgument; contactID = Int32.Parse(argument); pnlContacts.Visible = true; gvContacts.Visible = false; lbNew.Visible = false; lbFind.Visible = false; txtFind.Visible = false; contactdeat = new Phonebook.Model.Contact(); contactdeat = contacts.Where(c => c.ContactID == contactID).First(); contactNumber = contactNumbers.Where(c => c.ContactID == contactID).First(); txtName.Text = contactdeat.ContactName; txtContactSurname.Text = contactdeat.ContactSurname; txtNumber.Text = contactNumber.Number; ddlNumberType.SelectedIndex = ddlNumberType.Items.IndexOf(ddlNumberType.Items.FindByValue(contactNumber.NumberType.ToString())); ddlRelationship.SelectedIndex = ddlRelationship.Items.IndexOf(ddlRelationship.Items.FindByValue(contactdeat.Relationship.ToString())); } catch (Exception ex) { //Controller.testRules.exUpdateErrorLog(el); } }
protected void gvContacts_RowEditing(object sender, GridViewEditEventArgs e) { //editingIndex = e.NewEditIndex gvContacts.EditIndex = -1; contactID = Int32.Parse(gvContacts.DataKeys[e.NewEditIndex].Values["ContactID"].ToString()); contactNumberID = Int32.Parse(gvContacts.DataKeys[e.NewEditIndex].Values["ContactNumberID"].ToString()); gvContacts.Visible = false; lbNew.Visible = false; txtFind.Visible = false; pnlContacts.Visible = true; contactdeat = new Phonebook.Model.Contact(); contactdeat = contacts.Where(c => c.ContactID == contactID).First(); contactNumber = contactNumbers.Where(c => c.ContactID == contactID && c.ContactNumberID == contactNumberID).First(); txtName.Text = contactdeat.ContactName; txtContactSurname.Text = contactdeat.ContactSurname; txtNumber.Text = contactNumber.Number; ddlNumberType.SelectedIndex = ddlNumberType.Items.IndexOf(ddlNumberType.Items.FindByValue(contactNumber.NumberType.ToString())); ddlRelationship.SelectedIndex = ddlRelationship.Items.IndexOf(ddlRelationship.Items.FindByValue(contactdeat.Relationship.ToString())); }
protected void LinkButton1_Click(object sender, EventArgs e) { try { Type cstype = this.GetType(); // Get a ClientScriptManager reference from the Page class. ClientScriptManager cs = Page.ClientScript; //contactID = 0; //contactNumberID = 0; //if (ddlNumberType.SelectedItem.Text.ToUpper() != "EMAIL") //{ // if (!txtNumber.Text.ToString().All(Char.IsDigit)) // { // // Check to see if the startup script is already registered. // if (!cs.IsStartupScriptRegistered(cstype, "PopupScript")) // { // String cstext = "alert('Please enter a valid phone number');"; // cs.RegisterStartupScript(cstype, "PopupScript", cstext, true); // } // return; // } // else { // if (!txtNumber.Text.Contains("@") && !txtNumber.Text.Contains(".")) // { // if (!cs.IsStartupScriptRegistered(cstype, "PopupScript")) // { // String cstext = "alert('Please enter a valid phone number');"; // cs.RegisterStartupScript(cstype, "PopupScript", cstext, true); // } // return; // } // } //} //else { //} contactdeat = new Phonebook.Model.Contact(); contactdeat.ContactID = contactID; contactdeat.ContactName = txtName.Text.Trim().ToString(); contactdeat.ContactSurname = txtContactSurname.Text.Trim().ToString(); contactdeat.Relationship = Int32.Parse(ddlRelationship.SelectedValue); contactdeat.Deleted = false; contactNumber = new Phonebook.Model.ContactNumber(); contactNumber.ContactID = contactID; contactNumber.ContactNumberID = contactNumberID; contactNumber.NumberType = Int32.Parse(ddlNumberType.SelectedValue); contactNumber.Number = txtNumber.Text.Trim().ToString(); contactNumber.Deleted = false; Controller.tRules.exSaveContacts(contactdeat, contactNumber); getcontacts(); //Type cstype = this.GetType(); //// Get a ClientScriptManager reference from the Page class. //ClientScriptManager cs = Page.ClientScript; // Check to see if the startup script is already registered. if (!cs.IsStartupScriptRegistered(cstype, "PopupScript")) { String cstext = "alert('Saved');"; cs.RegisterStartupScript(cstype, "PopupScript", cstext, true); } gvContacts.Visible = true; lbNew.Visible = true; lbFind.Visible = true; txtFind.Visible = true; pnlContacts.Visible = false; //ASPxPopupControlDeleteQuestion.ShowOnPageLoad = true; } catch (Exception ex) { //Controller.testRules.exUpdateErrorLog(el); } }