Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            {
                if (!string.IsNullOrEmpty(tbpcodigo.Text) || !string.IsNullOrWhiteSpace(tbpcodigo.Text))
                {
                    operacion oper = new operacion();
                    string    id, nombre, costo, precio, existencia, suplidor;
                    id         = tbpcodigo.Text;
                    nombre     = tbpnombre.Text; nombre = nombre.Trim(new Char[] { ' ', '*', '.' }); //Limpiar Nombre de carácteres estraños
                    costo      = tbpcosto.Text;
                    precio     = tbpprecio.Text;
                    existencia = tbpexistencia.Text;
                    suplidor   = tbpsuplidor.Text;

                    if (nuevo)
                    {
                        oper.Sqlsinconsulta("INSERT INTO producto(nombre, costo, precio, existencia, suplidor) VALUES('" + nombre + "', '" + costo + "', '" + precio + "', '" + existencia + "', '" + suplidor + "');");
                        MessageBox.Show("Se agregó el Producto", "Nuevo");
                        nuevo = false;
                    }
                    else
                    {
                        oper.Sqlsinconsulta("UPDATE producto SET nombre = '" + nombre + "', costo = '" + costo + "', precio = '" + precio + "', existencia = '" + existencia + "', suplidor = '" + suplidor + "' WHERE id = '" + id + "';");
                        MessageBox.Show("Se Modificó el Producto", "Guardar");
                    }
                }
                else
                {
                    MessageBox.Show("Rellene todos los campos", "Guardar");
                }
            }
        }
Пример #2
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");
     }
 }
Пример #3
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;
        }
Пример #4
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)
                {
                }
            }
        }
Пример #5
0
        private void ConsultaSuplidores_Load(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            DataTable dt   = new DataTable();

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

            if (mantenimiento)
            {
                Form f = new suplidores();
                this.Hide();
                f.ShowDialog();
                if (!mantenimiento2)
                {
                    this.Close();
                }
                else
                {
                }
                mantenimiento  = false;
                mantenimiento2 = false;
            }
            else
            {
            }
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            {
                if (!string.IsNullOrEmpty(tbccodigo.Text) || !string.IsNullOrWhiteSpace(tbccodigo.Text))
                {
                    operacion oper = new operacion();
                    string    id, nombre, apellidos, cedula, telefono, direccion;
                    id        = tbccodigo.Text;
                    nombre    = tbcnombre.Text; nombre = nombre.Trim(new Char[] { ' ', '*', '.' }); //Limpiar el nombre de puntos y carácteres raros
                    apellidos = tbcapellidos.Text; apellidos = apellidos.Trim(new Char[] { ' ', '*', '.' });
                    cedula    = tbccedula.Text; cedula = cedula.Trim(new Char[] { ' ', '*', '.' });
                    telefono  = tbctelefono.Text; telefono = telefono.Trim(new Char[] { ' ', '*', '.' });
                    direccion = tbcdireccion.Text;

                    if (nuevo)
                    {
                        oper.Sqlsinconsulta("INSERT INTO cliente(nombre, apellidos, cedula, telefono, direccion) VALUES('" + nombre + "', '" + apellidos + "', '" + cedula + "', '" + telefono + "', '" + direccion + "');");
                        MessageBox.Show("Se agregó el Cliente", "Cliente");
                        nuevo = false;
                    }
                    else
                    {
                        oper.Sqlsinconsulta("UPDATE cliente SET nombre = '" + nombre + "', apellidos = '" + apellidos + "', cedula = '" + cedula + "', telefono = '" + telefono + "', direccion = '" + direccion + "' WHERE id = '" + id + "';");
                        MessageBox.Show("Se Modificó el Cliente", "Cliente");
                    }
                }
                else
                {
                    MessageBox.Show("Rellene por lo menos los campos de Nombre y Teléfono", "Guardar");
                }
            }
        }
Пример #7
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;
        }
Пример #8
0
        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();
        }
Пример #9
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)
                {
                }
            }
        }
