public ViewResult Checkout(Carrinho carrinho, Despacho despacho)
 {
     carrinho = GetCarrinho();
     if (carrinho.Itens.Count() == 0)
     {
         ModelState.AddModelError("", "Seu carrinho está vazio");
     }
     if (ModelState.IsValid)
     {
         try
         {
             _processarPedido.ProcessarPedido(carrinho, despacho);
             carrinho.LimparCarrinho();
             return(View("PedidoConcluido"));
         }
         catch (Exception ex)
         {
             return(View("_Erro", new HandleErrorInfo(ex, "Checkout", "Carrinho")));
         }
     }
     else
     {
         return(View(despacho));
     }
 }
Exemple #2
0
        public override void Notificar(RealizarDespachoArgs args)
        {
            if (verificarArgumentos(args))
            {
                new Erro("Por favor preencha todos os campos necessários");
                return;
            }

            Despacho despachoRejeitar = new Despacho()
            {
                id_projeto    = projeto.id,
                resultado     = resultado.ToLower(),
                data_despacho = DateTime.Now
            };
            int idDespacho = servicoDespacho.CriarDespacho(despachoRejeitar);

            DespachoIncentivo despachoIncentivo = new DespachoIncentivo()
            {
                id_despacho    = idDespacho,
                montante       = Convert.ToDouble(args.val1),
                custo_elegivel = Convert.ToDouble(args.val2),
                prazo_execucao = Convert.ToDateTime(args.data)
            };

            servicoDespacho.CriarDespachoIncentivo(despachoIncentivo);

            string estado     = servicoObterEstados.ObterEstado(projeto.estado).estado1;
            string estadoNovo = Utils.EstadoParaString(MaquinaDeEstados.processar(Utils.StringParaEstado(estado), EventosProjeto.despacho_aprovado));

            projeto.estado = servicoObterEstados.ObterIdEstado(estadoNovo);
            servicoProjetos.AtualizarProjeto(projeto);

            Vista.Hide();
            Vista.Close();
        }
Exemple #3
0
        public RealizarPagamento(Projeto projeto) : base(new FormRealizarPagamento())
        {
            this.projeto        = projeto;
            servicoProjetos     = CRUDProjetos.ObterInstancia();
            servicoDespacho     = CRUDDespacho.ObterInstancia();
            servicoPagamento    = CRUDPagamento.ObterInstancia();
            servicoObterEstados = ObterEstados.ObterInstancia();
            despacho            = servicoDespacho.LerUltimoDespacho(projeto);
            despachoMaisRecente = despacho.DespachoIncentivo;
            bool expirou = ConfirmarData();

            totalAPagar();
            Vista.AlterarDados(Convert.ToString(aPagar));
            Vista.Notificavel = this;
            if (expirou)
            {
                Erro erro = new Erro("A data de pagamento do projeto expirou.");
                Vista.Hide();
                Vista.Close();
            }
            else
            {
                Vista.ShowDialog();
            }
        }
Exemple #4
0
        private void MostrarDespacho()
        {
            Despacho des = new Despacho();

            dtg_despacho.ItemsSource = des.ReadAll();
            dtg_despacho.Items.Refresh();
        }
