Exemple #1
0
        public void ConsultaCliente_Load(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM cliente;");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.Columns[0].ReadOnly = true;

            if (mantenimiento)
            {
                Form f = new cliente();
                this.Hide();
                f.ShowDialog();
                if (!mantenimiento2)
                {
                    this.Close();
                }
                else
                {
                    dt = oper.ExtraeData("SELECT * FROM cliente;");
                    dataGridView1.DataSource = dt;
                    dataGridView1.Refresh();
                    dataGridView1.Columns[0].ReadOnly = true;
                }
                mantenimiento  = false;
                mantenimiento2 = false;
            }
            else
            {
            }
        }
Exemple #2
0
        void GeneradasHoy()
        {
            //Mostrar facturas generadas el día de hoy
            //Para formatear la fecha
            if (DateTime.Now.Day < 10)
            {
                dia = "0" + DateTime.Now.Day.ToString();
            }
            else
            {
                dia = DateTime.Now.Day.ToString();
            }
            if (DateTime.Now.Month < 10)
            {
                mes = "0" + DateTime.Now.Month.ToString();
            }
            else
            {
                mes = DateTime.Now.Month.ToString();
            }
            año = DateTime.Now.Year.ToString();

            fechaf = año + "-" + mes + "-" + dia;

            dt = oper.ExtraeData("SELECT * from factura WHERE fecha = '" + fechaf + "'");
            dataGridView1update.DataSource = dt;
            dataGridView1update.Refresh();
            RellenarTablas();
        }
Exemple #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            int       lid;
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT seq FROM sqlite_sequence WHERE name = 'producto';");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.SelectAll();

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    tbpcodigo.Text = fila.Cells[0].Value.ToString();
                    lid            = Convert.ToInt32(tbpcodigo.Text);
                    lid++;
                    tbpcodigo.Text = Convert.ToString(lid);
                }
                catch (Exception)
                {
                }
            }

            tbpnombre.Text     = "";
            tbpcosto.Text      = "";
            tbpprecio.Text     = "";
            tbpexistencia.Text = "";

            //Para Cargar los Suplidores
            dt = oper.ExtraeData("SELECT nombre FROM suplidores;");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.SelectAll();
            tbpsuplidor.Items.Clear();
            tbpsuplidor.Text = "";

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    tbpsuplidor.Items.Add(fila.Cells[0].Value.ToString());
                }
                catch (Exception)
                {
                }
            }
            tbpsuplidor.SelectedIndex = 0;

            nuevo = true;
        }
        private void btmodificar_Click(object sender, EventArgs e)
        {
            suplidores.modificar = true;

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    suplidores.idmodificar = fila.Cells[0].Value.ToString();
                }
                catch (Exception)
                {
                }
            }
            Form f = new suplidores();

            f.ShowDialog();

            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM suplidores;");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
        }
Exemple #5
0
        public void RealizarBusqueda()
        {
            ids = tbpsearchcode.Text;
            tbpsearchcode.Text = "";

            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM producto WHERE id = '" + ids + "'");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.SelectAll();

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    tbpcodigo.Text     = fila.Cells[0].Value.ToString();
                    tbpnombre.Text     = fila.Cells[1].Value.ToString();
                    tbpcosto.Text      = fila.Cells[2].Value.ToString();
                    tbpprecio.Text     = fila.Cells[3].Value.ToString();
                    tbpexistencia.Text = fila.Cells[4].Value.ToString();
                    tbpsuplidor.Text   = fila.Cells[5].Value.ToString();
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #6
0
 private void Buscar_Producto_Load(object sender, EventArgs e)
 {
     //Al inicio del formulario para Buscar los productos escritos o mostrar todo
     dt = oper.ExtraeData("SELECT * FROM producto WHERE nombre LIKE '%" + busqueda + "%';");
     dataGridView1.DataSource = dt;
     dataGridView1.Refresh();
     dataGridView1.Columns[0].ReadOnly = true;
     if (dataGridView1.RowCount > 0 && !String.IsNullOrEmpty(busqueda))
     {
         dataGridView1.Select();
     }
     else
     {
         tbnombre.Select();
     }
 }
Exemple #7
0
        void RealizarBusqueda()
        {
            string ids = tbcsearchcode.Text;

            tbcsearchcode.Text = "";

            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM cliente WHERE id = '" + ids + "'");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.SelectAll();

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    tbccodigo.Text    = fila.Cells[0].Value.ToString();
                    tbcnombre.Text    = fila.Cells[1].Value.ToString();
                    tbcapellidos.Text = fila.Cells[2].Value.ToString();
                    tbccedula.Text    = fila.Cells[3].Value.ToString();
                    tbctelefono.Text  = fila.Cells[4].Value.ToString();
                    tbcdireccion.Text = fila.Cells[5].Value.ToString();
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #8
0
        private void btcnew_Click(object sender, EventArgs e)
        {
            int       lid;
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT seq FROM sqlite_sequence WHERE name = 'cliente';");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.SelectAll();

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    tbccodigo.Text = fila.Cells[0].Value.ToString();
                    lid            = Convert.ToInt32(tbccodigo.Text);
                    lid++;
                    tbccodigo.Text = Convert.ToString(lid);
                }
                catch (Exception)
                {
                }
            }

            tbcnombre.Text    = "";
            tbcapellidos.Text = "";
            tbccedula.Text    = "";
            tbctelefono.Text  = "";
            tbcdireccion.Text = "";

            nuevo = true;
        }