Пример #10
0
        private void btcsave_Click(object sender, EventArgs e)
        {
            {
                if (!string.IsNullOrEmpty(tbccodigo.Text) || !string.IsNullOrWhiteSpace(tbccodigo.Text))
                {
                    operacion oper = new operacion();
                    string    id, nombre, tipo, telefono1, telefono2, direccion;
                    id        = tbccodigo.Text;
                    nombre    = tbcnombre.Text;
                    tipo      = tbstipo.Text;
                    telefono1 = tbstel1.Text;
                    telefono2 = tbstel2.Text;
                    direccion = tbcdireccion.Text;

                    if (nuevo)
                    {
                        oper.Sqlsinconsulta("INSERT INTO suplidores (nombre, tipo, telefono1, telefono2, direccion) VALUES('" + nombre + "', '" + tipo + "', '" + telefono1 + "', '" + telefono2 + "', '" + direccion + "');");
                        MessageBox.Show("Se agregó el Suplidor", "Suplidor");
                        nuevo = false;
                    }
                    else
                    {
                        oper.Sqlsinconsulta("UPDATE suplidores SET nombre = '" + nombre + "', tipo = '" + tipo + "', telefono1 = '" + telefono1 + "', telefono2 = '" + telefono2 + "', direccion = '" + direccion + "' WHERE id = '" + id + "';");
                        MessageBox.Show("Se Modificó el Suplidor", "Suplidor");
                    }
                }
                else
                {
                    MessageBox.Show("Rellene por lo menos los campos de Nombre y Teléfono 1", "Guardar");
                }
            }
        }
Пример #11
0
        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();
        }
Пример #12
0
        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();
        }
Пример #13
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;
        }
Пример #14
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;
        }
Пример #15
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");
            }
        }
Пример #16
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;
        }
Пример #17
0
 private void reset_Click(object sender, EventArgs e)
 {
     if (tbpass.Text == "zxccxz1")
     {
         operacion oper = new operacion();
         oper.Sqlsinconsulta("DELETE FROM factura; DELETE FROM detalle; DELETE FROM sqlite_sequence WHERE name = 'factura'; DELETE FROM sqlite_sequence WHERE name = 'detalle';");
         MessageBox.Show("Campos reiniciados", "Enhorabuena", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         tbpass.Clear();
     }
     else
     {
         MessageBox.Show("Clave Incorrecta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         tbpass.Clear();
     }
 }
Пример #18
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");
            }
        }
Пример #19
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();
        }
Пример #20
0
        private void btnguardar_Click(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            int       maxid;
            //Este boton hace que sea posible guardar los datos que se encuentran en el datagridbiew
            string id, nombre, tipo, telefono1, telefono2, direccion;

            maxid = dataGridView1.RowCount;
            maxid--;

            for (int i = 0; i < maxid; i++)
            {
                id        = dataGridView1.Rows[i].Cells[0].Value.ToString();
                nombre    = dataGridView1.Rows[i].Cells[1].Value.ToString();
                tipo      = dataGridView1.Rows[i].Cells[2].Value.ToString();
                telefono1 = dataGridView1.Rows[i].Cells[3].Value.ToString();
                telefono2 = dataGridView1.Rows[i].Cells[4].Value.ToString();
                direccion = dataGridView1.Rows[i].Cells[5].Value.ToString();

                oper.Sqlsinconsulta("UPDATE suplidores SET nombre = '" + nombre + "', tipo = '" + tipo + "', telefono1 = '" + telefono1 + "', telefono2 = '" + telefono2 + "', direccion = '" + direccion + "' WHERE id = '" + id + "';");
            }
        }
Пример #21
0
        private void button2_Click(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            int       maxid;
            //Este boton hace que sea posible guardar los datos que se encuentran en datagridview
            string id, nombre, apellidos, cedula, telefono, direccion;

            maxid = dataGridView1.RowCount;
            maxid--;

            for (int i = 0; i < maxid; i++)
            {
                id        = dataGridView1.Rows[i].Cells[0].Value.ToString();
                nombre    = dataGridView1.Rows[i].Cells[1].Value.ToString();
                apellidos = dataGridView1.Rows[i].Cells[2].Value.ToString();
                cedula    = dataGridView1.Rows[i].Cells[3].Value.ToString();
                telefono  = dataGridView1.Rows[i].Cells[4].Value.ToString();
                direccion = dataGridView1.Rows[i].Cells[5].Value.ToString();

                //MessageBox.Show(id + " " + nombre + " " + apellidos + " " + cedula + " " + telefono + " " + direccion);
                oper.Sqlsinconsulta("UPDATE cliente SET nombre = '" + nombre + "', apellidos = '" + apellidos + "', cedula = '" + cedula + "', telefono = '" + telefono + "', direccion = '" + direccion + "' WHERE id = '" + id + "';");
            }
        }
