예제 #1
0
        public string mantenerpedido(PedidoCE aut, string accion)
        //public string mantenerAuto(Autos aut)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "sp_mantenimientopedido";
            cmd.Connection  = cn;
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@pedcod", SqlDbType.Int).Value      = aut.getCodigo();
            cmd.Parameters.Add("@dni", SqlDbType.VarChar, 25).Value = aut.getCliente();
            cmd.Parameters.Add("@monto", SqlDbType.Decimal).Value   = aut.getMonto();
            cmd.Parameters.Add("@fecha", SqlDbType.DateTime).Value  = aut.getFecha();
            cmd.Parameters.Add("@codest", SqlDbType.Char, 2).Value  = aut.getEstado();

            cmd.Parameters.Add("@accion", SqlDbType.Char, 1).Value = accion;


            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
                return("exito");
            }
            catch (Exception e)
            {
                return("Error" + e.ToString());
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
            }
        }
예제 #2
0
        public void agregarCarrito(PedidoCE ped)
        {
            DataRow fila = carrito.NewRow();

            fila[0] = ped.getProveedor();
            fila[1] = ped.getModelo();
            fila[2] = ped.getMonto();
            fila[3] = ped.getCantidad();
            // fila[4] = ped.getCliente();

            carrito.Rows.Add(fila);
        }
예제 #3
0
        public string registrarPedido(PedidoCE ped, DataTable tabla)
        {
            string         msg = "";
            int            cod = generarCodigo();
            SqlTransaction tr  = cn.BeginTransaction(IsolationLevel.Serializable);
            SqlCommand     com = new SqlCommand("sp_registrarpedidocab", cn, tr);

            try
            {
                //cn.Open();

                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("@pedcod", SqlDbType.Int).Value     = cod;
                com.Parameters.Add("@dni", SqlDbType.VarChar, 9).Value = ped.getCliente();
                com.Parameters.Add("@monto", SqlDbType.Decimal).Value  = ped.getMonto();

                com.ExecuteNonQuery();

                foreach (DataRow r in tabla.Rows)
                {
                    com             = new SqlCommand("sp_registrarpedidodet", cn, tr);
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.Add("@pedcod", SqlDbType.Int).Value = cod;
                    //string proveedor = r["proveedor"].ToString();
                    com.Parameters.Add("@nomprov", SqlDbType.VarChar, 50).Value = r["idprov"];
                    com.Parameters.Add("@modelo", SqlDbType.VarChar, 15).Value  = r["modelo"];
                    com.Parameters.Add("@precio", SqlDbType.Decimal).Value      = r["precio"];
                    com.Parameters.Add("@cantidad", SqlDbType.Int).Value        = r["cantidad"];
                    com.Parameters.Add("@subtotal", SqlDbType.Decimal).Value    = r["subtotal"];
                    com.ExecuteNonQuery();
                }

                tr.Commit();
                carrito.Clear();
                msg = "exito";
            }
            catch (Exception e)
            {
                tr.Rollback();
                msg = "Error!" + e.ToString();
            }
            finally
            {
                com.Dispose();
                cn.Close();
            }

            return(msg);
        }
예제 #4
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            int cantidad = 0;

            if (txtCantidad.Text == "0" || txtCantidad.Text == "")
            {
                txtCantidad.Text = "";
                lblMensaje.Text  = "Cantidad no Aceptada";
            }
            else
            {
                cantidad = Int32.Parse(lblStock.Text) - Int32.Parse(txtCantidad.Text);
                if (cantidad >= 0)
                {
                    pedido = new PedidoCE();
                    pedido.setModelo(lblCodigo.Text);
                    pedido.setProveedor(lblProveedor.Text);
                    //  pedido.setCliente(lista[3].ToString());
                    pedido.setMonto(Double.Parse(lblPrecio.Text));
                    pedido.setCantidad(Int32.Parse(txtCantidad.Text));


                    pedidobl = new PedidoCR();
                    pedidobl.setCarrito((DataTable)Session["carrito"]);
                    pedidobl.agregarCarrito(pedido);
                    Session["carrito"] = pedidobl.getCarrito();


                    txtCantidad.Text = "";
                    lblMensaje.Text  = "Registro Agregado";
                }
                else
                {
                    txtCantidad.Text = "";
                    lblMensaje.Text  = "Cantidad no Aceptada";
                }
            }
        }
예제 #5
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            tabla = (DataTable)Session["carrito"];
            string   msg    = "";
            PedidoCE pedido = new PedidoCE();


            if (lblTotal.Text == "0")
            {
                lblTotal.Text   = "0";
                lblMensaje.Text = "No hay productos";
                limpiar();
            }

            if (lblTotal.Text != "0")
            {
                pedido.setCliente(lista[0].ToString());
                pedido.setMonto(Convert.ToDouble(lblTotal.Text));
                msg = p.registrarPedido(pedido, tabla);

                if (msg == "exito")
                {
                    Session.Remove("carrito");
                    generardoc();
                    cargarDatos();
                    Button2.Enabled = false;

                    gvCarrito.Enabled = false;
                }
                else
                {
                    lblTotal.Text   = "0";
                    lblMensaje.Text = "No hay productos";
                    limpiar();
                }
            }
        }
예제 #6
0
 public string mantenerpedido(PedidoCE aut, string accion)
 {
     return(pedidocd.mantenerpedido(aut, accion));
 }
예제 #7
0
 public string registrarPedido(PedidoCE pedido, DataTable tabla)
 {
     return(pedidocd.registrarPedido(pedido, tabla));
 }
예제 #8
0
 public void agregarCarrito(PedidoCE ped)
 {
     pedidocd.setCarrito(carrito);
     pedidocd.agregarCarrito(ped);
     carrito = pedidocd.getCarrito();
 }