Exemple #9
0
        public void RealizarModificacion()
        {
            cliente.modificar = true;

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    cliente.idmodificar = fila.Cells[0].Value.ToString();
                }
                catch (Exception)
                {
                }
            }
            Form f = new cliente();

            f.ShowDialog();

            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM cliente WHERE nombre LIKE '%" + tbnombre.Text + "%';");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.Columns[0].ReadOnly = true;
        }
Exemple #10
0
 void BuscarporCodigo()
 {
     try
     {
         dataGridView1.Rows.Clear();
         operacion oper = new operacion();
         DataTable dt   = new DataTable();
         dt = oper.ExtraeData("SELECT id,nombrecliente,equipo,fecha, preciotrabajo FROM registro WHERE id LIKE '%" + tbcodigo.Text + "%' AND estado LIKE '%" + servicioestado + "%';");
         dataGridView3.DataSource = dt;
         dataGridView3.Refresh();
         for (int i = 0; i < (dataGridView3.RowCount - 1); i++)
         {
             dataGridView1.Rows.Add();
             dataGridView1.Rows[i].Cells[0].Value = dataGridView3.Rows[i].Cells[0].Value;
             dataGridView1.Rows[i].Cells[1].Value = dataGridView3.Rows[i].Cells[1].Value;
             dataGridView1.Rows[i].Cells[2].Value = dataGridView3.Rows[i].Cells[2].Value;
             dataGridView1.Rows[i].Cells[3].Value = dataGridView3.Rows[i].Cells[3].Value;
             dataGridView1.Rows[i].Cells[4].Value = dataGridView3.Rows[i].Cells[4].Value;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error al Cargar los Registros, Contacte al J.M.B.", "Aviso");
     }
 }
Exemple #11
0
 public void MostrarTodo()
 {
     // Mostrar todo el contenido de la tabla cliente
     dt = oper.ExtraeData("SELECT id, nombre, apellidos, cedula FROM cliente;");
     dataGridView1.DataSource = dt;
     dataGridView1.Refresh();
     dataGridView1.Columns[0].ReadOnly = true;
 }
        void RealizarBusqueda()
        {
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM suplidores WHERE nombre LIKE '%" + tbnombre.Text + "%';");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM suplidores;");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
        }
Exemple #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM producto;");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.Columns[0].ReadOnly = true;
        }
Exemple #15
0
        public void RealizarBusqueda()
        {
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT * FROM producto WHERE nombre LIKE '%" + tbnombre.Text + "%';");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.Columns[0].ReadOnly = true;
        }
