//Variables

        //FuncionesVarias

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

            try
            {
                //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());
                //Carga fecha de creacion
                fechaCreacion = cpd.ExtraerCodigo2("FechaEmision", "tbl_devolucionencabezado", "id", codigoEnc);
                //Carga de aprobado
                string apro = cpd.ExtraerCodigo2("Aprobado", "tbl_devolucionencabezado", "id", codigoEnc);
                if (apro == "0")
                {
                    aprobado = "Desaprobado";
                    buttonCambiarEstado.Enabled = true;
                }
                else
                {
                    aprobado = "Aprobado";
                    buttonCambiarEstado.Enabled = false;
                }
                //Carga de Cliente
                cliente = cpd.ExtraerCodigo3(
                    "Concat(tbl_cliente.NIT,',',tbl_persona.Nombre,',',tbl_organizacion.Nombre) as ", "NombreC",
                    "tbl_persona, tbl_organizacion, tbl_cliente, tbl_ventasencabezado",
                    "tbl_organizacion.id = tbl_cliente.tbl_organizacion_id " +
                    "AND tbl_cliente.tbl_Persona_id = tbl_Persona.id " +
                    "AND tbl_ventasencabezado.tbl_Cliente_id = tbl_Cliente.NIT " +
                    "AND tbl_ventasencabezado.id = " + codigoEnc + " " +
                    "AND tbl_cliente.status ", " 1");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL CARGAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Asignacion de datos a los labels
            labelEmpleado.Text     = datosEmpleado;
            labelNoDevolucion.Text = codigoEnc;
            labelFechaEntrega.Text = fechaCreacion;
            labelEstado.Text       = aprobado;
            labelNickname.Text     = NicknameEmpleado;
            labelCliente.Text      = cliente;
            cargarDetalle();
        }
        //Variables

        //FuncionesVarias

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

            try
            {
                //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());
                //Carga fecha de creacion
                fechaCreacion = cpd.ExtraerCodigo2("FechaEmision", "tbl_ventasencabezado", "id", codigoEnc);
                //Carga fecha de cancelacion
                fechaCancelacion = cpd.ExtraerCodigo2("FechaCancelacion", "tbl_ventasencabezado", "id", codigoEnc);
                //Carga de saldo
                saldo = cpd.ExtraerCodigo2("saldo", "tbl_ventasencabezado", "id", codigoEnc);
                //Carga de total
                total = cpd.ExtraerCodigo2("total", "tbl_ventasencabezado", "id", codigoEnc);
                //Carga de Cliente
                proveedor = cpd.ExtraerCodigo3(
                    "Concat(tbl_cliente.NIT,',',tbl_persona.Nombre,',',tbl_organizacion.Nombre) as ", "NombreC",
                    "tbl_persona, tbl_organizacion, tbl_cliente, tbl_ventasencabezado",
                    "tbl_organizacion.id = tbl_cliente.tbl_organizacion_id " +
                    "AND tbl_cliente.tbl_Persona_id = tbl_Persona.id " +
                    "AND tbl_ventasencabezado.tbl_Cliente_id = tbl_Cliente.NIT " +
                    "AND tbl_ventasencabezado.id = " + codigoEnc + " " +
                    "AND tbl_cliente.status ", " 1");
                //Carga de transporte
                transporte = cpd.ExtraerCodigo2("transporte", "tbl_ventasencabezado", "id", codigoEnc);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL CARGAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Asignacion de datos a los labels
            labelEmpleado.Text         = datosEmpleado;
            labelNoVenta.Text          = codigoEnc;
            labelFechaEntrega.Text     = fechaCreacion;
            labelFechaCancelación.Text = fechaCancelacion;
            labelSaldo.Text            = saldo;
            labelTotal.Text            = total;
            labelCliente.Text          = proveedor;
            labelNickname.Text         = NicknameEmpleado;
            labelTransporte.Text       = transporte;
            cargarDetalle();
        }
        ////////////////////////////////// PROCESOS TERCER GRAFICA

        string GetIDProducto(string numeroPosicion)
        {
            string id = "";
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                id = cpd.ExtraerCodigo3("CAN, PRODUCTO as ", "NombreC",
                                        "( " +
                                        "    SELECT PRODUCTO, MAX(CANTIDAD) as CAN " +
                                        "    FROM " +
                                        "    ( " +
                                        "        SELECT distinct " +
                                        "        tbl_producto.id as 'PRODUCTO', SUM(tbl_ventasdetalle.Cantidad) as CANTIDAD " +
                                        "        FROM " +
                                        "        tbl_producto, tbl_ventasdetalle, tbl_movimientoinventario "
                                        ,
                                        "        tbl_ventasdetalle.tbl_Producto_id ", " tbl_Producto.id " +
                                        "        AND tbl_movimientoinventario.id = tbl_ventasdetalle.tbl_movimientoinventario_id " +
                                        "        group by PRODUCTO " +
                                        "        order by CANTIDAD DESC " +
                                        "        limit 10 " +
                                        "    ) " +
                                        "    a GROUP by PRODUCTO " +
                                        ") " +
                                        "a GROUP by PRODUCTO " +
                                        "order by CAN DESC " +
                                        "limit " + numeroPosicion + ", 1 ");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(id);
        }
