Exemplo n.º 1
0
        private void Dgv_detalle_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string Id_reference  = "";                                                                                                      // FUNCION PARA ELIMINAR EL DETALLE, POR MEDIO DEL CODIGO DEL DETALLE Y EL DE EL NUMERO DE ORDEN, SE ELIMINA DANDO DOBLE CLICK EN EL REGISTRO QUE SE DESEA ELIMINAR
            string Id_reference2 = "";                                                                                                      // VARIABLES QUE GUARDAN EL ID

            if (Dgv_detalle.SelectedCells.Count > 0)                                                                                        // SELECCION DEL REGISTRO QUE SE DESEA ELIMINAR
            {
                int             selectedrowindex = Dgv_detalle.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = Dgv_detalle.Rows[selectedrowindex];
                Id_reference  = Convert.ToString(selectedRow.Cells[0].Value);
                Id_reference2 = Convert.ToString(selectedRow.Cells[1].Value);
            }
            CapaDatosCompras cd = new CapaDatosCompras();                                                                                   // INSTANCIA A LA CAPA DE DATOS

            cd.EliminarDatosDetalle(Id_reference, Id_reference2);                                                                           // LLAMADA A FUNCION DE ELIMINAR
            DataSet ds;

            ds = cd.ConsultarDatos(Txt_NOrden.Text);
            Dgv_detalle.DataSource = ds.Tables[0];


            double suma = 0;

            foreach (DataGridViewRow row in Dgv_detalle.Rows)
            {
                if (row.Cells[4].Value != null)
                {
                    suma += Convert.ToDouble(row.Cells[4].Value);                       // SUMA DE SUBTOTALES PARA GENERAR EL TOTAL
                }
            }
            this.Txt_total.Text = Convert.ToString(suma);

            // GUARDADO DE DATOS
            cd.ActualizarTotal(Txt_total.Text, "PK_NumeroOrden", "TBL_OrdenDeCompraEncabezado", Txt_NOrden.Text);               /// ACTUALIZAR LOS TOTALES DEL ENCABEZADO
        }
Exemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            CapaDatosCompras cd = new CapaDatosCompras();                                                                                   // GUARDADO DE DATOS

            cd.InsertarDatosDetalle(Txt_NDetalle.Text, Txt_Cantidad.Text, Txt_Subtotal.Text, Txt_NOrden.Text, Txt_CodigoP.Text);

            clean();                                                                                                                        // FUNCION DE LIMPIAR

            DataSet ds;                                                                                                                     // CARGA DEL DATAGRID DE DETALES

            ds = cd.ConsultarDatos(Txt_NOrden.Text);
            Dgv_detalle.DataSource = ds.Tables[0];


            double suma = 0;

            foreach (DataGridViewRow row in Dgv_detalle.Rows)
            {
                if (row.Cells[4].Value != null)
                {
                    suma += Convert.ToDouble(row.Cells[4].Value);                       // SUMA DE SUBTOTALES PARA GENERAR EL TOTAL
                }
            }
            this.Txt_total.Text = Convert.ToString(suma);

            // GUARDADO DE DATOS
            cd.ActualizarTotal(Txt_total.Text, "PK_NumeroOrden", "TBL_OrdenDeCompraEncabezado", Txt_NOrden.Text);
        }
