예제 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Guardar == true)
            {
                fn.Registrar("Productos", "'" + txtnombre.Text + "','" + txtDescripcion.Text.TrimEnd() + "','" + cbTipo.SelectedValue + "'");
                if (dgPresentacion.Rows.Count == 0)
                {
                    return;
                }

                string CodigoProducto = fn.select_one_value("max(IDProducto)", "Productos", "IDProducto!=0", 0);

                foreach (DataGridViewRow row in dgPresentacion.Rows)
                {
                    fn.Registrar("Presentacion", "'" + CodigoProducto + "','" + row.Cells["Nombre"].Value.ToString() + "','" + row.Cells["Costo"].Value.ToString() + "','" + row.Cells["Precio"].Value.ToString() + "'");
                }
            }
            else
            {
                fn.Modificar("Productos", "Nombre='" + txtnombre.Text.TrimEnd() + "',Descripcion='" + txtDescripcion.Text.TrimEnd() + "',IDCondicion='" + cbTipo.SelectedValue + "'", "IDProducto='" + IDProducto + "'");
            }
            CargarGrid();
            Desbloquear(false);
        }
예제 #2
0
        private void aCTIVARVENTAToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dgVentas.CurrentRow.Cells["ESTADO"].Value.ToString() == "OK")
            {
                MessageBox.Show("La Venta ya se Encuentra Activa", "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            string idVenta = dgVentas.CurrentRow.Cells[0].Value.ToString();

            DialogResult msj = MessageBox.Show("Desea ACTIVAR la Venta " + idVenta, "FactuTED", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (msj == DialogResult.OK)
            {
                SqlDataReader lectorPresentaciones = fn.selectMultiValues("select * from VentaDetalle where IDVenta = '" + idVenta + "'");
                while (lectorPresentaciones.Read())
                {
                    string idpresentacion = lectorPresentaciones["IDPresentacion"].ToString();
                    string cantidad       = lectorPresentaciones["Cantidad"].ToString();

                    SqlConnection conexion = new SqlConnection(Funciones.preconex);
                    string        oncod    = "select IDStockAlmacen,Cantidad from Receta WHERE IDPresentacion = '" + idpresentacion + "'";
                    SqlCommand    cmd      = new SqlCommand(oncod, conexion);
                    conexion.Open();
                    SqlDataReader lector = cmd.ExecuteReader();
                    while (lector.Read())
                    {
                        string idStockAlmacen = lector[0].ToString();
                        string IDInsumo       = fn.select_one_value("IDInsumo", "StockAlmacen", "IDStockAlmacen='" + idStockAlmacen + "'", 0);

                        //Descontando receta de producto paraventa
                        decimal cantidadSalida = Convert.ToDecimal(lector["Cantidad"].ToString()) * Convert.ToDecimal(cantidad);
                        fn.Modificar("StockAlmacen", "Stock=Stock-(" + cantidadSalida + ")", "IDStockAlmacen='" + idStockAlmacen + "'");
                    }
                }

                fn.Modificar("Venta", "Anulada='False'", "IDVenta='" + idVenta + "'");

                //REGISTRAMOS
                fn.RegistrarOficial("[Venta.Seguridad]", "Fecha,Hora,IDVenta,IDUsuario,Movimiento", "'" + DateTime.Now.ToShortDateString() + "','" + DateTime.Now.ToLongTimeString() + "','" + idVenta + "','" + Datos.idUsuario + "','VENTA ACTIVADA'");

                MessageBox.Show("Venta Activada", "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Information);

                buscar();
            }
        }