Beispiel #4
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;
        }
        /// <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);
        }
        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);
        }
        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();
        }
        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);
        }
        private void buttonAgregarAbono_Click_1(object sender, EventArgs e)
        {
            string[]      listaDetalle = new string[6];
            List <string> queryList    = new List <string>();

            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                foreach (DataGridViewRow row in dtg_ProductosDetalle.Rows)
                {
                    //Insercion de las cantidades a las bodegas
                    listaDetalle[0] = Convert.ToString(row.Cells[0].Value); //CODIGO
                    listaDetalle[1] = Convert.ToString(row.Cells[1].Value); //PRODUCTO
                    listaDetalle[2] = Convert.ToString(row.Cells[2].Value); //BODEGA
                    listaDetalle[3] = Convert.ToString(row.Cells[3].Value); //CANTIDAD
                    string[] datosProducto = listaDetalle[1].Split(',');
                    string[] datosBodega   = listaDetalle[2].Split(',');
                    int      sumaRows      = 0;
                    foreach (DataGridViewRow row2 in dtg_ProductosDetalle.Rows)
                    {
                        if (row.Cells[1].Value.ToString() == row2.Cells[1].Value.ToString())
                        {
                            sumaRows += Convert.ToInt32(row2.Cells[3].Value);
                        }
                    }

                    //Agregar al inventario
                    string CantidadEnExistencia = cpd.ExtraerCodigo3("Cantidad as ", "Cantidad",
                                                                     "tbl_productobodega",
                                                                     "tbl_Bodega_id= " + datosBodega[0] +
                                                                     " AND tbl_Producto_id ", datosProducto[0]);
                    if (CantidadEnExistencia == "")
                    {
                        CantidadEnExistencia = "0";
                    }
                    int totalCantidad = Convert.ToInt32(CantidadEnExistencia) + sumaRows;
                    queryList.Add(cpd.DevolverSentencia_Insert("tbl_productobodega",
                                                               datosBodega[0] + ", " + datosProducto[0] + ", " + listaDetalle[3] + ")  ON DUPLICATE KEY UPDATE " +
                                                               "Cantidad = " + totalCantidad + "; -- "));
                    queryList.Add(cpd.DevolverSentencia_Modificar("tbl_devolucionencabezado", "aprobado = 1", "id", codigoEnc));
                }

                /*string review = "";
                 * foreach (string var in queryList)
                 * {
                 *  review += var + "\n";
                 * }
                 * MessageBox.Show(review);*/
                cpd.EjectuarOperacionExterna(queryList, "", "", "Aprobacion de devolucion");
                MessageBox.Show("Se ha Realizado la devolucion", "DATOS GUARDADOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadForm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL GUARDAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
        //Variables

        ///Funciones varias

        // Funcion para cargar datos a paneles informativos
        void CargaPaneInformativo(Label lbl, string typeDateYear, string typeDateMonth, string typeDateDay, int variant, string typePanelInfo)
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
            string commandWHERE1         = "";
            string commandWHERE2         = "";

            if (typeDateMonth != "")
            {
                commandWHERE1 += " AND " + typeDateMonth + "(FechaEmision) " +
                                 " = (SELECT(" + typeDateMonth + "(NOW()))) ";
                if (typeDateDay != "")
                {
                    commandWHERE2 += " AND " + typeDateDay + "(FechaEmision) " +
                                     " = (SELECT(" + typeDateDay + "(NOW()))) ";
                }
            }

            //Carga el segundo panel informativo
            try
            {
                if (variant == 0)
                {
                    lbl.Text = cpd.ExtraerCodigo3("SUM(total) as ", "Total",
                                                  "tbl_ventasencabezado ",
                                                  typeDateYear + "(FechaEmision) ",
                                                  "(SELECT(" + typeDateYear + "(NOW()))) " + commandWHERE1 + commandWHERE2
                                                  + typePanelInfo
                                                  );
                }
                else
                {
                    lbl.Text = cpd.ExtraerCodigo3("SUM(total) as ", "Total",
                                                  "tbl_ventasencabezado",
                                                  "1",
                                                  "1" + typePanelInfo);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #11
0
        private void buttonGenerarReporte_Click(object sender, EventArgs e)
        {
            string datosEmpleado         = "";
            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()
                                                   );
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            ///
            ReporteadorFerreteria.REPORTS.ReportProductos objRpt = new ReporteadorFerreteria.REPORTS.ReportProductos();
            ReporteadorFerreteria.DATASETS.DataSetP       ds1    = new ReporteadorFerreteria.DATASETS.DataSetP();
            foreach (DataGridViewRow row in dtg_Productos.Rows)
            {
                ReporteadorFerreteria.DATASETS.DataSetP.tbl_productoRow rowProducto = ds1.tbl_producto.Newtbl_productoRow();
                rowProducto.id           = Convert.ToString(row.Cells["id"].Value);
                rowProducto.Nombre       = Convert.ToString(row.Cells["Nombre"].Value);
                rowProducto.PrecioCompra = Convert.ToString(row.Cells["PrecioCompra"].Value);
                rowProducto.PrecioVenta  = Convert.ToString(row.Cells["PrecioVenta"].Value);
                rowProducto.Material     = Convert.ToString(row.Cells["Material"].Value);
                rowProducto.Marca        = Convert.ToString(row.Cells["Marca"].Value);
                rowProducto.Color        = Convert.ToString(row.Cells["Color"].Value);
                rowProducto.Cantidad     = Convert.ToString(row.Cells["Cantidad"].Value);
                rowProducto.Bodega       = Convert.ToString(row.Cells["Bodega"].Value);

                ds1.tbl_producto.Addtbl_productoRow(rowProducto);
            }
            objRpt.SetDataSource(ds1);
            TextObject txtObject     = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextBy"];
            TextObject txtObjectDate = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextDate"];

            txtObjectDate.Text = DateTime.Now.ToLongTimeString();
            txtObject.Text     = datosEmpleado;
            UI_Visualizador form = new UI_Visualizador();

            form.crystalReportViewerGlobal.ReportSource = objRpt;
            form.ShowDialog();
        }
Beispiel #12
0
        private void buttonGenerarReporte_Click(object sender, EventArgs e)
        {
            string datosEmpleado         = "";
            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()
                                                   );
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            ///
            ReporteadorFerreteria.REPORTS.ReportDevoluciones objRpt = new ReporteadorFerreteria.REPORTS.ReportDevoluciones();
            ReporteadorFerreteria.DATASETS.DataSetP          ds1    = new ReporteadorFerreteria.DATASETS.DataSetP();
            foreach (DataGridViewRow row in DataGridViewDetalles.Rows)
            {
                ReporteadorFerreteria.DATASETS.DataSetP.tbl_ReporteDevolucionesRow rowDevoluciones = ds1.tbl_ReporteDevoluciones.Newtbl_ReporteDevolucionesRow();
                rowDevoluciones.id           = Convert.ToString(row.Cells["ID"].Value);
                rowDevoluciones.FechaEmision = Convert.ToString(row.Cells["FECHA EMISION"].Value);
                rowDevoluciones.Objetivo     = Convert.ToString(row.Cells["CLIENTE"].Value);
                rowDevoluciones.Aprobado     = Convert.ToString(row.Cells["APROBADO"].Value);
                rowDevoluciones.Motivo       = Convert.ToString(row.Cells["MOTIVO"].Value);

                ds1.tbl_ReporteDevoluciones.Addtbl_ReporteDevolucionesRow(rowDevoluciones);
            }
            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"];

            txtObjectDate.Text = DateTime.Now.ToLongTimeString();
            txtObject.Text     = datosEmpleado;
            UI_Visualizador form = new UI_Visualizador();

            form.crystalReportViewerGlobal.ReportSource = objRpt;
            form.ShowDialog();
        }
Beispiel #13
0
        // Variables

        // Funciones Varias

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

            try
            {
                //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());
                //Carga del combobox de proveedores
                cpd.cargarDatosACombobox2(comboBoxProveedor,
                                          "tbl_organizacion.Nombre as NombreC", "Nombre",
                                          "tbl_organizacion, tbl_proveedor " +
                                          "WHERE " +
                                          "tbl_proveedor.tbl_organizacion_id = tbl_organizacion.id " +
                                          "AND tbl_proveedor.status = 1");
                //Cargar datos de los productos
                cpd.cargarDatosACombobox2(comboBoxProducto, " CONCAT(id,',',Nombre) AS NombreC", "Nombre", "" +
                                          "tbl_Producto WHERE tbl_Producto.status = 1 ");
                //Cargar datos de los productos
                cpd.cargarDatosACombobox2(comboBoxBodega, " CONCAT(id,',',NombreBodega) AS NombreC", "Nombre", "" +
                                          "tbl_bodega WHERE tbl_bodega.status = 1 ");
            }
            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();
            ordenDeCompra           = nextCodigo();
            labelFechaEntrega.Text  = DateTime.Now.ToShortDateString();
            labelNickname.Text      = NicknameEmpleado;
        }
        ////////////////////////////////// PROCESOS TERCER GRAFICA

        string GetClienteID(string numeroPosicion)
        {
            string id = "";
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                id = cpd.ExtraerCodigo3("" +
                                        "MAX(Total) as TOTAL, MAX(Saldo) as SALDO,tbl_Cliente_id as ", "CLIENTE",
                                        "tbl_ventasencabezado ", "1", "1 " +
                                        "group by CLIENTE " +
                                        "order by TOTAL DESC " +
                                        "limit " + numeroPosicion + ", 1");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(id);
        }
Beispiel #15
0
        private void buttonAgregarEncabezado_Click(object sender, EventArgs e)
        {
            panelProductos.Visible = true;
            panelDataGird.Visible  = true;
            string   codigoProveedor     = "";
            string   codigoEmpleado      = "";
            DateTime fEntrega            = Convert.ToDateTime(labelFechaEntrega.Text);
            DateTime fCancelacion        = Convert.ToDateTime(dateTimePickerFechaCancelacion.Value.ToString("yyyy-MM-dd"));
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                codigoEmpleado  = cpd.ExtraerCodigo("tbl_Empleado_DPI", "tbl_Usuario", "Nickname", labelNickname.Text);
                codigoProveedor = cpd.ExtraerCodigo3("tbl_proveedor.id AS ", "NombreC", "tbl_Proveedor, tbl_Organizacion", "tbl_Organizacion.Nombre = '" + comboBoxProveedor.Text
                                                     + "' AND tbl_Organizacion.id ", " tbl_Proveedor.tbl_Organizacion_id");
                cpd.InsertDatos("tbl_ComprasEncabezado", "0, " + codigoProveedor + ", " + fEntrega.ToString("yyyyMMdd") + ", " + fCancelacion.ToString("yyyyMMdd") +
                                " ," + labelTotalOrden.Text + " ," + codigoEmpleado + ", 1, 0", "Ingreso de orden de compra");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL GUARDAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        string GetNameCliente(string codCliente)
        {
            string name = "";

            if (codCliente != "")
            {
                ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();
                try
                {
                    name = cpd.ExtraerCodigo3("CONCAT(tbl_Persona.Nombre,',',tbl_organizacion.Nombre) as ", "NombreC",
                                              "tbl_persona, tbl_organizacion, tbl_cliente",
                                              "tbl_cliente.NIT", codCliente + " " +
                                              "AND tbl_cliente.tbl_Persona_id = tbl_persona.id " +
                                              "AND tbl_cliente.tbl_organizacion_id = tbl_organizacion.id "
                                              );
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(name);
        }
        //Variables

        //Funciones

        void LoadForm()
        {
            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            // Llenar datagridview Principal
            try
            {
                DataSet ds = cpd.LlenarGrid("" +
                                            "tbl_movimientoinventario.id as 'CODIGO', " +
                                            "tbl_tipomovimiento.DescripcionMovimiento as 'MOVIMIENTO', " +
                                            "tbl_producto.Nombre as 'PRODUCTO', " +
                                            "tbl_movimientoinventario.FechaMovimiento as 'FECHA', " +
                                            "tbl_movimientoinventario.CantidadMovimiento as 'CANTIDAD', " +
                                            "tbl_movimientoinventario.PrecioMovimiento as 'PRECIO', " +
                                            "tbl_movimientoinventario.Subtotal as 'SUBTOTAL' ",
                                            "tbl_movimientoinventario, tbl_tipomovimiento, tbl_producto",
                                            "tbl_movimientoinventario.tbl_TipoMovimiento_id = tbl_TipoMovimiento.id " +
                                            "AND tbl_movimientoinventario.tbl_Producto_id = tbl_Producto.id " + filtro,
                                            "Vista datos de productos");
                dtg_Productos.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Llenar Ingresos
            try
            {
                string query = "select " +
                               "tbl_movimientoinventario.id " +
                               "from " +
                               "tbl_movimientoinventario, tbl_TipoMovimiento " +
                               "where " +
                               "tbl_movimientoinventario.tbl_TipoMovimiento_id = tbl_TipoMovimiento.id " +
                               "AND tbl_TipoMovimiento.DescripcionMovimiento = 'Compras';";
                labelIngresosQ.Text = cpd.ExtraerCodigo3("sum(subtotal) as ", "subtotal", "tbl_movimientoinventario, tbl_TipoMovimiento",
                                                         "tbl_movimientoinventario.tbl_TipoMovimiento_id = tbl_TipoMovimiento.id " +
                                                         "AND ( tbl_TipoMovimiento.DescripcionMovimiento",
                                                         "'Compras' " +
                                                         "OR tbl_TipoMovimiento.DescripcionMovimiento = 'Devoluciones') ;");
                labelIngresosC.Text = cpd.RetornoMenosExistencias(query).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Llenar Egresos
            try
            {
                string query = "select " +
                               "tbl_movimientoinventario.id " +
                               "from " +
                               "tbl_movimientoinventario, tbl_TipoMovimiento " +
                               "where " +
                               "tbl_movimientoinventario.tbl_TipoMovimiento_id = tbl_TipoMovimiento.id " +
                               "AND ( tbl_TipoMovimiento.DescripcionMovimiento = 'Ventas'" +
                               "OR tbl_TipoMovimiento.DescripcionMovimiento = 'Devoluciones') ;";
                labelEgresosQ.Text = cpd.ExtraerCodigo3("sum(subtotal) as ", "subtotal", "tbl_movimientoinventario, tbl_TipoMovimiento",
                                                        "tbl_movimientoinventario.tbl_TipoMovimiento_id = tbl_TipoMovimiento.id " +
                                                        "AND tbl_TipoMovimiento.DescripcionMovimiento",
                                                        "'Ventas' ;");
                labelEgresosC.Text = cpd.RetornoMenosExistencias(query).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error al Cargar los Datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #18
0
        private void buttonAgregarEncabezado_Click(object sender, EventArgs e)
        {
            panelProductos.Visible = true;
            panelDataGird.Visible  = true;
            string   codigoProveedor = "";
            string   codigoEmpleado  = "";
            DateTime fEntrega        = Convert.ToDateTime(labelFechaEntrega.Text);
            DateTime fCancelacion    = Convert.ToDateTime(dateTimePickerFechaCancelacion.Value.ToString("yyyy-MM-dd"));

            string[]      listaDetalle = new string[6];
            List <string> queryList    = new List <string>();

            ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria();

            try
            {
                // Insersion del encabezado
                codigoEmpleado  = cpd.ExtraerCodigo("tbl_Empleado_DPI", "tbl_Usuario", "Nickname", labelNickname.Text);
                codigoProveedor = cpd.ExtraerCodigo3("tbl_proveedor.id AS ", "NombreC", "tbl_Proveedor, tbl_Organizacion", "tbl_Organizacion.Nombre = '" + comboBoxProveedor.Text
                                                     + "' AND tbl_Organizacion.id ", " tbl_Proveedor.tbl_Organizacion_id");
                queryList.Add(cpd.DevolverSentencia_Insert("tbl_ComprasEncabezado", "0, " + codigoProveedor + ", " + fEntrega.ToString("yyyyMMdd") + ", " + fCancelacion.ToString("yyyyMMdd") +
                                                           " ," + labelTotalOrden.Text + " ," + codigoEmpleado + ", 1, 0, " + labelTotalOrden.Text));
                //Insersino del detalle
                foreach (DataGridViewRow row in dtg_ProductosDetalle.Rows)
                {
                    listaDetalle[0] = Convert.ToString(row.Cells[0].Value); //PRODUCTO
                    listaDetalle[1] = Convert.ToString(row.Cells[1].Value); //BODEGA
                    listaDetalle[2] = Convert.ToString(row.Cells[2].Value); //CANTIDAD
                    listaDetalle[3] = Convert.ToString(row.Cells[3].Value); //PRECIO
                    listaDetalle[4] = Convert.ToString(row.Cells[4].Value); //SUBTOTAL
                    string[] datosProducto = listaDetalle[0].Split(',');
                    string[] datosBodega   = listaDetalle[1].Split(',');
                    //Agregar el movimiento
                    string movCode = nextCodigo("tbl_MovimientoInventario");
                    queryList.Add(cpd.DevolverSentencia_Insert("tbl_movimientoInventario",
                                                               "0, 1, " + datosProducto[0] + ", " + fEntrega.ToString("yyyyMMdd") + ", " + listaDetalle[2] +
                                                               ", " + listaDetalle[3] + ", " + listaDetalle[4] + ", " + datosBodega[0]));
                    queryList.Add(cpd.DevolverSentencia_Insert("tbl_comprasdetalle", "0, " + labelNoOrdenCompra.Text + ", " + datosProducto[0] + ", " + listaDetalle[2]
                                                               + ", " + listaDetalle[3] + ", " + listaDetalle[4] + ", " + movCode));
                }
                foreach (DataGridViewRow row in dtg_ProductosDetalle.Rows)
                {
                    listaDetalle[0] = Convert.ToString(row.Cells[0].Value); //PRODUCTO
                    listaDetalle[1] = Convert.ToString(row.Cells[1].Value); //BODEGA
                    listaDetalle[2] = Convert.ToString(row.Cells[2].Value); //CANTIDAD
                    listaDetalle[3] = Convert.ToString(row.Cells[3].Value); //PRECIO
                    listaDetalle[4] = Convert.ToString(row.Cells[4].Value); //SUBTOTAL
                    string[] datosProducto = listaDetalle[0].Split(',');
                    string[] datosBodega   = listaDetalle[1].Split(',');
                    int      sumaRows      = 0;
                    foreach (DataGridViewRow row2 in dtg_ProductosDetalle.Rows)
                    {
                        if (row.Cells[0].Value.ToString() == row2.Cells[0].Value.ToString())
                        {
                            sumaRows += Convert.ToInt32(row2.Cells[2].Value);
                        }
                    }

                    //Agregar al inventario
                    string CantidadEnExistencia = cpd.ExtraerCodigo3("Cantidad as ", "Cantidad",
                                                                     "tbl_productobodega",
                                                                     "tbl_Bodega_id= " + datosBodega[0] +
                                                                     " AND tbl_Producto_id ", datosProducto[0]);
                    if (CantidadEnExistencia == "")
                    {
                        CantidadEnExistencia = "0";
                    }
                    int totalCantidad = Convert.ToInt32(CantidadEnExistencia) + sumaRows;
                    queryList.Add(cpd.DevolverSentencia_Insert("tbl_productobodega",
                                                               datosBodega[0] + ", " + datosProducto[0] + ", " + listaDetalle[2] + ")  ON DUPLICATE KEY UPDATE " +
                                                               "Cantidad = " + totalCantidad + "; -- "));
                }

                /*string review = "";
                 * foreach(string var in queryList)
                 * {
                 *  review += var + "\n";
                 * }
                 * MessageBox.Show(review);*/
                cpd.EjectuarOperacionExterna(queryList, "", "", "Registro de compra");
                MessageBox.Show("Se ha Realizado la compra", "DATOS GUARDADOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Refrresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR AL GUARDAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #19
0
        private void buttonGenerarReporte_Click(object sender, EventArgs e)
        {
            string datosEmpleado         = "";
            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()
                                                   );
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            ///
            ReporteadorFerreteria.REPORTS.ReportComprasVentas objRpt = new ReporteadorFerreteria.REPORTS.ReportComprasVentas();
            ReporteadorFerreteria.DATASETS.DataSetP           ds1    = new ReporteadorFerreteria.DATASETS.DataSetP();
            foreach (DataGridViewRow row in DataGridViewDetalles.Rows)
            {
                ReporteadorFerreteria.DATASETS.DataSetP.tbl_ReporteVentaCompraRow rowVentaCompra = ds1.tbl_ReporteVentaCompra.Newtbl_ReporteVentaCompraRow();
                rowVentaCompra.id               = Convert.ToString(row.Cells["ID"].Value);
                rowVentaCompra.FechaEmision     = Convert.ToString(row.Cells["FECHA EMISION"].Value);
                rowVentaCompra.FechaCancelacion = Convert.ToString(row.Cells["FECHA CANCELACION"].Value);
                rowVentaCompra.Total            = Convert.ToString(row.Cells["TOTAL"].Value);
                rowVentaCompra.Objetivo         = Convert.ToString(row.Cells[titleObjetivo].Value);
                rowVentaCompra.Cancelado        = Convert.ToString(row.Cells["CANCELADO"].Value);
                rowVentaCompra.Saldo            = Convert.ToString(row.Cells["SALDO"].Value);

                ds1.tbl_ReporteVentaCompra.Addtbl_ReporteVentaCompraRow(rowVentaCompra);
            }
            objRpt.SetDataSource(ds1);
            TextObject txtObject     = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextBy"];
            TextObject txtObjectDate = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextDate"];
            TextObject txtTotal      = (TextObject)objRpt.ReportDefinition.Sections["Section4"].ReportObjects["TextTotal"];
            TextObject txtSaldo      = (TextObject)objRpt.ReportDefinition.Sections["Section4"].ReportObjects["TextSaldo"];
            string     type          = "";

            if (tablaObj == "tbl_comprasencabezado")
            {
                type = "COMPRAS";
            }
            else
            {
                type = "VENTAS";
            }
            TextObject txtObjectType = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextType"];

            txtTotal.Text      = sumarFilas(3).ToString();
            txtSaldo.Text      = sumarFilas(6).ToString();
            txtObjectDate.Text = DateTime.Now.ToLongTimeString();
            txtObject.Text     = datosEmpleado;
            txtObjectType.Text = type;
            UI_Visualizador form = new UI_Visualizador();

            form.crystalReportViewerGlobal.ReportSource = objRpt;
            form.ShowDialog();
        }