Exemplo n.º 3
0
        private void Txt_NOrden_TextChanged(object sender, EventArgs e)
        {
            CapaDatosCompras cd = new CapaDatosCompras();                                   // INSTANCIA DE LA CAPA DE DATOS

            if (Txt_NOrden.Text != "")                                                      // HABILITACION O DESHABILITACION DEL BOTON DE DETALLE SEGUN EL NUMERO DE ORDEN
            {
                button3.Enabled = true;

                DataSet ds;
                ds = cd.ConsultarDatos(Txt_NOrden.Text);                                    // CARGA DEL DATAGRIDVIEW CON LOS DATOS DE LOS DEMAS DETALLES DE LA ORDEN
                Dgv_detalle.DataSource = ds.Tables[0];
                double suma = 0;
                foreach (DataGridViewRow row in Dgv_detalle.Rows)
                {
                    if (row.Cells[4].Value != null)
                    {
                        suma += Convert.ToDouble(row.Cells[4].Value);                       // SUMA DE SUBTOTALES PARA GENERAR EL TOTAL
                    }
                }

                this.Txt_total.Text = Convert.ToString(suma);                               // CARGA DEL TOTAL AL TEXTBOX
            }
            else
            {
                button3.Enabled = false;                                                    // DESHABILITACION DEL DETALLE
                DataTable dt = (DataTable)Dgv_detalle.DataSource;                           // VACIADO DEL DATAGRID
                dt.Clear();
                this.Txt_total.Text = "0";                                                  // TOTAL EN CERO
            }
        }
Exemplo n.º 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            CapaDatosCompras cd = new CapaDatosCompras();                                                                                   // GUARDADO DE DATOS

            cd.InsertarDatosDetalle(Txt_NDetalle.Text, Txt_Cantidad.Text, Txt_Subtotal.Text, Txt_NOrden.Text, Txt_CodigoP.Text);

            clean();                                                                                                                        // FUNCION DE LIMPIAR

            DataSet ds;                                                                                                                     // CARGA DEL DATAGRID DE DETALES

            ds = cd.ConsultarDatos(Txt_NOrden.Text);
            Dgv_detalle.DataSource = ds.Tables[0];
        }
Exemplo n.º 5
0
        private void Cbb_productoD_SelectedIndexChanged(object sender, EventArgs e)
        {
            CapaDatosCompras cd = new CapaDatosCompras();                                                                                   // INSTANCIA A LA CAPA DE DATOS

            Txt_CodigoP.Text = cd.ExtraerCodigos(Cbb_productoD.Text, "PK_Codigo_Producto", "TBL_Producto", "Descripcion_Producto");         // EXTRACCION DEL CODIGO A TRAVES DEL NOMBRE
            string[] datos;
            datos           = new string[3];
            datos           = cd.cargarDatos1(Txt_CodigoP.Text);                                                                            // CARGA DE DATOS DE PRODUCTOS, ESTO CON EL FIN DE SABER QUE PRODUCTO SE ESTA OPERANDO
            Txt_Precio.Text = datos[2];                                                                                                     // CARGA DE PRECIO


            DataSet ds;                                                                                                                     // CARGA DE DATAGRID CON OTROS DETALLES DE LA MISMA ORDEN

            ds = cd.ConsultarDatos(Txt_NOrden.Text);
            Dgv_detalle.DataSource = ds.Tables[0];
        }
Exemplo n.º 6
0
        private void Dgv_detalle_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string Id_reference  = "";                                                                                                      // FUNCION PARA ELIMINAR EL DETALLE, POR MEDIO DEL CODIGO DEL DETALLE Y EL DE EL NUMERO DE ORDEN, SE ELIMINA DANDO DOBLE CLICK EN EL REGISTRO QUE SE DESEA ELIMINAR
            string Id_reference2 = "";                                                                                                      // VARIABLES QUE GUARDAN EL ID

            if (Dgv_detalle.SelectedCells.Count > 0)                                                                                        // SELECCION DEL REGISTRO QUE SE DESEA ELIMINAR
            {
                int             selectedrowindex = Dgv_detalle.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = Dgv_detalle.Rows[selectedrowindex];
                Id_reference  = Convert.ToString(selectedRow.Cells[0].Value);
                Id_reference2 = Convert.ToString(selectedRow.Cells[1].Value);
            }
            CapaDatosCompras cd = new CapaDatosCompras();                                                                                   // INSTANCIA A LA CAPA DE DATOS

            cd.EliminarDatosDetalle(Id_reference, Id_reference2);                                                                           // LLAMADA A FUNCION DE ELIMINAR
            DataSet ds;

            ds = cd.ConsultarDatos(Txt_NOrden.Text);
            Dgv_detalle.DataSource = ds.Tables[0];
        }