public void InfoTextBox() { DataCliente d = new DataCliente(); SqlConnection Coneccion = new SqlConnection(CadCon.Servidor()); Coneccion.Open(); SqlCommand Command = new SqlCommand("CargarDatosActualizar", Coneccion); Command.Parameters.AddWithValue("@Pk_cliente", ID); Command.CommandType = System.Data.CommandType.StoredProcedure; Command.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter Data = new SqlDataAdapter(Command); Data.Fill(dt); /************************************************ */ textBox2.Text= dt.Rows[0][4].ToString(); textBox3.Text= dt.Rows[0][1].ToString(); maskedTextBox1.Text= dt.Rows[0][2].ToString(); textBox4.Text= dt.Rows[0][3].ToString(); /************************************************ */ textBox5.Text= dt.Rows[0][5].ToString(); textBox6.Text = dt.Rows[0][6].ToString(); textBox7.Text = dt.Rows[0][7].ToString(); textBox8.Text = dt.Rows[0][8].ToString(); Command.Dispose(); Coneccion.Close(); }
public DetallesContactos(int id, DataCliente dc) { InitializeComponent(); this.id = id; this.dc = dc; MostrarClientes(); }
public ActualizarCliente(int ID, DataCliente dc) { InitializeComponent(); this.ID = ID; this.dc = dc; MostrarContactos(); InfoTextBox(); textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; maskedTextBox1.Enabled = false; }
private void button2_Click(object sender, EventArgs e) { MetodosComunes m = new MetodosComunes(); if (m.ActualizarCliente(ID, Convert.ToInt32(textBox5.Text), textBox3.Text, maskedTextBox1.Text, textBox4.Text) == true) { DataCliente dc = new DataCliente(); dc.MostrarClientes(); this.Dispose(); } else { return; } }
private void Agregar_Click(object sender, EventArgs e) { DataCliente dc = new DataCliente(); if (textBox3.Text == "" || textBox4.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "" ) { MessageBox.Show(null,"Debe completar toda la información marcada como obligatoria","Error al registrar", MessageBoxButtons.OK, MessageBoxIcon.Warning); CargarAst(); } else { SqlConnection Coneccion = new SqlConnection(CadCon.Servidor()); Coneccion.Open(); String Query = "SELECT *FROM Contactos_cliente where Pk_contacto=" +textBox4.Text + " AND nombre='" +textBox6.Text + "' AND apellido='" +textBox7.Text + "' AND ced = '" +textBox8.Text + "' AND tel='"+maskedTextBox4.Text+"'"; SqlCommand s = new SqlCommand(Query, Coneccion); s.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter Data = new SqlDataAdapter(s); Data.Fill(dt); int cantCol= dt.Rows.Count; if (cantCol == 0) { MessageBox.Show("No se encontró la información del contacto indicado\n" +"Si lo que desea es registrar la información de una nueva persona " +"de contacto dirgirse a la pestaña Contactos en la parte superior " +"de la ventana de registro y completar el formulario.", "Lo sentimos...", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int IDContacto = Convert.ToInt32(dt.Rows[0][0].ToString()); SqlCommand Command = new SqlCommand("GuardarClientes", Coneccion); Command.CommandType = System.Data.CommandType.StoredProcedure; Command.Parameters.AddWithValue("@fkContacto", IDContacto); Command.Parameters.AddWithValue("@Nombre", textBox3.Text); Command.Parameters.AddWithValue("@dir", textBox5.Text); Command.Parameters.AddWithValue("@tipo", comboBox2.SelectedItem.ToString()); Command.Parameters.AddWithValue("@tel", maskedTextBox3.Text); int f = Command.ExecuteNonQuery(); if (f != 0) { MessageBox.Show("Almacenado exitosamente", "Cliente almacenado", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); CargarFalseAst(); } } }
private void verTodosToolStripMenuItem_Click(object sender, EventArgs e) { Clientes f = new Clientes(); DataCliente dc = new DataCliente(); dc.MdiParent = this; f.Dispose(); dc.Show(); }