Пример #22
0
        private void btnguardar_Click(object sender, EventArgs e)
        {
            operacion oper = new operacion();
            int       maxid;
            //Este boton hace que sea posible guardar los datos que se encuentran en datagridbiew
            string id, nombre, costo, precio, existencia, suplidor;

            maxid = dataGridView1.RowCount;

            for (int i = 0; i < maxid; i++)
            {
                id         = dataGridView1.Rows[i].Cells[0].Value.ToString();
                nombre     = dataGridView1.Rows[i].Cells[1].Value.ToString();
                costo      = dataGridView1.Rows[i].Cells[2].Value.ToString();
                precio     = dataGridView1.Rows[i].Cells[3].Value.ToString();
                existencia = dataGridView1.Rows[i].Cells[4].Value.ToString();
                suplidor   = dataGridView1.Rows[i].Cells[5].Value.ToString();

                //MessageBox.Show(id + " " + nombre + " " + apellidos + " " + cedula + " " + telefono + " " + direccion);
                oper.Sqlsinconsulta("UPDATE producto SET nombre = '" + nombre + "', costo = '" + costo + "', precio = '" + precio + "', existencia = '" + existencia + "', suplidor = '" + suplidor + "' WHERE id = '" + id + "';");
            }

            btnguardar.Enabled = false;
        }
Пример #23
0
        private void btcsave_Click(object sender, EventArgs e)
        {
            {
                if (!string.IsNullOrEmpty(tbnombre.Text) || !string.IsNullOrWhiteSpace(tbnombre.Text))
                {
                    operacion oper = new operacion();
                    DataTable dt = new DataTable();
                    int       mmes = 0, ddia = 0;
                    string    id = numregistro;
                    string    nombrecliente, equipo, modelo, proceso, detalle, memoria, chip, año, mes, dia, fecha;

                    nombrecliente = tbnombre.Text;
                    equipo        = tbequipo.Text;
                    modelo        = tbmodelo.Text;
                    proceso       = tbproceso.Text;
                    detalle       = tbdetalle.Text;
                    memoria       = tbmemoria.Text;
                    chip          = tbchip.Text;

                    //Para coloar la fecha en formato correcto
                    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();
                    fecha = (año + "-" + mes + "-" + dia);

                    if (nuevo)
                    {
                        oper.Sqlsinconsulta("INSERT INTO registro (nombrecliente, equipo, modelo, proceso, detalle, memoria, chip, fecha, estado) VALUES('" + nombrecliente + "', '" + equipo + "', '" + modelo + "', '" + proceso + "', '" + detalle + "', '" + memoria + "', '" + chip + "', '" + fecha + "', 'PROCESO');");
                        MessageBox.Show("Se agregó el registro Correctamente", "Registrar");

                        //Para hacer que si el cliente hacer algún cambio este se modifique
                        nuevo = false;

                        //Para que se habilite la opción imprimir
                        imprimir           = true;
                        btimprimir.Enabled = true;
                        btimprimir.Focus();
                    }
                    else
                    {
                        oper.Sqlsinconsulta("UPDATE registro SET nombrecliente = '" + nombrecliente + "', equipo = '" + equipo + "', modelo = '" + modelo + "', proceso = '" + proceso + "', detalle = '" + detalle + "', memoria = '" + memoria + "', chip = '" + chip + "' WHERE id = '" + numregistro + "';");
                        MessageBox.Show("Se Modificó el Cliente", "Guardar");

                        //Para que se habilite la opción imprimir
                        imprimir           = true;
                        btimprimir.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("Rellene Todos los Campos", "Guardar");
                }
            }
        }
Пример #24
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)
                    {
                    }
                }
            }
        }
Пример #25
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)
                    {
                    }
                }
            }
        }