Example #1
0
        private void GuardarDetallePresupuesto(clsDetallePresupuestos pDetPresu)
        {
            //Cargar el producto en la tabla
            //Guardar la factura
            string myCadSQL = "INSERT INTO DetallePresupuestos (IdDetPresupuesto, " +
                              " IdPresupuesto," +
                              " IdArticulo," +
                              " Codigo_Articulo," +
                              " Cantidad," +
                              " Descripcion," +
                              " PrecioUnitario," +
                              " Activo," +
                              " Excel," +
                              " Orden)" +
                              "  values (" + pDetPresu.IdDetPresupuesto + "," +
                              pDetPresu.IdPresupuesto + "," +
                              pDetPresu.IdArticulo + ",'" +
                              pDetPresu.Codigo_Articulo + "'," +
                              pDetPresu.Cantidad.ToString().Replace(",", ".") + ",'" +
                              pDetPresu.Descripcion + "'," +
                              pDetPresu.PrecioUnitario.ToString().Replace(",", ".") + "," +
                              pDetPresu.Activo + "," +
                              pDetPresu.Excel + "," +
                              pDetPresu.Orden + ")";


            clsDataBD.GetSql(myCadSQL);
        }
Example #2
0
        private void btnPresu_Click(object sender, EventArgs e)
        {
            DataTable myDataPresu   = new DataTable();
            DataTable myDataDetalle = new DataTable();

            string PedNro   = dgvComprobantes.CurrentRow.Cells["Numero"].Value.ToString();
            string myCadena = "";

            //Timer
            TriggerTime.Stop();
            //CERRAR EL PRESUPUESTO ACTUAL
            DialogResult dlResult = MessageBox.Show("Desea CERRAR el PEDIDO N° " + PedNro + " ?. Esta acción < NO > se pude deshacer!", "Confirmar!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            // Si confirma... cambiar estado
            if (dlResult == DialogResult.Yes)
            {
                //Pasar Pedido a Presupuestos //// ....
                myCadena    = "Select * from Pedidos Where IdPedido = " + IdPedido;
                myDataPresu = clsDataBD.GetSql(myCadena);

                //NUEVO OBJETO PRESUPUESTOS
                clsPresupuestos myPresu = new clsPresupuestos();

                //RECORRER GRILLA Y GUARDAR EN EL OBJETO
                foreach (DataRow filas in myDataPresu.Rows)
                {
                    /*Guardar en Matriz*/
                    myPresu.IdPresupuesto = clsDataBD.RetornarUltimoId("Presupuestos", "IdPresupuesto") + 1;
                    myPresu.IdCliente     = Convert.ToInt32(filas["IdCliente"].ToString());
                    myPresu.IdFormaPago   = Convert.ToInt32(filas["IdFormaPago"].ToString());
                    myPresu.Punto         = Convert.ToInt32(filas["Punto"].ToString());
                    // ** 29/05
                    // myPresu.Nro = clsDataBD.RetornarMax("Presupuestos","Nro")+1;
                    // **
                    myPresu.Nro = clsDataBD.getUltComp("Ult_Presupuesto", clsGlobales.cParametro.PtoVtaPorDefecto, 0) + 1;  //
                    // **
                    myPresu.PuntoNro      = myPresu.Punto.ToString("D4") + "-" + myPresu.Nro.ToString("D8");
                    myPresu.IdTransporte  = Convert.ToInt32(filas["IdTransporte"].ToString());
                    myPresu.Fecha         = DateTime.Now;
                    myPresu.Comentario    = filas["Comentario"].ToString();
                    myPresu.Dto           = Convert.ToDouble(filas["Dto"].ToString());
                    myPresu.Flete         = Convert.ToDouble(filas["Flete"].ToString());
                    myPresu.Facturado     = 0;
                    myPresu.Activo        = 1;
                    myPresu.Excel         = Convert.ToInt32(filas["Excel"].ToString());
                    myPresu.Pendiente     = 0;
                    myPresu.Codigo_Correo = "No establecido";
                }

                //Guardar el Presupuesto
                GuardarPresupuesto(myPresu);

                //Actualizar el numero de presupuesto en Tabla AFIP
                string mySQL = "UPDATE PuntosVentaAFIP SET Ult_Presupuesto = " + myPresu.Nro + " WHERE Punto = " + clsGlobales.cParametro.PtoVtaPorDefecto;
                clsDataBD.GetSql(mySQL);

                //GUARDAR EL DETALLE
                myCadena      = "Select * from Vista_Detalle_Pedido_ABM where IdPedido = " + IdPedido;
                myDataDetalle = clsDataBD.GetSql(myCadena);

                clsDetallePresupuestos myDetallePresupuesto = new clsDetallePresupuestos();

                foreach (DataRow filas in myDataDetalle.Rows)
                {
                    myDetallePresupuesto.IdDetPresupuesto = clsDataBD.RetornarUltimoId("DetallePresupuestos", "IdDetPresupuesto") + 1;
                    myDetallePresupuesto.IdPresupuesto    = myPresu.IdPresupuesto;
                    myDetallePresupuesto.IdArticulo       = Convert.ToInt32(filas["IdArticulo"].ToString());
                    myDetallePresupuesto.Codigo_Articulo  = filas["CodigoArticulo"].ToString();
                    myDetallePresupuesto.Cantidad         = Convert.ToInt32(filas["Cantidad"].ToString());
                    myDetallePresupuesto.Descripcion      = filas["Articulo"].ToString();
                    myDetallePresupuesto.PrecioUnitario   = Convert.ToDouble(filas["Precio"].ToString());
                    myDetallePresupuesto.Activo           = 1;
                    myDetallePresupuesto.Excel            = Convert.ToInt32(filas["Excel"].ToString());
                    myDetallePresupuesto.Orden            = Convert.ToInt32(filas["Orden"].ToString());

                    //GUARDAR DETALLE DEL PRESUPUESTO
                    GuardarDetallePresupuesto(myDetallePresupuesto);
                }

                //Quitar el PEDIDO
                myCadena = "DELETE FROM Pedidos WHERE IdPedido =" + IdPedido;
                clsDataBD.GetSql(myCadena);
                //Quitar el DETALLE
                myCadena = "DELETE FROM DetallePedidos WHERE IdPedido =" + IdPedido;
                clsDataBD.GetSql(myCadena);
                //Timer
                TriggerTime.Start();
                //Refrescar grilla
                this.CargarGrilla("", "");
                //Posicionar en grilla
                this.PosicionarFocoFila();
            }
        }