Exemple #1
0
        private void CastForm_ondgvDoubleClick(object sender, EventArgs e)
        {
            foreach (Form formulario in this.formsAbiertos)
            {
                if (formulario is FrmAgregarProveedor castForm)
                {
                    castForm.IsEditar = true;
                    castForm.AsignarDatos(DatagridString.ReturnValuesOfCells(sender, 0));
                    castForm.WindowState = FormWindowState.Normal;
                    castForm.Show();
                    castForm.Activate();
                    return;
                }
            }

            FrmAgregarProveedor form = new FrmAgregarProveedor
            {
                StartPosition = FormStartPosition.CenterScreen,
                Name          = "FrmAgregarProveedor",
                IsEditar      = true
            };

            form.AsignarDatos(DatagridString.ReturnValuesOfCells(sender, 0));
            form.FormClosed += Frm_FormClosed;
            form.Show();
            Form frm = (Form)form;

            this.formsAbiertos.Add(frm);
        }
Exemple #2
0
        private void BuscarDetallePlatos(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable table =
                    NPlatos.BuscarDetallePlatos(tipo_busqueda, texto_busqueda);
                this.dgvInsumosUsados.DataSource = table;
                if (table != null)
                {
                    this.lblins.Text = "Insumos usados " + table.Rows.Count;

                    string[] columnsHeader =
                    {
                        "Id detalle", "Id plato", "Id insumos", "Insumo", "Cantidad", "Cantidad usada", "Id tipo insumo", "Tipo"
                    };
                    bool[] columnsVisible =
                    {
                        false, false, false, true, false, true, false, false
                    };
                    this.dgvInsumosUsados =
                        DatagridString.ChangeHeaderTextAndVisible(this.dgvInsumosUsados, columnsHeader, columnsVisible);
                }
                else
                {
                    this.lblins.Text = "No hay insumos agregados";
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarDetallePlatos",
                                              "Hubo un error al buscar un detalle", ex.Message);
            }
        }
 private void DgvInsumos_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvInsumos.Enabled)
         {
             string rpta = "";
             int    fila = this.dgvInsumos.CurrentRow.Cells[0].RowIndex;
             if (this.agregarInsumos != null)
             {
                 this.agregarInsumos.ObtenerDatos(DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                 this.Close();
             }
             else if (this.detallePlato != null)
             {
                 this.detallePlato.DatosInsumos(DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
             }
         }
     }
     catch (Exception ex)
     {
         Mensajes.MensajeErrorCompleto(this.Name, "DgvInsumos_DoubleClick",
                                       "Hubo un error con la tabla de datos", ex.Message);
     }
 }
Exemple #4
0
        private void DgvPlatos_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow row = this.dgvPlatos.CurrentRow;
                if (this.dgvPlatos.Enabled && this.dgvPlatos.Focused && row != null)
                {
                    string rpta = "OK";
                    int    fila = this.dgvPlatos.CurrentRow.Cells[0].RowIndex;
                    if (this.FrmAgregarPlato != null)
                    {
                        this.FrmAgregarPlato.ObtenerDatos
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                    }
                    else if (this.agregarDetallePlato != null)
                    {
                        this.agregarDetallePlato.ObtenerDatosPlato
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                    }
                    else if (this.InactivarPlatos)
                    {
                        Mensajes.MensajePregunta("¿Seguro desea inactivar el plato?",
                                                 "Continuar", "Cancelar", out DialogResult dialog);
                        if (dialog == DialogResult.Yes)
                        {
                            int id_plato = Convert.ToInt32(row.Cells["Id_plato"].Value);
                            rpta = NPlatos.InactivarPlato(id_plato);
                            if (rpta.Equals("OK"))
                            {
                                Mensajes.MensajeOkForm("Se inactivó el plato correctamente");
                                this.BuscarPlatos("COMPLETO", "");
                                return;
                            }
                            else
                            {
                                throw new Exception(rpta);
                            }
                        }
                    }

                    if (rpta.Equals("OK"))
                    {
                        this.Close();
                    }
                    else
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "DgvPlatos_DoubleClick",
                                              "Hubo un error con la tabla de datos", ex.Message);
            }
        }
        private void BuscarBebidas(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                string    estado = this.rdActivo.Checked ? "ACTIVO" : "INACTIVO";
                DataTable Tabla  =
                    NBebidas.BuscarBebida(tipo_busqueda, texto_busqueda, estado, out string rpta);
                if (Tabla != null)
                {
                    this.dgvBebidas.Enabled  = true;
                    this.dgvBebidas.Enabled  = true;
                    this.dgvBebidas.PageSize = 25;
                    this.dgvBebidas.SetPagedDataSource(Tabla, this.bindingNavigator1);

                    this.lblResultados.Text =
                        "Se encontraron " + Tabla.Rows.Count + " bebidas";
                    string[] columns_header_text =
                    {
                        "Id bebida",    "Nombre",             "Precio",
                        "Precio trago", "Precio trago doble", "Precio proveedor",
                        "Id proveedor", "Imagen",             "Id Tipo",         "Cantidad (Unidades)","Cantidad por unidad", "Cantidad total", "Estado",
                        "Id tipo",      "Tipo"
                    };

                    bool[] columns_visible =
                    {
                        false, true, true, false, false, false, false, false, false, true, true, true, false, false, true
                    };

                    this.dgvBebidas =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvBebidas, columns_header_text, columns_visible);
                }
                else
                {
                    this.dgvBebidas.clearDataSource();
                    this.dgvBebidas.Enabled = false;
                    this.lblResultados.Text =
                        "No se encontraron bebidas";

                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarBebidas",
                                              "Hubo un error al buscar una bebida", ex.Message);
            }
        }