Exemple #16
0
        private void btpdelete_Click(object sender, EventArgs e)
        {
            DialogResult boton = MessageBox.Show("Seguro que desea eliminar este producto", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (boton == DialogResult.No)
            {
                return;
            }
            else


            if (!string.IsNullOrEmpty(tbpcodigo.Text) || !string.IsNullOrWhiteSpace(tbpcodigo.Text))
            {
                operacion oper = new operacion();
                string    id;
                id = tbpcodigo.Text;

                oper.Sqlsinconsulta("DELETE FROM producto WHERE id = '" + id + "'");
                MessageBox.Show("Se eliminó el Producto", "Eliminar");

                tbpnombre.Text     = "";
                tbpcosto.Text      = "";
                tbpprecio.Text     = "";
                tbpexistencia.Text = "";
                tbpsuplidor.Text   = "";

                int       lid;
                DataTable dt = new DataTable();
                dt = oper.ExtraeData("SELECT seq FROM sqlite_sequence WHERE name = 'producto';");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        tbpcodigo.Text = fila.Cells[0].Value.ToString();
                        lid            = Convert.ToInt32(tbpcodigo.Text);
                        lid++;
                        tbpcodigo.Text = Convert.ToString(lid);
                    }
                    catch (Exception)
                    {
                    }
                }
                nuevo = true;
            }
            else
            {
                MessageBox.Show("No ha seleccionado ningún producto para eliminar", "Eliminar");
            }
        }
Exemple #17
0
        void ModificarRegistro()
        {
            try
            {
                //Validar si se modificará un registro o si se creará uno nuevo
                if (dataGridView1.RowCount > 0)
                {
                    int actualid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);

                    //Rellenar Tabla Grid2 con los datos completos
                    operacion oper = new operacion();
                    DataTable dt   = new DataTable();
                    dt = oper.ExtraeData("SELECT * FROM registro WHERE id = '" + actualid + "';");
                    dataGridView2.DataSource = dt;
                    dataGridView2.Refresh();
                    dataGridView2.Columns[0].ReadOnly = true;

                    id            = dataGridView2.Rows[0].Cells[0].Value.ToString();
                    nombrecliente = dataGridView2.Rows[0].Cells[1].Value.ToString();
                    equipo        = dataGridView2.Rows[0].Cells[2].Value.ToString();
                    modelo        = dataGridView2.Rows[0].Cells[3].Value.ToString();
                    proceso       = dataGridView2.Rows[0].Cells[4].Value.ToString();
                    detalle       = dataGridView2.Rows[0].Cells[5].Value.ToString();
                    memoria       = dataGridView2.Rows[0].Cells[6].Value.ToString();
                    chip          = dataGridView2.Rows[0].Cells[7].Value.ToString();
                    fecha         = dataGridView2.Rows[0].Cells[8].Value.ToString();

                    //Abrir el formulario de Edición y activar la variable de edición
                    Registrar.modificando = true;
                    Form f = new Registrar();
                    f.ShowDialog();
                    Registrar.modificando = false;
                    MostrarTodo();
                }
                else
                {
                    //Abrir el formulario de Edición y activar la variable de edición
                    Registrar.modificando = false;
                    Form f = new Registrar();
                    f.ShowDialog();
                    MostrarTodo();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Seleccione un solo registro a la vez", "Modificar");
            }
        }
Exemple #18
0
        void NuevoRegistro()
        {
            //Para establecer el Número de registro actual
            int lid;

            operacion oper = new operacion();
            DataTable dt   = new DataTable();

            dt = oper.ExtraeData("SELECT seq FROM sqlite_sequence WHERE name = 'registro';");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();

            try
            {
                numregistro = dataGridView1.Rows[0].Cells[0].Value.ToString();
                lid         = Convert.ToInt32(numregistro);
                lid++;
                numregistro = Convert.ToString(lid);
            }
            catch (Exception)
            {
                numregistro = "1";
            }

            //Para mostrar el número de resgistro en el formulario actual
            lbnumregistro.Text = ("No. Registro: " + numregistro);

            //Esto es para establecer la fecha en el formulario actual
            lbfecha.Text = (DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString());

            tbnombre.Text  = "";
            tbequipo.Text  = "";
            tbmodelo.Text  = "";
            tbproceso.Text = "Reparación";
            tbdetalle.Text = "";
            tbmemoria.Text = "No";
            tbchip.Text    = "No";

            nuevo              = true;
            imprimir           = false;
            btimprimir.Enabled = false;
            tbnombre.Focus();
        }
