private void btnSearch_Click(object sender, EventArgs e) { if (!filledValues()) { //MessageBox.Show("Complete la información"); } else { Cursor.Current = Cursors.WaitCursor; serviceDA = new DBControllerWSClient(); cliente = (serviceDA.queryByIdCustomer(txtDniRuc.Text)); Cursor.Current = Cursors.Arrow; if (cliente.id != null) { ModificarClienteForm modClient = new ModificarClienteForm(); modClient.currentCustomer = new customer(); serviceDA = new DBControllerWSClient(); modClient.currentCustomer = cliente; modClient.SetParent(this); modClient.ShowDialog(); updateDataGridView(); } else { MessageBox.Show("Cliente no encontrado"); } } }
private void btnEditClient_Click(object sender, EventArgs e) { int i = dgvClients.CurrentCell.RowIndex; if (i >= 0) { ModificarClienteForm modClient = new ModificarClienteForm(); modClient.currentCustomer = new customer(); customer e1 = new customer(); serviceDA = new DBControllerWSClient(); e1 = serviceDA.queryByIdCustomer(dgvClients.Rows[i].Cells[0].Value.ToString()); modClient.currentCustomer = e1; modClient.ShowDialog(); updateDataGridView(); } else { MessageBox.Show("Seleccione un cliente"); } }
private bool filledValues() { if (cbTipoCliente.Text == "") { MessageBox.Show("Seleccione el tipo de cliente"); return(false); } else if (cbTipoCliente.Text == "Natural" && txtClienteID.Text.Length != 8) { MessageBox.Show("Ingrese un DNI valido de 8 dígitos númericos"); return(false); } else if (cbTipoCliente.Text == "Natural" && txtClienteID.Text.Length == 8) { int result = 0; if (!int.TryParse(txtClienteID.Text, out result)) { MessageBox.Show("Ha ingresado caracteres no númericos en el campo DNI, ingrese 8 dígitos númericos "); return(false); } } else if (cbTipoCliente.Text == "Jurídica" && txtClienteID.Text.Length != 11) { MessageBox.Show("Ingrese un RUC valido de 11 dígitos númericos"); return(false); } else if (cbTipoCliente.Text == "Jurídica" && txtClienteID.Text.Length == 11) { //int result = 0; if (!Regex.Match(txtPhone.Text, @"([0-9]{11})").Success) { MessageBox.Show("Ha ingresado caracteres no númericos en el campo del RUC, ingrese 11 dígitos númericos "); return(false); } } if (txtDesc.Text == "") { MessageBox.Show("Ingrese la razón social o nombre del cliente válida (Mayor a 0 y menor a 50 caracteres)"); return(false); } if (txtAddress.Text == "") { MessageBox.Show("Ingrese una dirección del cliente valida (Mayor a 0 y menor a 50 caracteres)"); return(false); } if (txtOccupation.Text == "") { MessageBox.Show("Ingrese una ocupación del cliente valida (Mayor a 0 y menor a 50 caracteres)"); return(false); } if (txtEmail.Text == "" || !txtEmail.Text.Contains("@")) { MessageBox.Show("Ingrese un correo válido "); return(false); } if (txtPhone.Text == "" || txtPhone.Text.Length < 3) { MessageBox.Show("Ingrese un teléfono válido (Mayor a 3 y menor a 15 digitos)"); return(false); } if (txtPhone.Text.Length >= 3) { //int result = 0; if (!Regex.Match(txtPhone.Text, @"([0-9]{3,})").Success) { MessageBox.Show("Ha ingresado caracteres no númericos en el campo del Telefono, ingrese de 3 a 15 dígitos "); return(false); } } Cursor.Current = Cursors.WaitCursor; serviceDA = new DBControllerWSClient(); customer c = serviceDA.queryByIdCustomer(txtClienteID.Text); Cursor.Current = Cursors.Arrow; if (c.descriptionCustomer != null) { MessageBox.Show("Ya existe un cliente con ese DNI/RUC"); return(false); } return(true); }