Exemple #6
0
        private void DgvEmpleados_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvEmpleados.Enabled)
                {
                    int    fila = this.dgvEmpleados.CurrentRow.Cells[0].RowIndex;
                    string rpta = "SIN ACCION";
                    if (this.FrmAgregarEmpleado != null)
                    {
                        rpta = "";
                        this.FrmAgregarEmpleado.ObtenerDatos
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                    }
                    else if (this.venta)
                    {
                        rpta              = "";
                        this.Tag          = DatagridString.ReturnValuesOfCells(sender, fila, out rpta);
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else if (this.facturar_pedido)
                    {
                        rpta              = "";
                        this.Tag          = DatagridString.ReturnValuesOfCells(sender, fila, out rpta);
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }

                    if (this.OnDataRow != null)
                    {
                        this.OnDataRow?.Invoke(dgvEmpleados.CurrentRow, e);
                        this.Close();
                    }

                    if (rpta.Equals("OK"))
                    {
                        this.Close();
                    }
                    else if (!rpta.Equals("SIN ACCION"))
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "DgvEmpleados_DoubleClick",
                                              "Hubo un error con la tabla de datos", ex.Message);
            }
        }
Exemple #7
0
        private Cliente GetCliente(object row)
        {
            Cliente       cliente = new Cliente();
            List <string> vs      = DatagridString.ReturnValuesOfCells(row, 0);

            foreach (string ca in vs)
            {
                cliente.Id_cliente    = Convert.ToInt32(vs[0]);
                cliente.Fecha_ingreso = Convert.ToDateTime(vs[1]);
                cliente.Nombre        = Convert.ToString(vs[2]);
                cliente.Telefono      = Convert.ToString(vs[3]);
                cliente.Correo        = Convert.ToString(vs[4]);
            }
            return(cliente);
        }
        private void BuscarPedido(int id_pedido)
        {
            try
            {
                string    rpta = "";
                DataTable tablaDetalle;
                TablaDatosPrincipales =
                    NPedido.BuscarPedidosYDetalle("ID PEDIDO", Convert.ToString(this.Id_pedido),
                                                  out tablaDetalle, out rpta);
                this.TablaDetalle = tablaDetalle;

                this.dgvPedido.DataSource = TablaDetalle;
                if (this.TablaDetalle != null)
                {
                    this.dgvPedido.Enabled = true;
                    string[] columnsHeaderText =
                    {
                        "Id pedido", "Id tipo", "Tipo", "Nombre", "Precio", "Cantidad", "Total", "Observaciones"
                    };
                    bool[] columnsVisible =
                    {
                        false, false, false, true, true, true, true, true
                    };
                    this.dgvPedido =
                        DatagridString.ChangeHeaderTextAndVisible(this.dgvPedido, columnsHeaderText, columnsVisible);
                }
                else
                {
                    this.dgvPedido.Enabled = false;
                }

                if (this.TablaDatosPrincipales != null)
                {
                    this.ContextMenuDatosPedido.txtCliente.Text = Convert.ToString(TablaDatosPrincipales.Rows[0]["Cliente"]);
                    this.ContextMenuDatosPedido.txtCliente.Tag  = Convert.ToString(TablaDatosPrincipales.Rows[0]["Id_cliente"]);
                    this.lblIdPedido.Text = Convert.ToString(TablaDatosPrincipales.Rows[0]["Id_pedido"]);
                    this.lblEmpleado.Text = "Mesero encargado: " + Convert.ToString(TablaDatosPrincipales.Rows[0]["Nombre_empleado"]);

                    this.lblMesa.Text = Convert.ToString(TablaDatosPrincipales.Rows[0]["Num_mesa"]);
                }
            }
            catch (Exception ex)
            {
                this.dgvPedido.Enabled = false;
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarPedido",
                                              "Hubo un error al buscar un pedido", ex.Message);
            }
        }
