private void DatosUsuario_Load(object sender, EventArgs e) { DataTable table = NClientes.BuscarClientes("ID CLIENTE", this.Id_cliente.ToString()); if (table != null) { string rpta; if (this.panel1.Controls.Count > 0) { this.panel1.Controls.RemoveAt(0); } FrmAgregarCliente Frm = new FrmAgregarCliente(); Frm.ObtenerDatos(DatagridString.ReturnValuesOfCells(table, 0, out rpta)); Frm.TopLevel = false; Frm.IsPedido = true; Frm.onChangedEmail += Frm_onChangedEmail; Frm.FormBorderStyle = FormBorderStyle.None; Frm.Dock = DockStyle.Fill; this.panel1.Controls.Add(Frm); this.panel1.Tag = Frm; Frm.Show(); } }
private void BuscarClientes(string tipo_busqueda, string texto_busqueda) { try { DataTable Tabla = NClientes.BuscarClientes(tipo_busqueda, texto_busqueda); this.dgvClientes.DataSource = Tabla; if (Tabla != null) { this.lblResultados.Text = "Se encontraron " + Tabla.Rows.Count + " clientes"; this.dgvClientes.Enabled = true; string[] columns_header_text = { "Id cliente", "Nombre", "Teléfono", "Correo electrónico" }; this.dgvClientes = DatagridString.ChangeColumnsHeaderText(this.dgvClientes, columns_header_text); bool[] columns_visible = { false, true, true, true }; this.dgvClientes = DatagridString.ChangeColumnsVisible(this.dgvClientes, columns_visible); } else { this.lblResultados.Text = "No se encontraron clientes"; this.dgvClientes.Enabled = false; } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "BuscarClientes", "Hubo un error con la tabla de datos", ex.Message); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { if (this.Comprobaciones()) { string mensaje = ""; string rpta = ""; int id_cliente; if (this.IsEditar) { rpta = NClientes.EditarClientes(this.Variables(), this.Id_cliente); mensaje = "Se actualizó correctamente los datos del cliente"; } else { rpta = NClientes.InsertarClientes(this.Variables(), out id_cliente); mensaje = "Se guardó correctamente el cliente"; } if (rpta.Equals("OK")) { Mensajes.MensajeOkForm(mensaje); this.Limpiar(); } else { throw new Exception(rpta); } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click", "Hubo un error al guardar un cliente", ex.Message); } }
public DataTable ProductosDataSet(DataTable dt) { dt = NClientes.ListarClientes(1); return(dt); }
public void CargarClientes() { this.comboBoxClientes.DataSource = NClientes.ListaClientes(); this.comboBoxClientes.ValueMember = "ID"; this.comboBoxClientes.DisplayMember = "NOMBRE"; }
//btnAgregarActualizar - Evento Click - Inserta o edita un cliente en la base de datos. private void btnAgregarActualizar_Click(object sender, EventArgs e) { //Declaración de variables. string Respuesta; decimal TelefonoFiscal = 0; decimal Telefono1 = 0; decimal Telefono2 = 0; decimal Telefono3 = 0; if (this.lblTitulo.Text == "Nuevo Cliente") { //Revisión de datos obligatorios if (String.IsNullOrWhiteSpace(txtRazonSocial.Text)) { MessageBox.Show("Debe ingresar la razón social de la empresa.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtRazonSocial, "Ingrese una razón social."); } else if (String.IsNullOrWhiteSpace(cbxTipoDocumento.Text)) { MessageBox.Show("Debe ingresar un tipo de documento.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(cbxTipoDocumento, "Ingrese un tipo de documento."); } else if (String.IsNullOrWhiteSpace(cbxClaseDocumento.Text)) { MessageBox.Show("Debe ingresar una clase de documento.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(cbxClaseDocumento, "Ingrese una clase de documento."); } else if (String.IsNullOrWhiteSpace(txtNumDocumento.Text)) { MessageBox.Show("Debe ingresar un número de documento.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtNumDocumento, "Ingrese un número de documento."); } else if (String.IsNullOrWhiteSpace(txtTelefonoFiscal.Text)) { MessageBox.Show("Debe ingresar un nombre teléfono fiscal.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtTelefonoFiscal, "Ingrese un teléfono fiscal."); } else if (String.IsNullOrWhiteSpace(txtDireccion.Text)) { MessageBox.Show("Debe ingresar una dirección fiscal.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtDireccion, "Ingrese una dirección fiscal."); } else { if (this.txtTelefonoFiscal.Text != "") { TelefonoFiscal = Convert.ToDecimal(this.txtTelefonoFiscal.Text.Replace("(", "").Replace(") ", "") .Replace("-", "")); } if (this.txtTelefono1.Text != "") { Telefono1 = Convert.ToDecimal(this.txtTelefono1.Text.Replace("(", "").Replace(") ", "").Replace("-", "")); } if (this.txtTelefono2.Text != "") { Telefono2 = Convert.ToDecimal(txtTelefono2.Text.Replace("(", "").Replace(") ", "").Replace("-", "")); } if (this.txtTelefono3.Text != "") { Telefono3 = Convert.ToDecimal(txtTelefono3.Text.Replace("(", "").Replace(") ", "").Replace("-", "")); } //Ingresa los datos en la base de datos. Respuesta = NClientes.Insertar(txtRazonSocial.Text, cbxTipoDocumento.Text + ": " + cbxClaseDocumento.Text + "-" + txtNumDocumento.Text, txtDireccion.Text, TelefonoFiscal, txtPersonaContacto.Text, Telefono1, Telefono2, Telefono3, txtCorreo1.Text, txtCorreo2.Text, txtEntrega1.Text, txtEntrega2.Text, txtEntrega3.Text, txtEntrega4.Text, txtEntrega5.Text, this.ctrlClientes.IdUsuario); if (Respuesta == "OK") { //Muestra confirmación al usuario via MessageBox. MessageBox.Show("El cliente fue ingresado en el sistema satisfactoriamente.", String.Format(Configuracion.Titulo, "Registro Exitoso"), MessageBoxButtons.OK, MessageBoxIcon.Information); ctrlClientes.Mostrar(); ctrlClientes.Mensaje(String.Format("El cliente {0} ha sido AGREGADO satisfactoriamente. ", txtRazonSocial.Text)); this.Close(); } else { //Muestra Respuesta error al usuario mediante MessageBox MessageBox.Show(Respuesta, String.Format(Configuracion.Titulo, "Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else if (this.lblTitulo.Text == "Editar Cliente") { //Revisión de datos obligatorios. if (String.IsNullOrWhiteSpace(txtRazonSocial.Text)) { MessageBox.Show("Debe ingresar la razón social del cliente.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtRazonSocial, "Ingrese la razón social."); } else if (String.IsNullOrWhiteSpace(txtNumDocumento.Text)) { MessageBox.Show("Debe ingresar un número de documento.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtNumDocumento, "Ingrese un número de documento."); } else if (String.IsNullOrWhiteSpace(txtTelefonoFiscal.Text)) { MessageBox.Show("Debe ingresar un teléfono fiscal.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtTelefonoFiscal, "Ingrese un teléfono."); } else if (String.IsNullOrWhiteSpace(txtDireccion.Text)) { MessageBox.Show("Debe ingresar una dirección fiscal.", String.Format(Configuracion.Titulo, "Dato Inválido"), MessageBoxButtons.OK, MessageBoxIcon.Warning); this.errorProvider.SetError(txtTelefonoFiscal, "Ingrese una dirección."); } else { if (this.txtTelefonoFiscal.Text != "") { TelefonoFiscal = Convert.ToDecimal(this.txtTelefonoFiscal.Text.Replace("(", "").Replace(") ", "") .Replace("-", "")); } if (this.txtTelefono1.Text != "") { Telefono1 = Convert.ToDecimal(this.txtTelefono1.Text.Replace("(", "").Replace(") ", "").Replace("-", "")); } if (this.txtTelefono2.Text != "") { Telefono2 = Convert.ToDecimal(txtTelefono2.Text.Replace("(", "").Replace(") ", "").Replace("-", "")); } if (this.txtTelefono3.Text != "") { Telefono3 = Convert.ToDecimal(txtTelefono3.Text.Replace("(", "").Replace(") ", "").Replace("-", "")); } Respuesta = NClientes.Editar(this.IdCliente, this.txtRazonSocial.Text, this.cbxTipoDocumento.Text + ": " + this.cbxClaseDocumento.Text + "-" + this.txtNumDocumento.Text, this.txtDireccion.Text, TelefonoFiscal, this.txtPersonaContacto.Text, Telefono1, Telefono2, Telefono3, this.txtCorreo1.Text, this.txtCorreo2.Text, this.txtEntrega1.Text, this.txtEntrega2.Text, this.txtEntrega3.Text, this.txtEntrega4.Text, this.txtEntrega5.Text, ctrlClientes.IdUsuario); if (Respuesta == "OK") { //Muestra confirmación al usuario via MessageBox. MessageBox.Show(String.Format("Los datos del cliente {0} fueron modificados satisfactoriamente.", txtRazonSocial.Text), String.Format(Configuracion.Titulo, "Actualización de Datos Exitosa"), MessageBoxButtons.OK, MessageBoxIcon.Information); ctrlClientes.Mostrar(); ctrlClientes.Mensaje(String.Format("Los Datos del Cliente {0} fueron modificados satisfactoriamente.", txtRazonSocial.Text)); this.Close(); } else { //Muestra Respuesta error al usuario mediante MessageBox. MessageBox.Show(Respuesta, String.Format(Configuracion.Titulo, "Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public bool Comprobacion(out int id_cliente, out int id_direccion, out string observaciones) { bool result = true; id_cliente = 0; id_direccion = 0; observaciones = this.txtObservaciones.Text; if (this.listaCalleCarrera.Text.Equals("")) { result = false; this.errorProvider1.SetError(this.listaCalleCarrera, "Campo obligatorio"); } if (this.txtNumeroCalleCarrera.Text.Equals("")) { result = false; this.errorProvider1.SetError(this.txtNumeroCalleCarrera, "Campo obligatorio"); } if (this.txtNumero1.Text.Equals("")) { result = false; this.errorProvider1.SetError(this.txtNumero1, "Campo obligatorio"); } if (this.txtReferencias.Text.Equals("")) { result = false; this.errorProvider1.SetError(this.txtReferencias, "Escriba al menos 1 referencia"); } if (this.rdMismoCliente.Checked) { if (this.txtCliente.Tag == null) { result = false; this.errorProvider1.SetError(this.txtCliente, "Seleccione un cliente"); } } else { if (this.txtNombre.Text.Equals("")) { result = false; this.errorProvider1.SetError(this.txtNombre, "Escriba un nombre de la persona que recibe"); } if (this.txtTelefono.Text.Equals("")) { result = false; this.errorProvider1.SetError(this.txtTelefono, "Escriba el teléfono de la persona que recibe"); } } if (result) { //Insertar la dirección del cliente List <string> direccionCliente = new List <string>() { Convert.ToString(this.txtCliente.Tag), this.listaCalleCarrera.Text, this.txtNumeroCalleCarrera.Text, this.txtNumero1.Text, this.txtNumero2.Text, this.txtReferencias.Text }; id_cliente = Convert.ToInt32(this.txtCliente.Tag); string rpta = NClientes.InsertarDireccionClientes(direccionCliente, out id_direccion); if (rpta.Equals("OK")) { result = true; } else { result = false; } } return(result); }
private void buttonGuardar_Click(object sender, EventArgs e) { //direccion string calle = this.textBoxCalle.Text; string numero = this.textBoxNumero.Text; string depto = this.textBoxDepto.Text; string piso = this.textBoxPiso.Text; string cp = this.textBoxCP.Text; string ciudad = this.textBoxCiudad.Text; string provincia = this.textBoxProvincia.Text; string pais = this.textBoxPais.Text; string id_direccion = this.idDireccion.ToString(); List <string> dir = new List <string>(); dir.Add(calle); dir.Add(numero); dir.Add(piso); dir.Add(depto); dir.Add(cp); dir.Add(ciudad); dir.Add(provincia); dir.Add(pais); dir.Add(id_direccion); //cliente string nombre = this.textBoxNombre.Text; string apellido = this.textBoxApellido.Text; long cuil = 0; if (this.textBoxCuil.Text != "") { cuil = long.Parse(this.textBoxCuil.Text); } string razonSocial = this.textBoxRazonSocial.Text; long cuit = 0; if (this.textBoxCuit.Text != "") { cuit = long.Parse(this.textBoxCuit.Text); } string telFijo = this.textBoxTelFijo.Text; string telMovil = this.textBoxTelMovil.Text; string email = this.textBoxEmail.Text; int tipo = 0; if (radioButtonEmpresa.Checked == true) { tipo = 2; } else { tipo = 1; } String mensaje = NClientes.Editar(Id_Cliente, nombre, apellido, cuil, razonSocial, cuit, telFijo, telMovil, email, tipo, dir); if (mensaje == "Y") { this._owner.Mensaje(String.Format("El Cliente {0} ha sido EDITADO", this.textBoxNombre.Text + " " + this.textBoxApellido.Text)); this._owner.Refrescar(); this.Close(); } else { MensajeError(mensaje); } }
//Método Mostrar - Muestra los registros actuales en el "dgvClientes" y establece la cantidad de páginas. public void Mostrar() { this.dgvClientes.DataSource = NClientes.Mostrar(Configuracion.RegistrosPorPagina, Configuracion.NumeroPagina); Configuracion.CantidadPaginas = NClientes.Tamaño(Configuracion.RegistrosPorPagina); this.lblPaginacion.Text = String.Format("Página {0} de {1}.", Configuracion.NumeroPagina, Configuracion.CantidadPaginas); }
private void FrmRealizarPedido_Load(object sender, EventArgs e) { DialogResult dialog = this.Comprobacion(); if (dialog == DialogResult.OK) { this.comandas.ObtenerReporte(); this.lblMistico.Text = "Realizar un nuevo pedido para la mesa " + this.Numero_mesa; if (this.IsEditar) { try { string rpta; DataTable dtDetalle; DataTable dtPedido = NPedido.BuscarPedidosYDetalle("ID PEDIDO", this.Id_pedido.ToString(), out dtDetalle, out rpta); if (dtPedido != null) { this.lblMesero.Text = "Mesero: " + Convert.ToString(dtPedido.Rows[0]["Nombre_empleado"]); //Recorrer las tablas de pedido y detalle y crear las Listas this.tablasPedido = new TablasPedido(this.IsEditar, this.Id_pedido, dtDetalle); DataTable dtCliente = NClientes.BuscarClientes("ID CLIENTE", Convert.ToString(dtPedido.Rows[0]["Id_cliente"])); if (dtCliente != null) { this.contextMenuDatosPedido.ObtenerCliente(DatagridString.ReturnValuesOfCells(dtCliente, 0, out rpta)); } else { throw new Exception("No se encontró el cliente"); } Label lbl1 = new Label(); lbl1.AutoSize = true; lbl1.Location = new System.Drawing.Point(this.dgvProductos.Location.X, this.panelProductosParaAgregar.Location.Y + this.panelProductosParaAgregar.Height); this.Controls.Add(lbl1); this.chkImprimirComandas.Visible = true; this.chkImprimirComandas.Checked = true; this.panelProductosParaAgregar.Visible = true; this.dgvProductos.Location = new System.Drawing.Point(this.dgvProductos.Location.X, this.panelProductosParaAgregar.Location.Y + this.panelProductosParaAgregar.Height + lbl1.Height); this.dgvProductos = ConfiguracionDatagridview.ConfigurationGrid(this.dgvProductos); this.dgvProductosEditar = ConfiguracionDatagridview.ConfigurationGrid(this.dgvProductosEditar); this.btnQuitar.Location = new System.Drawing.Point(this.dgvProductos.Location.X - this.btnQuitarProductosEditado.Width - 2, this.dgvProductos.Location.Y); this.btnQuitarProductosEditado.Visible = true; } else { throw new Exception(rpta); } } catch (Exception ex) { Mensajes.MensajeErrorCompleto("TablasPedido.cs", "TablasPedido(bool isEditar, int id_pedido)", "Hubo un error al inicializar las tablas del pedido para editar", ex.Message); } this.ActualizarProductos(); } else { this.panelProductosParaAgregar.Visible = false; this.btnQuitarProductosEditado.Visible = false; this.dgvProductos = ConfiguracionDatagridview.ConfigurationGrid(this.dgvProductos); this.tablasPedido = new TablasPedido(); } } else { this.Close(); } }
//buscalo clientes segun el tipo (persona o empresa) y el nombre (nombre o razon social) public void BuscarClientes(int opcion, string nombre) { this.dataGridViewClientes.DataSource = NClientes.Buscar(opcion, nombre); this.dataGridViewClientes.AllowUserToAddRows = false; }