Exemple #19
0
        private void cliente_Load(object sender, EventArgs e)
        {
            if (modificar)
            {
                string ids = idmodificar;

                operacion oper = new operacion();
                DataTable dt   = new DataTable();
                dt = oper.ExtraeData("SELECT * FROM cliente WHERE id = '" + ids + "'");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        tbccodigo.Text    = fila.Cells[0].Value.ToString();
                        tbcnombre.Text    = fila.Cells[1].Value.ToString();
                        tbcapellidos.Text = fila.Cells[2].Value.ToString();
                        tbccedula.Text    = fila.Cells[3].Value.ToString();
                        tbctelefono.Text  = fila.Cells[4].Value.ToString();
                        tbcdireccion.Text = fila.Cells[5].Value.ToString();
                    }
                    catch (Exception)
                    {
                    }
                }
                modificar = false;
            }
            else
            {
                string    lsid = "1";
                operacion oper = new operacion();
                DataTable dt   = new DataTable();
                dt = oper.ExtraeData("SELECT MAX(id)FROM cliente;");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        lsid = fila.Cells[0].Value.ToString();
                    }

                    catch (Exception)
                    {
                    }
                }

                dt = oper.ExtraeData("SELECT * FROM cliente WHERE id = '" + lsid + "'");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        tbccodigo.Text    = fila.Cells[0].Value.ToString();
                        tbcnombre.Text    = fila.Cells[1].Value.ToString();
                        tbcapellidos.Text = fila.Cells[2].Value.ToString();
                        tbccedula.Text    = fila.Cells[3].Value.ToString();
                        tbctelefono.Text  = fila.Cells[4].Value.ToString();
                        tbcdireccion.Text = fila.Cells[5].Value.ToString();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Exemple #20