Exemple #9
0
        private void DgvClientes_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow row = this.dgvClientes.CurrentRow;
                if (this.dgvClientes.Enabled & row != null)
                {
                    string rpta = "OK";
                    int    fila = this.dgvClientes.CurrentRow.Cells[0].RowIndex;
                    if (this.FrmAgregarCliente != null)
                    {
                        this.FrmAgregarCliente.ObtenerDatos
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                        this.Close();
                    }
                    else if (this.menuPedido != null)
                    {
                        this.menuPedido.ObtenerCliente
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else if (this.venta)
                    {
                        rpta = "OK";
                        this.DialogResult = DialogResult.OK;
                        this.Tag          = DatagridString.ReturnValuesOfCells(sender, fila, out rpta);
                    }

                    this.OnDgvDoubleClick?.Invoke(row, e);

                    if (rpta.Equals("OK"))
                    {
                        this.Close();
                    }
                    else
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "DgvClientes_DoubleClick",
                                              "Hubo un error con la tabla de datos", ex.Message);
            }
        }
 private void DgvProductos_DataSourceChanged(object sender, EventArgs e)
 {
     try
     {
         bool[] columns_visible =
         {
             false, true, true
         };
         this.dgvProductos =
             DatagridString.ChangeColumnsVisible(this.dgvProductos, columns_visible);
     }
     catch (Exception ex)
     {
         Mensajes.MensajeErrorCompleto(this.Name, "DgvProductos_DataSourceChanged",
                                       "Hubo un error al cambiar las propiedades de la columna en el dgv", ex.Message);
     }
 }
Exemple #11
0
        private void BuscarTipoArticulos(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable tableTipoArticulos =
                    NTipo_articulos.BuscarTipoArticulos(tipo_busqueda, texto_busqueda, out string rpta);
                if (tableTipoArticulos != null)
                {
                    this.dgvTipoArticulos.Enabled  = true;
                    this.dgvTipoArticulos.PageSize = 30;
                    this.dgvTipoArticulos.SetPagedDataSource(tableTipoArticulos, this.bindingNavigator1);

                    string[] columns_header =
                    {
                        "Id tipo artículo", "Nombre", "Descripción"
                    };

                    bool[] columns_visible =
                    {
                        false, true, true
                    };

                    this.dgvTipoArticulos =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvTipoArticulos,
                                                                                columns_header, columns_visible);
                    this.lblResultados.Text = "Se encontraron " + tableTipoArticulos.Rows.Count + " tipos de artículos";
                }
                else
                {
                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }

                    this.dgvTipoArticulos.clearDataSource();
                    this.dgvTipoArticulos.Enabled = false;
                    this.lblResultados.Text       = "No se encontraron tipos de artículos";
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarProveedores",
                                              "Hubo un error al buscar un tipo de artículo", ex.Message);
            }
        }