Exemple #5
0
        public async Task <ActionResult> Create([Bind(Include = "DespachoID,NombreDocumento,NumeroDocumento,ClienteID,DireccionDespacho,BodegaID,Fecha,BodegaOrigen,Linea,Status")] Despacho despacho, FormCollection post)
        {
            despacho.Fecha = Helpers.convertirFecha(post["Fecha"]);

            //Se obtiene el detalle:
            string[] productoID     = Request.Form.GetValues("producto");
            string[] cantidad       = Request.Form.GetValues("cantidad");
            string[] precioUnitario = Request.Form.GetValues("precioUnitario");
            string[] costoVigente   = Request.Form.GetValues("costoVigente");
            string[] totalNetoLinea = Request.Form.GetValues("totalNetoLinea");

            List <DetalleDespacho> detalleDespacho = new List <DetalleDespacho>();

            for (int i = 0; i < productoID.Length; i++)
            {
                DetalleDespacho nuevo = new DetalleDespacho();

                nuevo.Despacho = despacho;

                nuevo.productos      = db.productos.Find(int.Parse(productoID[i]));
                nuevo.Cantidad       = double.Parse(cantidad[i]);
                nuevo.CostoVigente   = double.Parse(costoVigente[i]);
                nuevo.PrecioUnitario = double.Parse(precioUnitario[i]);
                nuevo.TotalNetoLinea = double.Parse(totalNetoLinea[i]);

                detalleDespacho.Add(nuevo);
            }

            db.Despachos.Add(despacho);
            db.DetalleDespacho.AddRange(detalleDespacho);

            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DespachoId,NombreDespacho")] Despacho despacho)
        {
            if (id != despacho.DespachoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(despacho);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DespachoExists(despacho.DespachoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(despacho));
        }
        public ActionResult Editar(Despacho a)

        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                using (var db = new AlmacenContext())
                {
                    Despacho Des = db.Despacho.Find(a.Id);
                    Des.Fecha               = a.Fecha;
                    Des.Tipo_de_accion      = a.Tipo_de_accion;
                    Des.Cliente             = a.Cliente;
                    Des.Contacto            = a.Contacto;
                    Des.Detalle_de_producto = a.Detalle_de_producto;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #8
0
        private void Btn_guardar_Click(object sender, RoutedEventArgs e)
        {
            if (cb_compra.Text != String.Empty && cb_producto.Text != String.Empty && cb_empleado.Text != String.Empty &&
                cb_estado.Text != String.Empty)
            {
                Despacho des = new Despacho()
                {
                    ID_DESPACHO  = 0,
                    ID_DETALLE   = (decimal)cb_producto.SelectedValue,
                    ID_ESTADO    = (short)cb_estado.SelectedValue,
                    RUT_EMPLEADO = cb_empleado.SelectedValue.ToString().Trim(),
                    FECHA_ENVIO  = DateTime.Now
                };

                if (des.Create())
                {
                    MessageBoxResult exito = MessageBox.Show("Se creo la orden de despacho", "Éxito",
                                                             MessageBoxButton.OK, MessageBoxImage.Information);
                }

                else
                {
                    MessageBoxResult mal = MessageBox.Show("No se guardo el despacho", "Error",
                                                           MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            else
            {
                MessageBoxResult mal = MessageBox.Show("Debe llenar todos los campos", "Error",
                                                       MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemple #9
0
        public void InitVista(Projeto projeto)
        {
            Promotor    promotor    = servicoPromotor.LerPromotor(projeto.id_promotor);
            Responsavel responsavel = servicoResponsavel.LerResponsavel(projeto.id_responsavel);

            Vista.AlterarDadosPromotor(promotor.nome, promotor.nacionalidade, promotor.nib, promotor.nif);
            Vista.AlterarDadosResponsavel(responsavel.nome, responsavel.telefone, responsavel.email);

            String tipo   = projeto.Bonificacao != null ? "Bonificação" : "Incentivo";
            String estado = servicoObterEstados.ObterEstado(projeto.estado).estado1;

            Vista.AlterarDadosProjeto(projeto.id, projeto.Tecnico.Utilizador.username, tipo, projeto.montante_solicitado, projeto.descricao, estado, projeto.data_criacao);

            ListarDespacho(servicoDespacho.LerDespachosDeProjeto(projeto));
            ListarPagamentos(servicoPagamento.LerPagamentosDeProjeto(projeto));
            ListarPareceresTecnico(servicoParecer.LerParecerTecnicosDeProjeto(projeto));
            Despacho ultimoDespacho = servicoDespacho.LerUltimoDespacho(projeto);

            if (ultimoDespacho != null)
            {
                if (ultimoDespacho.DespachoBonificacao != null)
                {
                    ConfirmarDespachoExpirado(projeto, ultimoDespacho.DespachoBonificacao);
                }
                ListarPedidosDeReforco(servicoPedidoDeReforoco.LerPedidosDeReforco(ultimoDespacho));
            }
        }
Exemple #10
0
 public JsonResult jsonDetalleDespacho(int id)
 {
     Despacho despacho = db.Despachos.Find(id);
    
     var resultDetalle = db.DetalleDespacho.Where(s => s.DespachoID == despacho.DespachoID);
     return Json(resultDetalle, JsonRequestBehavior.AllowGet);
 }
        public void leerExcel(string pAbsolutePath)
        {
            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Despacho.db3");

                var db = new SQLiteConnection(dbPath);

                db.Table <Despacho>().Delete(d => d.Despachado == 0 | d.Despachado == 1);

                ExcelEngine excelEngine = new ExcelEngine();

                using (var stream = File.Open(pAbsolutePath, FileMode.Open, FileAccess.Read))
                {
                    var workbook = excelEngine.Excel.Workbooks.Open(stream);

                    var worksheet = workbook.Worksheets["Listado"];

                    var usedRange = worksheet.UsedRange;

                    for (int i = 3; i <= usedRange.LastRow; i++)
                    {
                        Despacho despacho = new Despacho();
                        despacho.Contenedor = worksheet[i, 1].DisplayText;
                        despacho.Tamanho    = worksheet[i, 2].DisplayText;
                        db.Insert(despacho);
                    }
                }
                App.Current.MainPage = new HomePage();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #12
0
        public ActionResult Editar(Despacho e)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                using (var db = new GestionDeAlmacenContext())
                {
                    Despacho cl = db.Despacho.Find(e.id);
                    cl.fecha                = e.fecha;
                    cl.tipo_de_acciom       = e.tipo_de_acciom;
                    cl.producto             = e.producto;
                    cl.clientes             = e.clientes;
                    cl.contactos            = e.contactos;
                    cl.Detalle_de_productos = e.Detalle_de_productos;
                    cl.cant_producto        = e.cant_producto;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #13
0
        private void BtEdit_Click(object sender, EventArgs e)
        {
            if (lstMain.SelectedItem == null)
            {
                return;
            }
            inputBox iBox = new inputBox();
            String   sCod = iBox.Show(lstMain.Text, "Informação", "Digite o nome do despacho.", 40);

            if (!string.IsNullOrEmpty(sCod))
            {
                Processo_bll processo_class             = new Processo_bll(_connection);
                Despacho     reg                        = new Despacho();
                GtiTypes.CustomListBoxItem selectedData = (GtiTypes.CustomListBoxItem)lstMain.SelectedItem;
                reg.Codigo    = Convert.ToInt16(selectedData._value);
                reg.Descricao = sCod.ToUpper();
                reg.Ativo     = lstMain.GetItemChecked(lstMain.SelectedIndex);
                Exception ex = processo_class.Alterar_Despacho(reg);
                if (ex != null)
                {
                    ErrorBox eBox = new ErrorBox("Atenção", "Despacho já cadastrado.", ex);
                    eBox.ShowDialog();
                }
                else
                {
                    Carrega_Lista();
                }
            }
        }
Exemple #14
0
        public Exception Excluir_Despacho(Despacho reg)
        {
            Processo_Data obj = new Processo_Data(_connection);
            Exception     ex  = obj.Excluir_Despacho(reg);

            return(ex);
        }
Exemple #15
0
        private void MostrarDespacho()
        {
            Despacho des = new Despacho();

            dtg_despacho.ItemsSource = des.ReadRutPendientes(Login.rut);
            dtg_despacho.Items.Refresh();
        }
Exemple #16
0
        public ArrayList Un_Carro_X_Clave_All(int id_grupo, int bloque, int id_expediente)
        {
            Cursor.Current = Cursors.WaitCursor;
            var       exp               = new e_expedientes();
            var       llam              = new z_llamados();
            int       id_carro_tip      = 0;
            string    sindesp           = "";
            ArrayList list_carros_alist = new ArrayList();

            try
            {
                exp  = exp.getObjecte_expedientes(id_expediente);
                llam = llam.getObjectz_llamados(exp.codigo_principal);
            }
            catch (Exception ex)
            {
                Log.ShowAndLog(ex);
            }

            if (exp.id_area != 0)
            {
                // Obtener el ID de Carro Según Grupo Solicitado
                list_carros_alist = Despacho.Ranking_x_Claves_All(exp.id_expediente, id_grupo.ToString(), bloque);
                // List<int> id_carros = llam.incendio ? Despacho.DespacharBatallon(id_expediente, id_area, llam.codigo_llamado - 50, out sindesp) : Despacho.Despachar(id_expediente, id_area);



                /*
                 * var cd = new ConfirmarDespacho
                 * {
                 *  IdCarros = id_carros,
                 *  IdExpediente = id_expediente,
                 *  IdArea = id_area
                 * };
                 * cd.lblSinDesp.Text += "\n" + sindesp;
                 *
                 * // ******
                 *
                 * // ******************
                 *
                 * cd.ShowDialog();
                 * btnDespachar.Blink = false;
                 * ZeusWin.Actualizar();
                 *
                 * }
                 * else
                 * {
                 * var id_carros = new List<int>();
                 * var cd = new CarroDisponible { IdCarros = id_carros };
                 * if (cd.ShowDialog() == DialogResult.OK)
                 * {
                 *  Despacho.ConfirmarDespacho(id_carros, id_expediente);
                 * }
                 * }
                 * Cursor.Current = Cursors.Default;
                 */
            }
            return(list_carros_alist);
        }
Exemple #17
0
 public void AtualizarDespacho(Despacho despacho)
 {
     using (Entidades context = new Entidades())
     {
         context.Entry(despacho).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public ActionResult Detalles(int Id)
 {
     using (var db = new AlmacenContext())
     {
         Despacho Pro = db.Despacho.Find(Id);
         return(View(Pro));
     }
 }
        public void ContarEnviosPendientesEmpleadoTest()
        {
            Despacho des = new Despacho();

            int res = des.ReadRutPendientes("15969833-4").Count();

            Assert.AreEqual(3, res);
        }
Exemple #20
0
 public ActionResult Detalles(int id)
 {
     using (var db = new GestionDeAlmacenContext())
     {
         Despacho cl4 = db.Despacho.Find(id);
         return(View(cl4));
     }
 }
 public static Despacho TraerDespacho(string id)
 {
     using (PJInventarioEntities database = new PJInventarioEntities())
     {
         Despacho despacho = database.Despacho.Find(id);
         return(despacho);
     }
 }
 private void ConfirmarDespacho_FormClosed(object sender, FormClosedEventArgs e)
 {
     axShockwaveFlash1.Dispose();
     if (!confirmado)
     {
         //### Cancelar Despacho N°1
         Despacho.CancelarDespacho(IdCarros);
     }
 }
Exemple #23
0
 public List <PedidoDeReforco> LerPedidosDeReforco(Despacho despacho)
 {
     using (Entidades contexto = new Entidades())
     {
         return(contexto.PedidoDeReforco
                .Where(p => p.id_despacho == despacho.id)
                .ToList());
     }
 }
Exemple #24
0
        private void Btn_modificar_Click(object sender, RoutedEventArgs e)
        {
            Despacho           fila = (Despacho)dtg_despacho.SelectedItem;
            int                id   = fila.ID_DESPACHO;
            Modificar_despacho md   = new Modificar_despacho(id);

            md.Show();
            this.Hide();
        }
Exemple #25
0
        public bool Ingresar(int id_user, List <Item> cart, Despacho d, Metodo_pago metodo, string Total_venta)
        {
            string fecha = DateTime.Now.ToString("MM-dd-yyyy/HH:mm:ss:fff");
            string hora  = DateTime.Now.ToString("MM-dd-yyyy");


            try
            {
                venta.id_user     = id_user;
                venta.Total_venta = Int32.Parse(Total_venta);
                venta.Fecha_venta = fecha;
                venta.Hora_venta  = hora;
                venta.Estado      = "INGRESADO";
                ctx.Ventas.Add(venta);
                ctx.SaveChanges();
                int id = (from o in ctx.Ventas
                          where o.Fecha_venta == fecha
                          select o.Id_ventas).SingleOrDefault();

                foreach (var item in cart)
                {
                    carro.Id_venta    = id;
                    carro.Id_producto = item.p.Id_producto;
                    carro.Precio_p    = item.p.Precio_producto;
                    carro.Cantidad    = item.Quantity;
                    ctx.Carrito.Add(carro);
                    ctx.SaveChanges();
                }
                metodo_pago.Id_ventas  = id;
                metodo_pago.Tipo_mpago = metodo.Tipo_mpago;
                ctx.Metodo_pago.Add(metodo_pago);
                ctx.SaveChanges();

                despacho.Id_ventas        = metodo_pago.Id_ventas;
                despacho.Num_seguimiento  = 0;
                despacho.Estado_despacho  = d.Estado_despacho;
                despacho.Fecha_envio      = d.Fecha_envio;
                despacho.Fecha_entrega    = d.Fecha_entrega;
                despacho.Calle            = d.Calle;
                despacho.Numero           = d.Numero;
                despacho.Comuna           = d.Comuna;
                despacho.Ciudad           = d.Ciudad;
                despacho.Cod_postal       = d.Cod_postal;
                despacho.Num_departamento = d.Num_departamento;
                ctx.Despacho.Add(despacho);
                ctx.SaveChanges();


                return(true);
            }
            catch (Exception ex)
            {
                log.Error("Ingresar-VentasDAL " + ex.Message);
                return(false);
            }
        }
        public CommandContracts.Common.CommandResult Handle(TransbordarVehiculoCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("Tiene que seleccionar un vehículo");
            }


            //Actualiza la operacion carga con el nuevo vehiculo
            List <OperacionCarga> operacioncarga = null;

            operacioncarga = _OperacionCargaRepository.Get(x => x.idvehiculo == command.idvehiculo_old &&
                                                           x.idestado == 15).ToList();

            foreach (var item in operacioncarga)
            {
                item.idvehiculo = command.idvehiculo_new;
            }

            //Actualiza el despacho carga con el nuevo vehiculo
            Despacho despacho = null;

            despacho = _DespachoRepository.Get(x => x.idvehiculo.Equals(command.idvehiculo_old) &&
                                               x.idestado == 16).LastOrDefault();
            if (despacho != null)
            {
                despacho.idvehiculo = command.idvehiculo_new;
            }



            //Actualiza el vehiculo a su estado creado
            Vehiculo vehiculo = null;

            vehiculo          = _VehiculoRepository.Get(x => x.idvehiculo.Equals(command.idvehiculo_old)).LastOrDefault();
            vehiculo.idestado = 1;


            try
            {
                _OperacionCargaRepository.SaveChanges();
                _DespachoRepository.SaveChanges();
                _VehiculoRepository.SaveChanges();

                return(new TransbordarVehiculoOutput()
                {
                    idvehiculo = command.idvehiculo_new
                });
            }
            catch (Exception ex)
            {
                //  _ValortablaRepository.Delete(dominio);
                //_ValortablaRepository.Commit();
                throw;
            }
        }
 public ActionResult Eliminar(int Id)
 {
     using (var db = new AlmacenContext())
     {
         Despacho Pro = db.Despacho.Find(Id);
         db.Despacho.Remove(Pro);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Exemple #28
0
 public ActionResult CreaDespacho([Bind(Include = "CodDespacho,CodCircuito,NombreDespacho,CantTecJud,CantTecJur,CantCoordJud,CantJuezCoord,CantJuezTram,CantJueces,CantOtros")] Despacho despacho)
 {
     if (ModelState.IsValid)
     {
         DespachoData.CreaDespacho(despacho);
         return(RedirectToAction("DespachoIndex"));
     }
     ViewBag.CodCircuito = DespachoData.ExtraeNombreCircuito();
     return(View(despacho));
 }
Exemple #29
0
 public ActionResult EditarDespacho(Despacho despacho)
 {
     if (ModelState.IsValid)
     {
         DespachoData.ModificaDespacho(despacho);
     }
     ViewBag.CodCircuito   = DespachoData.ExtraeNombreCircuito();
     ViewBag.ListaDespacho = DespachoData.ListDespacho();
     return(View("DespachoIndex"));
 }
Exemple #30
0
 public ActionResult Eliminar(int id)
 {
     using (var db = new GestionDeAlmacenContext())
     {
         Despacho cl = db.Despacho.Find(id);
         db.Despacho.Remove(cl);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }