private void agregarbutton_Click(object sender, EventArgs e) { DireccionGestor.setorigen("buscador"); addContact add = new addContact(); add.WindowState = FormWindowState.Normal; add.Show(); this.Close(); }
private void cONTACTOToolStripMenuItem_Click(object sender, EventArgs e) { LoginClass create = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); create.CreateContactsTable(UserAccessForm.getusername()); origen = "inicio"; addContact agendaobjectl = new addContact(); agendaobjectl.WindowState = FormWindowState.Normal; agendaobjectl.Show(); }
private void dataGrid_DoubleClick(object sender, EventArgs e) { try { dataout = new string[5]; LoginClass ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); string dato = this.dataGrid.CurrentCell.Value.ToString(); string orden = "SELECT * FROM " + UserAccessForm.getusername() + "_contacts_table WHERE NOMBRE='" + dato + "';"; if (ver.fillcombos(namecombo, telefonocombo, orden)) { editbutton.Enabled = true; quitarbutton.Enabled = true; try { dataout[0] = namecombo.Text; dataout[1] = telefonocombo.Text; dataout[2] = LoginClass.getdata()[0]; dataout[3] = LoginClass.getdata()[1]; dataout[4] = LoginClass.getdata()[2]; DireccionGestor.setorigen("editor"); addContact add = new addContact(); add.WindowState = FormWindowState.Normal; add.Show(); } catch (IndexOutOfRangeException por) { por.ToString(); } this.Close(); } else { editbutton.Enabled = false; quitarbutton.Enabled = false; } } catch (NullReferenceException pafh) { pafh.ToString(); } }
private void OKbutton_Click(object sender, EventArgs e) { cuenta = 0; carga ca = new carga(); ca.WindowState = FormWindowState.Normal; ca.Show(); if (DireccionGestor.getorigen() == "inicio") { if (nombrebox.Text == "" || telefonobox.Text == "") { if (nombrebox.Text == "") { nombrebox.BackColor = Color.Red; } else { nombrebox.BackColor = Color.Green; } if (telefonobox.Text == "") { telefonobox.BackColor = Color.Red; } else { telefonobox.BackColor = Color.Green; } MessageBox.Show("HAY CAMPOS CLAVES VACIOS"); } else { if (direccionbox.Text == "") { direccionbox.Text = "NINGUNA"; } if (emailbox.Text == "") { emailbox.Text = "NINGUNA"; } try { LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.AddContact(nombrebox.Text, telefonobox.Text, direccionbox.Text, emailbox.Text, UserAccessForm.getusername().ToString()); MessageBox.Show("NUEVO CONTACTO " + nombrebox.Text + " AGREGADO"); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { add = new LoginClass(); this.Close(); } else { add = new LoginClass(); addContact menu = new addContact(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } catch (FormatException datethis) { datethis.ToString(); } } } else if (DireccionGestor.getorigen() == "editor") { try { LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.ordensql("UPDATE " + UserAccessForm.getusername() + "_contacts_table SET NOMBRE='" + nombrebox.Text + "', TELEFONO='" + telefonobox.Text + "', DIRECCION='" + direccionbox.Text + "', EMAIL='" + emailbox.Text + "' WHERE ID='" + ShowContacts.getdataout()[4] + "';"); MessageBox.Show("CONTACTO " + DireccionGestor.getnombrestatic() + " EDITADO"); ShowContacts show = new ShowContacts(); show.WindowState = FormWindowState.Normal; show.Show(); this.Close(); } catch (FormatException datethis) { datethis.ToString(); } catch (IndexOutOfRangeException oper) { oper.ToString(); } } else if (DireccionGestor.getorigen() == "buscador") { if (nombrebox.Text == "" || telefonobox.Text == "") { if (nombrebox.Text == "") { nombrebox.BackColor = Color.Red; } else { nombrebox.BackColor = Color.Green; } if (telefonobox.Text == "") { telefonobox.BackColor = Color.Red; } else { telefonobox.BackColor = Color.Green; } MessageBox.Show("HAY CAMPOS CLAVES VACIOS"); } else { if (direccionbox.Text == "") { direccionbox.Text = "NINGUNA"; } if (emailbox.Text == "") { emailbox.Text = "NINGUNA"; } try { LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.AddContact(nombrebox.Text, telefonobox.Text, direccionbox.Text, emailbox.Text, UserAccessForm.getusername().ToString()); MessageBox.Show("NUEVO CONTACTO " + nombrebox.Text + " AGREGADO"); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { add = new LoginClass(); ShowContacts ad = new ShowContacts(); ad.WindowState = FormWindowState.Normal; ad.Show(); this.Close(); } else { add = new LoginClass(); addContact menu = new addContact(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } catch (FormatException datethis) { datethis.ToString(); } } } ca.Close(); }