Exemple #12
0
        private void BuscarProveedores(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable tableProveedores =
                    NProveedores.BuscarProveedores(tipo_busqueda, texto_busqueda, out string rpta);
                if (tableProveedores != null)
                {
                    this.dgvProveedores.Enabled  = true;
                    this.dgvProveedores.PageSize = 30;
                    this.dgvProveedores.SetPagedDataSource(tableProveedores, this.bindingNavigator1);

                    string[] columns_header =
                    {
                        "Id proveedor", "Fecha ingreso", "Nombre", "Teléfono", "Correo electrónico"
                    };

                    bool[] columns_visible =
                    {
                        false, false, true, true, true
                    };

                    this.dgvProveedores =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvProveedores,
                                                                                columns_header, columns_visible);
                    this.lblResultados.Text = "Se encontraron " + tableProveedores.Rows.Count + " proveedores";
                }
                else
                {
                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }

                    this.dgvProveedores.clearDataSource();
                    this.dgvProveedores.Enabled = false;
                    this.lblResultados.Text     = "No se encontraron proveedores";
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarProveedores",
                                              "Hubo un error al buscar un proveedor", ex.Message);
            }
        }
        private void BuscarVentas(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                string fecha1 = this.date1.Value.ToShortDateString();
                string fecha2 = this.date2.Value.ToShortDateString();
                string hora1  = this.ListaHora1.SelectedValue.ToString();
                string hora2  = this.ListaHora2.SelectedValue.ToString();

                DataTable tablaVenta =
                    NVentas.BuscarVenta(tipo_busqueda, texto_busqueda, fecha1, fecha2, hora1, hora2);
                this.dgvVentas.DataSource = tablaVenta;
                if (tablaVenta != null)
                {
                    this.btnResumen.Enabled = true;
                    string[] columns_header =
                    {
                        "Id venta",  "Id pedido",    "Fecha",       "Hora",          "Total parcial", "Propina",        "Subtotal",
                        "Descuento", "Bono o cupón", "Total",       "Observaciones", "Id cliente",    "Nombre cliente",
                        "Id mesa",   "Mesa",         "Id empleado", "Empleado"
                    };
                    bool[] columns_visible =
                    {
                        false, false, true,  true,  true, true,  true, true,
                        false, true,  false, false, true, false, true, false, true
                    };
                    this.dgvVentas =
                        DatagridString.ChangeHeaderTextAndVisible(this.dgvVentas, columns_header, columns_visible);

                    //this.dgvVentas.Columns["Hora_venta"].DefaultCellStyle.Format = "HH:mm";

                    this.resumenVenta.ObtenerVenta(Convert.ToDateTime(fecha1), Convert.ToDateTime(fecha2),
                                                   hora1, hora2);
                }
                else
                {
                    this.btnResumen.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarVentas", "Hubo un error al buscar una venta", ex.Message);
            }
        }
