// Funciones Varias

        private void comboBoxProducto_SelectedIndexChanged(object sender, EventArgs e)
        {
            cargardatos();
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                if (codigoProducto != "")
                {
                    numericUpDownPrecioVenta.Value = Convert.ToDecimal(cpd.ExtraerCodigo2("PrecioVenta", "tbl_Producto", "id", codigoProducto));
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString(), "ERROR AL CARGAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            foreach (DataGridViewRow row in dtg_ProductosDetalle.Rows)
            {
                int sumaRows = 0;
                if (row.Cells[0].Value.ToString() == comboBoxProducto.Text && row.Cells[1].Value.ToString() == comboBoxBodega.Text)
                {
                    int minusCant = Convert.ToInt32(row.Cells[2].Value); //CANTIDAD
                    sumaRows = Convert.ToInt32(labelCantidadDisponible.Text) - minusCant;
                    labelCantidadDisponible.Text = sumaRows.ToString();
                }
            }
        }
        //Variables

        //Funciones varias

        void LoadForm()
        {
            ///Carga de grid Principal
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_proveedor.id as CODIGO, " +
                                            "tbl_persona.nombre as NOMBRE, " +
                                            "tbl_persona.apellidos as APELLIDO, " +
                                            "tbl_organizacion.nombre as ORGANIZACION, " +
                                            "tbl_organizacion.direccion as DIRECCION "
                                            ,
                                            "tbl_proveedor, tbl_persona, tbl_organizacion "
                                            ,
                                            "tbl_persona.id = tbl_proveedor.tbl_persona_id " +
                                            "AND tbl_organizacion.id = tbl_proveedor.tbl_organizacion_id " +
                                            "AND tbl_proveedor.status = 1 " +
                                            filtro,
                                            "Visualizacion de Proveedores");
                DataGridViewProveedores.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al cargar datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        void cargarUsuarios(string codigo)
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            string[] datos = new string[15];
            try
            {
                datos                       = cpd.cargarDetallesUsuarios(codigoACambiar, "Vista de Detalles de usuarios");
                datosUsuario                = datos;
                labelUserID.Text            = datos[0];
                labelNameUser.Text          = datos[1];
                textBoxNickname.Text        = datos[1];
                textBoxPassword.Text        = cpd.DesEncriptar(datos[11]);
                textBoxImagen.Text          = datos[2];
                textBoxDPI.Text             = datos[3];
                textBoxNombre.Text          = datos[4];
                textBoxApellidos.Text       = datos[5];
                numericUpDownEdad.Value     = Convert.ToInt32(datos[6]);
                comboBoxSexo.SelectedItem   = datos[7];
                comboBoxPuesto.SelectedItem = datos[8];
                textBoxTelefono.Text        = datos[9];
                textBoxCorreo.Text          = datos[10];
            }catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL CARGAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        void CargarGrid()
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                ds = cpd.LlenarGrid("tbl_producto.id as id, tbl_producto.Nombre as Nombre, " +
                                    "tbl_producto.precioCompra as PrecioCompra, tbl_producto.precioVenta as PrecioVenta, " +
                                    "tbl_material.DescripcionMaterial as Material, tbl_marca.DescripcionMarca as Marca, tbl_colorproducto.DescripcionColor as Color, " +
                                    "tbl_productobodega.Cantidad as Cantidad, " +
                                    "tbl_bodega.NombreBodega as Bodega",
                                    "tbl_producto, tbl_bodega, tbl_productobodega, tbl_material, tbl_marca, tbl_colorproducto",
                                    "tbl_producto.id = tbl_productobodega.tbl_producto_id " +
                                    "AND tbl_material.id = tbl_producto.tbl_material_id " +
                                    "AND tbl_marca.id = tbl_producto.tbl_marca_id " +
                                    "AND tbl_colorproducto.id = tbl_producto.tbl_colorproducto_id " +
                                    "AND tbl_productobodega.tbl_bodega_id = tbl_bodega.id " + filtro,
                                    "Consulta Productos");
                dtg_Productos.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void buttonAgregarAbono_Click_1(object sender, EventArgs e)
        {
            double cantidadAbono         = 0;
            double newSaldo              = 0;
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            if (Convert.ToDouble(numericUpDownAbono.Value) > Convert.ToDouble(labelSaldo.Text))
            {
                cantidadAbono = Convert.ToDouble(labelSaldo.Text);
            }
            else
            {
                cantidadAbono = Convert.ToDouble(numericUpDownAbono.Value);
                newSaldo      = Convert.ToDouble(labelSaldo.Text) - cantidadAbono;
            }
            try
            {
                if (newSaldo == 0)
                {
                    cpd.ModificarDatos("tbl_ventasencabezado", "Cancelado = 1, saldo = " + newSaldo, "id", labelNoVenta.Text, "Registro de pago");
                }
                else
                {
                    cpd.ModificarDatos("tbl_ventasencabezado", "saldo = " + newSaldo, "id", labelNoVenta.Text, "Registro de pago");
                }
                MessageBox.Show("Pago Registrado", "DATOS GUARDADOS CON EXITO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                numericUpDownAbono.Value = 0;
                LoadForm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL GUARDAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonReport_Click(object sender, EventArgs e)
        {
            string datosEmpleado         = "";
            string motivo                = "";
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
            ClaseBitacoraFerreteria  cbf = new ClaseBitacoraFerreteria();

            try
            {
                datosEmpleado = cpd.ExtraerCodigo3("CONCAT(Apellidos,',',Nombre) AS ", "NombreC", "" +
                                                   " bd_ferreteria.tbl_Persona, bd_ferreteria.tbl_usuario, bd_ferreteria.tbl_Empleado",
                                                   "tbl_Empleado.status ", " 1 AND tbl_Persona.status = 1 " +
                                                   "AND tbl_Persona.id = tbl_Empleado.tbl_Persona_id " +
                                                   "AND tbl_usuario.tbl_empleado_DPI = tbl_empleado.DPI " +
                                                   "AND tbl_usuario.id = " + cbf.GetUserCodeForLog()
                                                   );
                motivo = cpd.ExtraerCodigo2("Motivo", "tbl_devolucionencabezado",
                                            "id", labelNoDevolucion.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            ///
            ReporteadorFerreteria.REPORTS.ReportDevolucionCotizacionDetalle objRpt = new ReporteadorFerreteria.REPORTS.ReportDevolucionCotizacionDetalle();
            ReporteadorFerreteria.DATASETS.DataSetP ds1 = new ReporteadorFerreteria.DATASETS.DataSetP();
            foreach (DataGridViewRow row in dtg_ProductosDetalle.Rows)
            {
                ReporteadorFerreteria.DATASETS.DataSetP.tbl_Encabezado_DetalleRow rowDetalles = ds1.tbl_Encabezado_Detalle.Newtbl_Encabezado_DetalleRow();
                rowDetalles.id       = Convert.ToString(row.Cells["CODIGO"].Value);
                rowDetalles.Producto = Convert.ToString(row.Cells["PRODUCTO"].Value);
                rowDetalles.Cantidad = Convert.ToString(row.Cells["CANTIDAD"].Value);

                ds1.tbl_Encabezado_Detalle.Addtbl_Encabezado_DetalleRow(rowDetalles);
            }
            objRpt.SetDataSource(ds1);
            TextObject txtObject            = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextBy"];
            TextObject txtObjectDate        = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextDate"];
            TextObject txtObjectType        = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextType"];
            TextObject txtObjectObjeto      = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextObjeto"];
            TextObject txtObjectNo          = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextNoOrden"];
            TextObject txtObjectFEmision    = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextFEmision"];
            TextObject txtObjectbjetivo     = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextObjetivo"];
            TextObject txtObjectMotivo      = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextMotivoDetalle"];
            TextObject txtObjectMotivoTitle = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextMotivoTitle"];

            txtObjectDate.Text     = DateTime.Now.ToLongTimeString();
            txtObject.Text         = datosEmpleado;
            txtObjectType.Text     = "DEVOLUCIONES";
            txtObjectObjeto.Text   = "Cliente:";
            txtObjectMotivo.Text   = motivo;
            txtObjectNo.Text       = labelNoDevolucion.Text;
            txtObjectFEmision.Text = labelFechaEntrega.Text;
            txtObjectbjetivo.Text  = labelCliente.Text;

            UI_Visualizador form = new UI_Visualizador();

            form.crystalReportViewerGlobal.ReportSource = objRpt;
            form.ShowDialog();
        }
Пример #7
0
        /// <summary>
        /// Carga los datos en caso de ser una modificacion de producto
        /// </summary>
        /// <param name="codigoACambiar"></param>
        void cargardatos()
        {
            string[] cdProducto = comboBoxProducto.Text.Split(',');
            codigoProducto = cdProducto[0];
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            string[] datos;
            datos = new string[18];
            try
            {
                datos = cpd.cargarDetallesProductos(cdProducto[0], "Vista de detalles de productos");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL CARGAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            ///     Carga del detalle del producto (Lo que no se va a modificar)
            labelCodigoDetalle.Text   = "ID: " + datos[0];
            labelNombreDetalle.Text   = "NOMBRE: " + datos[1];
            labelMaterialDetalle.Text = "MAT.: " + datos[13];
            labelTipoDetalle.Text     = "TIP.: " + datos[14];
            labelTamano.Text          = "TAM.: " + datos[6];
            labelDiametro.Text        = "DIAM.: " + datos[7];
            labelFuerza.Text          = "FUER.: " + datos[8];
            labelVoltaje.Text         = "VOL.: " + datos[2];
        }
Пример #8
0
        void CargarGridDetalleBodegas(DataGridView dtg, ComboBox cbm)
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            // Llenar Datagrid
            try
            {
                string  idBodega = cpd.ExtraerCodigo("id", "tbl_Bodega", "NombreBodega", cbm.Text);
                DataSet ds       = cpd.LlenarGrid("" +
                                                  "tbl_producto.id as 'CODIGO', " +
                                                  "tbl_producto.Nombre as 'NOMBRE', " +
                                                  "tbl_producto.tbl_Material_id as 'MATERIAL', " +
                                                  "tbl_productobodega.Cantidad as 'CANTIDAD' ",
                                                  "tbl_producto, tbl_productobodega ",
                                                  "tbl_productobodega.tbl_Producto_id = tbl_Producto.id " +
                                                  "and tbl_productobodega.tbl_Bodega_id = '" + idBodega + "' " +
                                                  "and tbl_Producto.status = 1",
                                                  "Visualizacion de productos en bodega");
                dtg.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
        private void comboBoxBodega1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                if ((sender as ComboBox).Name == "comboBoxBodega1")
                {
                    codBodega1 = cpd.ExtraerCodigo("id", "tbl_Bodega", "NombreBodega", (sender as ComboBox).Text);
                }
                if ((sender as ComboBox).Name == "comboBoxBodega2")
                {
                    codBodega2 = cpd.ExtraerCodigo("id", "tbl_Bodega", "NombreBodega", (sender as ComboBox).Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            CargarGridDetalleBodegas(dtg_Productos1, comboBoxBodega1);
            CargarGridDetalleBodegas(dtg_Productos2, comboBoxBodega2);
            if (codBodega1 == codBodega2)
            {
                buttonAsignar.Enabled    = false;
                buttonDesasignar.Enabled = false;
            }
            else
            {
                buttonAsignar.Enabled    = true;
                buttonDesasignar.Enabled = true;
            }
        }
        //Variables

        //Funciones varias

        void LoadForm()
        {
            ///Carga de grid Principal
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_cliente.NIT as 'NIT', " +
                                            "tbl_persona.Nombre as 'NOMBRE', " +
                                            "tbl_persona.Apellidos as 'APELLIDOS', " +
                                            "tbl_organizacion.Nombre as 'ORGANIZACION', " +
                                            "tbl_organizacion.Direccion as 'DIRECCION', " +
                                            "tbl_cliente.Transporte as 'TRANSPORTE', " +
                                            "tbl_telefono.NumeroTelefono as 'TELEFONO', " +
                                            "tbl_correo.Correo as 'CORREO'"
                                            ,
                                            "tbl_persona, tbl_organizacion, tbl_cliente,tbl_telefono, tbl_correo"
                                            ,
                                            "tbl_persona.id = tbl_telefono.tbl_persona_id " +
                                            "AND tbl_persona.id = tbl_correo.tbl_persona_id " +
                                            "AND tbl_organizacion.id = tbl_cliente.tbl_organizacion_id " +
                                            "AND tbl_cliente.tbl_Persona_id = tbl_Persona.id " +
                                            "AND tbl_cliente.status = 1 " +
                                            filtro,
                                            "Visualizacion de Proveedores");
                DataGridViewClientes.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al cargar datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #11
0
        //Variables

        //Funciones

        void LoadForm()
        {
            comboBoxBodega1.Items.Clear();
            comboBoxBodega2.Items.Clear();
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                cpd.cargarDatosACombobox(comboBoxBodega1, "NombreBodega", "tbl_Bodega");
                cpd.cargarDatosACombobox(comboBoxBodega2, "NombreBodega", "tbl_Bodega");
                if (comboBoxBodega1.Name == "comboBoxBodega1")
                {
                    codBodega1 = cpd.ExtraerCodigo("id", "tbl_Bodega", "NombreBodega", comboBoxBodega1.Text);
                }
                if (comboBoxBodega2.Name == "comboBoxBodega2")
                {
                    codBodega2 = cpd.ExtraerCodigo("id", "tbl_Bodega", "NombreBodega", comboBoxBodega2.Text);
                }
                codProducto = cpd.ExtraerCodigo("tbl_Producto_id", "tbl_productobodega", "tbl_Bodega_id", codBodega1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            CargarGridDetalleBodegas(dtg_Productos1, comboBoxBodega1);
            CargarGridDetalleBodegas(dtg_Productos2, comboBoxBodega2);
        }
        //Funcion que carga grid dependiendo del filtro
        void CargarGrid()
        {
            ///Carga de grid Principal
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_comprasencabezado.id as 'CÓDIGO',  tbl_organizacion.Nombre as 'PROVEEDOR', " +
                                            "tbl_comprasencabezado.FechaEmision as 'FECHA DE EMISIÓN', " +
                                            "tbl_comprasencabezado.FechaCancelacion as 'FECHA DE CANCELACIÓN', " +
                                            "tbl_comprasencabezado.Saldo as 'SALDO', " +
                                            "tbl_comprasencabezado.Total as 'TOTAL' ",
                                            "tbl_comprasencabezado, tbl_organizacion, tbl_proveedor ",
                                            "tbl_comprasencabezado.tbl_proveedor_id = tbl_proveedor.id " +
                                            "AND tbl_proveedor.tbl_organizacion_id = tbl_organizacion.id " +
                                            "AND tbl_comprasencabezado.status = 1 " +
                                            filtro,
                                            "Visualizacion de Compras Encabezado");
                dtg_Compras.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al cargar datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        double GetDatoPorCliente(string codCliente, string campo)
        {
            string cant = "";

            if (codCliente != "")
            {
                ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
                try
                {
                    cant = cpd.ExtraerCodigo3("SUM(" + campo + ")" + " as ", "NombreC",
                                              "tbl_ventasencabezado ",
                                              "tbl_Cliente_id",
                                              codCliente);
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            double res = 0;

            if (cant == "")
            {
                res = 0;
            }
            else
            {
                res = Convert.ToDouble(cant);
            }
            return(res);
        }
Пример #14
0
        //Variables

        ///Funciones varias

        //Funcion que carga grid dependiendo del filtro
        void CargarGrid()
        {
            ///Carga de grid Principal
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_bitacora.id as 'CÓDIGO', " +
                                            "CONCAT(tbl_persona.Nombre, ',', tbl_persona.Apellidos) as 'USUARIO PERSONA', " +
                                            "tbl_usuario.Nickname as 'USUARIO NICKNAME', " +
                                            "tbl_bitacora.host as 'HOST', " +
                                            "tbl_bitacora.fecha as 'FECHA', " +
                                            "tbl_bitacora.hora as 'HORA', " +
                                            "tbl_bitacora.accion as 'ACCION'",
                                            "tbl_bitacora, tbl_persona, tbl_usuario, tbl_empleado ",
                                            "tbl_bitacora.tbl_usuario_id = tbl_usuario.id " +
                                            "AND tbl_usuario.tbl_empleado_DPI = tbl_empleado.DPI " +
                                            "AND tbl_empleado.tbl_persona_id = tbl_persona.id " +
                                            filtro,
                                            "Visualizacion de Bitacora");
                dtg_Compras.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al cargar datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Funcion que carga grid dependiendo del filtro
        void CargarGrid()
        {
            ///Carga de grid Principal
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_devolucionencabezado.id as 'CÓDIGO',  CONCAT(tbl_persona.Nombre,',',tbl_organizacion.Nombre) as 'CLIENTE', " +
                                            "tbl_devolucionencabezado.Motivo as 'MOTIVO', " +
                                            "tbl_devolucionencabezado.FechaEmision as 'FECHA DE EMISIÓN' ",
                                            "tbl_devolucionencabezado, tbl_organizacion,tbl_persona,tbl_cliente ",
                                            "tbl_devolucionencabezado.tbl_Cliente_id = tbl_Cliente.NIT " +
                                            "AND tbl_Cliente.tbl_organizacion_id = tbl_organizacion.id " +
                                            "AND tbl_Cliente.tbl_Persona_id = tbl_Persona.id " +
                                            "AND tbl_devolucionencabezado.status = 1 " +
                                            filtro,
                                            "Visualizacion de Devoluciones Encabezado");
                DataGridViewDevoluciones.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al cargar datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Guardar los datos
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            ClaseCapaDatosFerreteria cpd       = new ClaseCapaDatosFerreteria();
            List <string>            queryList = new List <string>();

            queryList.Add(cpd.DevolverSentencia_Insert("tbl_Persona", "0, '" + textBoxNombre.Text + "', '" + textBoxApellidos.Text + "' , 1"));
            queryList.Add(cpd.DevolverSentencia_Insert("tbl_Telefono", "0, '" + textBoxTelefono.Text + "', " + nextCodigo("tbl_Persona") + " , 1"));
            queryList.Add(cpd.DevolverSentencia_Insert("tbl_Correo", "0, '" + textBoxCorreo.Text + "', " + nextCodigo("tbl_Persona") + " , 1"));
            queryList.Add(cpd.DevolverSentencia_Insert("tbl_Organizacion", "0, '" + textBoxOrganizacion.Text + "', '" + textBoxDireccion.Text + "', 1"));
            queryList.Add(cpd.DevolverSentencia_Insert("tbl_cliente", textBoxNIT.Text + ", " + nextCodigo("tbl_Persona") + ", '" + textBoxTransporte.Text + "', " +
                                                       "" + nextCodigo("tbl_Organizacion") + ", 1"));

            /*string review = "";
             * foreach (string var in queryList)
             * {
             *  review += var + "\n";
             * }
             * MessageBox.Show(review);*/
            try
            {
                cpd.EjectuarOperacionExterna(queryList, "a", "a", "Transaccion de ingreso de Clientes realizada");
                MessageBox.Show("Datos Ingresados Exitosamente", "Datos Ingresados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Limpiar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL GUARDAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        ///Funciona que contiene todas las acciones para cargar el form
        void LoadForm()
        {
            CargarGrid();

            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            //Carga el segundo panel informativo [compras anho T]
            CargaPaneInformativo(labelDevAnho, "YEAR", "", "", 0, " AND status = 1");

            //Carga el segundo panel informativo [compras mes T]
            CargaPaneInformativo(labelDevMes, "YEAR", "MONTH", "", 0, " AND status = 1");

            //Carga el segundo panel informativo [compras dia T]
            CargaPaneInformativo(labelDevDia, "YEAR", "MONTH", "DAY", 0, " AND status = 1");

            //Carga el segundo panel informativo [compras totales T]
            CargaPaneInformativo(labelDevTotales, "YEAR", "", "", 1, " WHERE status = 1");

            //Carga el segundo panel informativo [compras anho C]
            CargaPaneInformativo(labelAnhoD, "YEAR", "", "", 0, " AND status = 1 AND Aprobado = 1");

            //Carga el segundo panel informativo [compras mes C]
            CargaPaneInformativo(labelMesD, "YEAR", "MONTH", "", 0, " AND status = 1 AND Aprobado = 1");

            //Carga el segundo panel informativo [compras dia C]
            CargaPaneInformativo(labelDiaD, "YEAR", "MONTH", "DAY", 0, " AND status = 1 AND Aprobado = 1");

            //Carga el segundo panel informativo [compras totales C]
            CargaPaneInformativo(labelTotalD, "YEAR", "", "", 1, " WHERE status = 1 AND Aprobado = 1");
        }
Пример #18
0
        /// <summary>
        /// Carga los datos en caso de ser una modificacion de producto
        /// </summary>
        /// <param name="codigoACambiar"></param>
        void cargardatos(string codigoACambiar)
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            string[] datos;
            datos = new string[18];
            datos = cpd.cargarDetallesProductos(codigoACambiar, "Vista de detalles de productos");
            textBoxNombre.Text             = datos[1];
            numericUpDownVoltaje.Text      = datos[2];
            numericUpDownAmperaje.Text     = datos[3];
            numericUpDownCapacitancia.Text = datos[4];
            numericUpDownResistencia.Text  = datos[5];
            numericUpDownTamano.Text       = datos[6];
            numericUpDownDiametro.Text     = datos[7];
            numericUpDownFuerza.Text       = datos[8];
            numericUpDownTemperatura.Text  = datos[9];
            numericUpDownRPM.Text          = datos[10];
            numericUpDownHz.Text           = datos[11];
            numericUpDownPrecioVenta.Text  = datos[12];
            numericUpDownPrecioCompra.Text = datos[20];
            comboBoxMaterial.SelectedItem  = datos[13];
            comboBoxTipo.SelectedItem      = datos[14];
            comboBoxPais.SelectedItem      = datos[15];
            comboBoxMarca.SelectedItem     = datos[16];
            comboBoxColor.SelectedItem     = datos[17];
            textBoxObservaciones.Text      = datos[18];
            path_Image = datos[19];
            ///     Carga del detalle del producto (Lo que no se va a modificar)
            labelCodigoDetalle.Text   = datos[0];
            labelNombreDetalle.Text   = datos[1];
            labelMaterialDetalle.Text = datos[13];
            labelTipoDetalle.Text     = datos[14];
        }
        public void cargarDetalle()
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
            DataSet ds;

            try
            {
                ds = cpd.LlenarGrid("" +
                                    "tbl_devoluciondetalle.id as CODIGO, " +
                                    "Concat(tbl_producto.id,',',tbl_producto.Nombre) as PRODUCTO, " +
                                    "Concat(tbl_bodega.id,',',tbl_bodega.NombreBodega) as BODEGA, " +
                                    "tbl_devoluciondetalle.Cantidad as CANTIDAD, " +
                                    "tbl_devolucionencabezado.Motivo as MOTIVO ",
                                    "tbl_devoluciondetalle, tbl_devolucionencabezado, tbl_bodega," +
                                    "tbl_Producto ",
                                    "tbl_bodega.id = tbl_devoluciondetalle.tbl_bodega_id " +
                                    "AND tbl_devolucionencabezado.id = tbl_devoluciondetalle.tbl_devolucionencabezado_id " +
                                    "AND tbl_devoluciondetalle.tbl_devolucionencabezado_id = " + codigoEnc + " " +
                                    "AND tbl_devoluciondetalle.tbl_producto_id = tbl_Producto.id", "Visualizacion de datos detalles de devoluciones");
                dtg_ProductosDetalle.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL GUARDAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #20
0
        void CargarGrid()
        {
            string tabla                 = "tbl_devolucionencabezado";
            string campoObjetivo         = "tbl_Cliente";
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                ///id, fechaemision, fechacancelacion, total, objetivo, empleado, cancelado, saldo
                ds = cpd.LlenarGrid(tabla + ".id as ID, " + tabla + ".FechaEmision as 'FECHA EMISION', " +
                                    "" + tabla + ".Motivo as 'MOTIVO'," +
                                    "CONCAT(tbl_persona.Nombre,',',tbl_organizacion.Nombre) as 'CLIENTE'," +
                                    "" + tabla + ".Aprobado as 'APROBADO'",
                                    "" + tabla + ", tbl_persona, tbl_organizacion, " + campoObjetivo + "",
                                    "" + tabla + "." + campoObjetivo + "_id = " + campoObjetivo + ".NIT " +
                                    "AND " + campoObjetivo + ".tbl_persona_id = tbl_persona.id " +
                                    "AND " + tabla + ".status = 1 " +
                                    "AND " + campoObjetivo + ".tbl_organizacion_id = tbl_organizacion.id " + filtro,
                                    "Consulta Reportes");
                DataGridViewDetalles.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #21
0
        // Variables

        // Funciones Varias

        void LoadForm()
        {
            CapaDatosFerreteria.ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
            ClaseBitacoraFerreteria cbf = new ClaseBitacoraFerreteria();

            try
            {
                cargarProveedor();
                //Carga de datos del empleado
                datosEmpleado = cpd.ExtraerCodigo3("CONCAT(Apellidos,',',Nombre) AS ", "NombreC", "" +
                                                   " bd_ferreteria.tbl_Persona, bd_ferreteria.tbl_usuario, bd_ferreteria.tbl_Empleado",
                                                   "tbl_Empleado.status ", " 1 AND tbl_Persona.status = 1 " +
                                                   "AND tbl_Persona.id = tbl_Empleado.tbl_Persona_id " +
                                                   "AND tbl_usuario.tbl_empleado_DPI = tbl_empleado.DPI " +
                                                   "AND tbl_usuario.id = " + cbf.GetUserCodeForLog()
                                                   );
                //Carga de nickname del usuario
                NicknameEmpleado = cpd.ExtraerCodigo2("Nickname", "tbl_usuario", "id", cbf.GetUserCodeForLog());
                cargarBodegas();
                cargarProductos();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL CARGAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Asignacion de datos a los labels
            labelEmpleado.Text      = datosEmpleado;
            labelNoOrdenCompra.Text = nextCodigo("tbl_ComprasEncabezado");
            ordenDeCompra           = nextCodigo("tbl_ComprasEncabezado");
            labelFechaEntrega.Text  = DateTime.Now.ToShortDateString();
            labelNickname.Text      = NicknameEmpleado;
        }
Пример #22
0
        public UI_DetalleClientes(string nit, string nombre, string organizacion, string direccion, string telefono)
        {
            InitializeComponent();
            labelNIT.Text          = nit;
            labelNombre.Text       = nombre;
            labelOrganizacion.Text = organizacion;
            labelDireccion.Text    = direccion;
            labelTelefono.Text     = telefono;
            if (nit != "")
            {
                ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
                DataSet ds = cpd.LlenarGrid(
                    "tbl_Producto.id as 'CODIGO', tbl_Producto.Nombre as 'NOMBRE', tbl_ventasdetalle.Cantidad as 'CANTIDAD', " +
                    "tbl_ventasdetalle.Precio as 'PRECIO', tbl_ventasdetalle.Subtotal as 'SUBTOTAL', " +
                    "tbl_ventasencabezado.FechaEmision as 'FECHA' ",
                    "tbl_ventasdetalle, tbl_Producto, tbl_VentasEncabezado, tbl_Cliente ",
                    "tbl_ventasdetalle.tbl_VentasEncabezado_id = tbl_VentasEncabezado.id AND " +
                    "tbl_VentasEncabezado.tbl_Cliente_id = tbl_Cliente.NIT AND " +
                    "tbl_ventasdetalle.tbl_Producto_id = tbl_Producto.id AND " +
                    "tbl_Cliente.NIT = " + nit,
                    "Visualizacion de historial de clientes");

                dtg_ClientesDetalles.DataSource = ds.Tables[0];
            }
        }
        /// <summary>
        /// Retorna el valor dependiendo de la tabla y el mes
        /// </summary>
        /// <param name="monthNum">numero de mes</param>
        /// <param name="table">tabla de la que se extraeran datos</param>
        /// <returns></returns>
        double ExtraerValor(string monthNum, string table, string campo)
        {
            double res    = 0;
            string resaux = "0";
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                resaux = cpd.ExtraerCodigo3("SUM(" + campo + ") AS ", campo,
                                            table,
                                            "MONTH(FechaEmision) = '" + monthNum + "' AND YEAR(FechaEmision) ", " (SELECT YEAR(NOW())) AND status = 1 ");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (resaux == "")
            {
                res = 0;
            }
            else
            {
                res = Convert.ToDouble(resaux);
            }
            return(res);
        }
Пример #24
0
        //Funcion que carga grid dependiendo del filtro
        void CargarGrid()
        {
            ///Carga de grid Principal
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_ventasencabezado.id as 'CÓDIGO',  CONCAT(tbl_persona.Nombre,',',tbl_organizacion.Nombre) as 'CLIENTE', " +
                                            "tbl_ventasencabezado.FechaEmision as 'FECHA DE EMISIÓN', " +
                                            "tbl_ventasencabezado.FechaCancelacion as 'FECHA DE CANCELACIÓN', " +
                                            "tbl_ventasencabezado.Saldo as 'SALDO', " +
                                            "tbl_ventasencabezado.Total as 'TOTAL', " +
                                            "tbl_ventasencabezado.Transporte as 'TRANSPORTE' ",
                                            "tbl_ventasencabezado, tbl_organizacion,tbl_persona,tbl_cliente ",
                                            "tbl_ventasencabezado.tbl_Cliente_id = tbl_Cliente.NIT " +
                                            "AND tbl_Cliente.tbl_organizacion_id = tbl_organizacion.id " +
                                            "AND tbl_Cliente.tbl_Persona_id = tbl_Persona.id " +
                                            "AND tbl_ventasencabezado.status = 1 " +
                                            filtro,
                                            "Visualizacion de Ventas Encabezado");
                DataGridViewVentas.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al cargar datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #25
0
        void LoadForm()
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "DISTINCT tbl_usuario.id as 'CODIGO',  tbl_usuario.Nickname as 'NOMBRE USUARIO', " +
                                            "tbl_empleado.DPI as 'DPI', tbl_persona.Nombre as 'NOMBRE', tbl_persona.Apellidos as 'APELLIDOS' " +
                                            ", tbl_telefono.NumeroTelefono as 'TELEFONO', tbl_correo.Correo as 'CORREO' " +
                                            "", "" +
                                            "tbl_usuario, tbl_persona, tbl_empleado, tbl_telefono, tbl_correo " +
                                            "", "" +
                                            "tbl_usuario.tbl_empleado_DPI = tbl_empleado.DPI AND " +
                                            "tbl_empleado.status = 1 AND " +
                                            "tbl_persona.status = 1 AND " +
                                            "tbl_usuario.tbl_empleado_DPI = tbl_empleado.DPI AND " +
                                            "tbl_empleado.tbl_persona_id = tbl_persona.id AND " +
                                            "tbl_telefono.tbl_persona_id = tbl_persona.id AND " +
                                            "tbl_correo.tbl_persona_id = tbl_persona.id AND " +
                                            "tbl_usuario.status = 1 " + filtro +
                                            "; ", "Vista de datos de usuario");
                dtg_Usuarios.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #26
0
        private void comboBoxProducto_TextChanged(object sender, EventArgs e)
        {
            string codigoProducto = "", NombreProducto = "";

            string[] codeList = comboBoxProducto.Text.Split('-');
            codigoProducto = codeList[0];
            NombreProducto = codeList[1];

            /// Carga el detalle

            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            string[] datos;
            datos                   = new string[18];
            datos                   = cpd.cargarDetallesProductos(codigoProducto, "Carga de detalles de productos");
            labelVoltaje.Text       = datos[2] + " V";
            labelAmperaje.Text      = datos[3] + " A";
            labelCapacitancia.Text  = datos[4] + " C";
            labelResistencia.Text   = datos[5] + " R";
            labelTamaño.Text        = datos[6] + " cm";
            labelDiametro.Text      = datos[7] + " cm";
            labelFuerza.Text        = datos[8] + " N";
            labelTemperatura.Text   = datos[9] + " °C";
            labelRPM.Text           = datos[10];
            labelHz.Text            = datos[11];
            labelPrecio.Text        = "Q " + datos[12];
            labelPais.Text          = datos[13];
            labelMarca.Text         = datos[14];
            labelColor.Text         = datos[15];
            labelObservaciones.Text = datos[16];
            //cargarExistencias();
        }
        public string nextCodigo()
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            return(cpd.ExtraerCodigo2("AUTO_INCREMENT", "information_schema.TABLES", "TABLE_SCHEMA = 'bd_ferreteria' " +
                                      "AND TABLE_NAME", "'tbl_persona'"));
        }
Пример #28
0
 void cargarExistencias()
 {
     //MessageBox.Show("--" + comboBoxBodega.Text + " -- " + comboBoxProducto.Text+ "--" );
     if (comboBoxProducto.Text == "" || comboBoxBodega.Text == "")
     {
     }
     else
     {
         string   codigoProduct = "", codigoBodega = "";
         string[] codeList = comboBoxProducto.Text.Split('-');
         codigoProduct = codeList[0];
         string[] codeList2 = comboBoxBodega.Text.Split('-');
         codigoBodega = codeList2[0];
         ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
         string cant = cpd.ExtraerCodigo2("cantidad", "tbl_productobodega", "tbl_bodega_id = " + codigoBodega + " AND tbl_producto_id ", codigoProduct);
         //MessageBox.Show("-" + cant + "-");
         if (cant != "")
         {
             numericUpDownCantidad.Value = Convert.ToInt32(cant);
         }
         else
         {
             numericUpDownCantidad.Value = 0;
         }
     }
 }
        private void buttonAddPerfil_Click(object sender, EventArgs e)
        {
            string cadenaPrivilegios = "";

            foreach (bool value in privilegies)
            {
                if (value == true)
                {
                    cadenaPrivilegios += "1";
                }
                else
                {
                    cadenaPrivilegios += "0";
                }
            }
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                cpd.InsertDatos("tbl_perfilencabezado", "0, '" + textBoxNombrePerfil.Text + "', '" + cadenaPrivilegios + "'", "Insertar datos en Perfil");
                MessageBox.Show("Datos Guardados Exitosamente", "Datos Guardados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                clear();
                LoadForm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Guardar Los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        double GetCantidadVendidaPorProducto(string codProducto)
        {
            string cant = "";

            if (codProducto != "")
            {
                ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
                try
                {
                    cant = cpd.ExtraerCodigo3("SUM(tbl_ventasdetalle.Cantidad) as ", "CANTIDAD",
                                              "tbl_producto, tbl_ventasdetalle, tbl_movimientoinventario ",
                                              "tbl_ventasdetalle.tbl_Producto_id",
                                              "tbl_Producto.id " +
                                              "AND tbl_ventasdetalle.tbl_Producto_id = " + codProducto + " " +
                                              "AND tbl_movimientoinventario.id = tbl_ventasdetalle.tbl_movimientoinventario_id");
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            double res = 0;

            if (cant == "")
            {
                res = 0;
            }
            else
            {
                res = Convert.ToDouble(cant);
            }
            return(res);
        }