0
        private void producto_Load(object sender, EventArgs e)
        {
            operacion oper = new operacion();

            //Para Cargar los Suplidores
            DataTable dt = new DataTable();

            dt = oper.ExtraeData("SELECT nombre FROM suplidores;");
            dataGridView1.DataSource = dt;
            dataGridView1.Refresh();
            dataGridView1.SelectAll();
            tbpsuplidor.Text = "";

            foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
            {
                try
                {
                    tbpsuplidor.Items.Add(fila.Cells[0].Value.ToString());
                }
                catch (Exception)
                {
                }
            }


            if (modificar)
            {
                string ids = idmodificar;

                dt = oper.ExtraeData("SELECT * FROM producto WHERE id = '" + ids + "'");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        tbpcodigo.Text     = fila.Cells[0].Value.ToString();
                        tbpnombre.Text     = fila.Cells[1].Value.ToString();
                        tbpcosto.Text      = fila.Cells[2].Value.ToString();
                        tbpprecio.Text     = fila.Cells[3].Value.ToString();
                        tbpexistencia.Text = fila.Cells[4].Value.ToString();
                        tbpsuplidor.Text   = fila.Cells[5].Value.ToString();
                    }
                    catch (Exception)
                    {
                    }
                }
                modificar = false;
            }
            else
            {
                string lsid = "1";
                dt = oper.ExtraeData("SELECT MAX(id)FROM producto;");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        lsid = fila.Cells[0].Value.ToString();
                    }

                    catch (Exception)
                    {
                    }
                }

                dt = oper.ExtraeData("SELECT * FROM producto WHERE id = '" + lsid + "'");
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
                dataGridView1.SelectAll();

                foreach (DataGridViewRow fila in dataGridView1.SelectedRows)
                {
                    try
                    {
                        tbpcodigo.Text     = fila.Cells[0].Value.ToString();
                        tbpnombre.Text     = fila.Cells[1].Value.ToString();
                        tbpcosto.Text      = fila.Cells[2].Value.ToString();
                        tbpprecio.Text     = fila.Cells[3].Value.ToString();
                        tbpexistencia.Text = fila.Cells[4].Value.ToString();
                        tbpsuplidor.Text   = fila.Cells[5].Value.ToString();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Exemple #21
0
        private void btmodificar_Click(object sender, EventArgs e)
        {
            DialogResult boton = MessageBox.Show("¿Desea guardar los cambios realizados?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (boton == DialogResult.No)
            {
                return;
            }
            else

            if (credito && idcliente != 0.ToString() || !credito)
            {
                //Variables necesarias para el detalle
                string idf, idp, nombre, cantidad, precio, total;
                idf = numfactura;

                int maxrow = dataGridView1detalle.RowCount;

                for (int i = 0; i < maxrow; i++)
                {
                    detalleguardado = true;
                    try
                    {
                        idp      = dataGridView1detalle.Rows[i].Cells[0].Value.ToString();
                        nombre   = dataGridView1detalle.Rows[i].Cells[1].Value.ToString();
                        cantidad = dataGridView1detalle.Rows[i].Cells[2].Value.ToString();
                        precio   = dataGridView1detalle.Rows[i].Cells[3].Value.ToString();
                        total    = dataGridView1detalle.Rows[i].Cells[4].Value.ToString();

                        dt = oper.ExtraeData("SELECT existencia FROM producto WHERE id = '" + idp + "';");
                        dataGridView1.DataSource = dt;
                        dataGridView1.Refresh();

                        currentproductocantidad = dataGridView1.Rows[0].Cells[0].Value.ToString();

                        nuevacantidad = (Convert.ToInt32(currentproductocantidad) - Convert.ToInt32(cantidad)).ToString();

                        oper.Sqlsinconsulta("INSERT INTO detalle(idf, idp, nombre, cantidad, precio, total) VALUES('" + idf + "', '" + idp + "', '" + nombre + "', '" + cantidad + "', '" + precio + "', '" + total + "');");
                        oper.Sqlsinconsulta("UPDATE producto SET existencia = '" + nuevacantidad + "' WHERE id = '" + idp + "';");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error al Guardar la Factura", "Guardar");
                        detalleguardado = false; //Para detener el guardado si hubo algún error en el guardado
                    }
                }

                if (detalleguardado)
                {
                    //Variables necesarias para la factura
                    string idc, nombrec, fechaf;

                    nombrec = tbcliente.Text;
                    if (credito)
                    {
                        try { idc = Convert.ToInt32(tbidcliente.Text).ToString(); }
                        catch (Exception)
                        {
                            MessageBox.Show("Elija el cliente nuevamente", "Error");
                            return;
                        }
                    }
                    else
                    {
                        idc = "";
                    }


                    //Para coloar la fecha en formato correcto
                    int    mmes = 0, ddia = 0;
                    string mes, dia, año;
                    mmes = DateTime.Now.Month;
                    ddia = DateTime.Now.Day;

                    if (mmes < 10)
                    {
                        mes = ("0" + mmes.ToString());
                    }
                    else
                    {
                        mes = mmes.ToString();
                    }

                    if (ddia < 10)
                    {
                        dia = ("0" + mmes.ToString());
                    }
                    else
                    {
                        dia = ddia.ToString();
                    }

                    //Luego de hacer las revisiones necesarias en día y mes, formatear con guiones la fecha.
                    año    = DateTime.Now.Year.ToString();
                    fechaf = (año + "-" + mes + "-" + dia);
                    total  = totalfactura.ToString();

                    oper.Sqlsinconsulta("INSERT INTO factura(idc, nombrec, fecha, total) VALUES('" + idc + "', '" + nombrec + "', '" + fechaf + "', '" + total + "');");
                    facturaguardada = true;

                    dataGridView1detalle.ReadOnly = true;

                    if (detalleguardado && facturaguardada)
                    {
                        DialogResult Guardar = MessageBox.Show("Factura Guardada, Desea imprimirla", "Guardar", MessageBoxButtons.YesNo);
                        if (boton == DialogResult.Yes)
                        {
                            ImprimirFactura(); // Método de impresión de Factura

                            //Bloquear Factura
                            btbuscar.Enabled     = false;
                            tbproducto.Enabled   = false;
                            btnsearch.Enabled    = false;
                            chkbcontado.Enabled  = false;
                            chkbcredito.Enabled  = false;
                            tbcliente.Enabled    = false;
                            btnguardar.Enabled   = false;
                            btnimprimir.Enabled  = true;
                            btneliminiar.Enabled = false;
                            ptbcliente.Enabled   = false;
                            btnimprimir.Select();
                            return;
                        }
                        else
                        {
                            //Bloquear Factura
                            btbuscar.Enabled = false;
                        }
                        tbproducto.Enabled   = false;
                        btnsearch.Enabled    = false;
                        chkbcontado.Enabled  = false;
                        chkbcredito.Enabled  = false;
                        tbcliente.Enabled    = false;
                        btnguardar.Enabled   = false;
                        btnimprimir.Enabled  = true;
                        btneliminiar.Enabled = false;
                        ptbcliente.Enabled   = false;
                        btnimprimir.Select();
                    }
                }
            }
            else
            {
                MessageBox.Show("La facura es a Crédito por favor seleccione un cliente válido", "Aviso");
            }
        }