Exemple #14
0
        private void Buscar(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable dtPedidosEliminados =
                    NPedido.BuscarPedidosEliminados(tipo_busqueda, texto_busqueda);
                if (dtPedidosEliminados != null)
                {
                    this.dgvPedidosEliminados.Enabled  = true;
                    this.dgvPedidosEliminados.PageSize = 15;
                    this.dgvPedidosEliminados.SetPagedDataSource(dtPedidosEliminados, this.bindingNavigator1);

                    lblRespuesta.Text =
                        "Se encontraron " + dtPedidosEliminados.Rows.Count + " pedidos eliminados";

                    string[] columns_header_text =
                    {
                        "Id pedido", "Id usuario clave maestra", "Ingresó clave maestra",   "Id tipo", "Tipo", "Fecha", "Hora", "Motivo", "Nombre producto",
                        "Precio",    "Id usuario sesion",        "Tenía la sesión abierta", "Cargo",   "Teléfono"
                    };
                    bool[] columns_visible =
                    {
                        false, false, true, false, true, true, true, true, true, true, false, true, false, false
                    };
                    this.dgvPedidosEliminados =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvPedidosEliminados,
                                                                                columns_header_text, columns_visible);
                    this.dgvPedidosEliminados.Columns["Precio"].DefaultCellStyle.Format = "C";
                    this.dgvPedidosEliminados.Columns["Hora"].DefaultCellStyle.Format   = "hh:mm tt";
                }
                else
                {
                    this.dgvPedidosEliminados.clearDataSource();
                    this.dgvPedidosEliminados.Enabled = false;
                    lblRespuesta.Text = "No se encontraron pedidos eliminados";
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "Buscar",
                                              "Hubo un error al Buscar los pedidos eliminados",
                                              ex.Message);
            }
        }
        private void BuscarInsumos(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable table =
                    NInsumos.BuscarInsumos(tipo_busqueda, texto_busqueda, out string rpta);
                if (table != null)
                {
                    this.dgvInsumos.Enabled = true;
                    this.lblResultados.Text = "Se encontraron " + table.Rows.Count + " insumos";

                    this.dgvInsumos.PageSize = 25;
                    this.dgvInsumos.SetPagedDataSource(table, this.bindingNavigator1);

                    string[] columns_text_header =
                    {
                        "Id insumo", "Nombre", "Id tipo insumo", "Cantidad", "Medida", "Observaciones", "Id tipo insumo", "Tipo"
                    };
                    bool[] columns_visible =
                    {
                        false, true, false, true, true, true, false, true
                    };
                    this.dgvInsumos =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvInsumos, columns_text_header, columns_visible);
                }
                else
                {
                    this.dgvInsumos.clearDataSource();
                    this.dgvInsumos.Enabled = false;
                    this.lblResultados.Text = "No se encontraron insumos";

                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarInsumos",
                                              "Hubo un error al buscar insumos", ex.Message);
            }
        }
Exemple #16
0
        private void CrearTabla()
        {
            this.DtInsumos = new DataTable();
            this.DtInsumos.Columns.Add("Id_insumo", typeof(string));
            this.DtInsumos.Columns.Add("Nombre_insumo", typeof(string));
            this.DtInsumos.Columns.Add("Id_tipo_insumo", typeof(string));
            this.DtInsumos.Columns.Add("Tipo_insumo", typeof(string));
            this.DtInsumos.Columns.Add("Cantidad_usada", typeof(string));
            this.dgvInsumos.DataSource = this.DtInsumos;

            string[] columns_header =
            {
                "Id insumo", "Insumo", "Id tipo insumo", "Tipo", "Cantidad"
            };
            bool[] columns_visible =
            {
                false, true, false, true, true
            };

            this.dgvInsumos =
                DatagridString.ChangeHeaderTextAndVisible(this.dgvInsumos, columns_header, columns_visible);
        }
Exemple #17
0
 private void BuscarEmpleados(string tipo_busqueda, string texto_busqueda)
 {
     try
     {
         string    rpta;
         DataTable Tabla =
             NEmpleados.BuscarEmpleados(tipo_busqueda, texto_busqueda, out rpta);
         this.dgvEmpleados.DataSource = Tabla;
         if (Tabla != null)
         {
             this.dgvEmpleados.Enabled = true;
             this.lblResultados.Text   = "Se encontraron " + Tabla.Rows.Count + " empleados";
             string[] columns_header_text =
             {
                 "Id empleado", "Nombre", "Teléfono", "Correo electrónico", "Cargo", "Contraseña", "Clave maestra", "Estado"
             };
             this.dgvEmpleados =
                 DatagridString.ChangeColumnsHeaderText(this.dgvEmpleados, columns_header_text);
             bool[] columns_visible =
             {
                 false, true, true, true, true, false, false, false, false
             };
             this.dgvEmpleados =
                 DatagridString.ChangeColumnsVisible(this.dgvEmpleados, columns_visible);
             this.CargarPanelColumnas(this.dgvEmpleados);
         }
         else
         {
             this.dgvEmpleados.Enabled = false;
             this.lblResultados.Text   = "No se encontraron empleados";
         }
     }
     catch (Exception ex)
     {
         Mensajes.MensajeErrorCompleto(this.Name, "BuscarEmpleados",
                                       "Hubo un error al buscar un empleado", ex.Message);
     }
 }
        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();
            }
        }
Exemple #19
0
 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 ActualizarProductos()
        {
            this.dgvProductos.DataSource =
                this.tablasPedido.dtVistaPedido();
            if (this.dgvProductos.DataSource != null)
            {
                bool[] columns_visible =
                {
                    false, true, true, true, true, true
                };
                this.dgvProductos = DatagridString.ChangeColumnsVisible(this.dgvProductos, columns_visible);
            }

            if (this.IsEditar)
            {
                this.dgvProductosEditar.DataSource =
                    this.tablasPedido.dtDetallePedidoEditado();
                bool[] columns_visible =
                {
                    false, true, true, true, true, true
                };
                this.dgvProductosEditar = DatagridString.ChangeColumnsVisible(this.dgvProductosEditar, columns_visible);
            }
        }
        private void AsignarDatos()
        {
            try
            {
                if (Row_venta != null)
                {
                    this.Id_pedido              = Convert.ToInt32(Row_venta.Cells["Id_pedido"].Value);
                    this.lblId_venta.Text      += " " + Convert.ToString(Row_venta.Cells["Id_venta"].Value);
                    this.lblIdPedido.Text      += " " + Convert.ToString(Row_venta.Cells["Id_pedido"].Value);
                    this.lblFecha.Text         += " " + Convert.ToDateTime(Row_venta.Cells["Fecha_venta"].Value).ToLongDateString();
                    this.lblHora.Text          += " " + Convert.ToDateTime(Row_venta.Cells["Hora_venta"].Value).ToLongTimeString();
                    this.lblMesa.Text          += " " + Convert.ToString(Row_venta.Cells["Num_mesa"].Value);
                    this.lblEmpleado.Text      += " " + Convert.ToString(Row_venta.Cells["Nombre_empleado"].Value);
                    this.lblCliente.Text       += " " + Convert.ToString(Row_venta.Cells["Nombre_cliente"].Value);
                    this.lblTotal_parcial.Text += " " + Convert.ToInt32(Row_venta.Cells["Total_parcial"].Value).ToString("C");
                    this.lblPropina.Text       += " " + Convert.ToInt32(Row_venta.Cells["Propina"].Value).ToString("C");
                    this.lblSubTotal.Text      += " " + Convert.ToInt32(Row_venta.Cells["Subtotal"].Value).ToString("C");
                    this.lblDescuento.Text     += " " + Convert.ToString(Row_venta.Cells["Descuento"].Value);
                    this.lblTotalFinal.Text    += " " + Convert.ToInt32(Row_venta.Cells["Total_final"].Value).ToString("C");
                    this.txtObservaciones.Text  = Convert.ToString(Row_venta.Cells["Observaciones"].Value);

                    DataTable dtDetallePedido;
                    DataTable dtDetalleVenta;
                    DataTable DatosPrincipales = NVentas.BuscarVentaFinal(this.Id_pedido.ToString(), out dtDetallePedido, out dtDetalleVenta);

                    this.dgvPagos =
                        ConfiguracionDatagridview.ConfigurationGrid(this.dgvPagos);

                    this.dgvDetalle_pedido =
                        ConfiguracionDatagridview.ConfigurationGrid(this.dgvDetalle_pedido);

                    this.dgvDetalle_pedido.DataSource = dtDetallePedido;
                    this.dgvPagos.DataSource          = dtDetalleVenta;

                    if (dtDetallePedido != null)
                    {
                        string[] columns_header =
                        {
                            "Id pedido", "Id tipo", "Tipo", "Nombre", "Precio", "Cantidad", "Total", "Observaciones"
                        };
                        bool[] columns_visible =
                        {
                            false, false, false, true, true, true, true, true
                        };
                        this.dgvDetalle_pedido = DatagridString.ChangeHeaderTextAndVisible(this.dgvDetalle_pedido, columns_header, columns_visible);
                    }

                    if (dtDetalleVenta != null)
                    {
                        string[] columns_header =
                        {
                            "Id venta", "Método de pago", "Valor", "Vaucher", "Observaciones"
                        };
                        bool[] columns_visible =
                        {
                            false, true, true, false, true
                        };
                        this.dgvPagos = DatagridString.ChangeHeaderTextAndVisible(this.dgvPagos, columns_header, columns_visible);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "AsignarDatos()",
                                              "Hubo un error al asignar los datos de la venta", ex.Message);
            }
        }
        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();
            }
        }