Пример #1
0
        protected void btnCosto_Click(object sender, EventArgs e)
        {
            Excurcion        ex             = null;
            Cliente          cliente        = null;
            IList <Pasajero> listaPasajeros = new List <Pasajero>();
            string           id             = txtCodigo.Text;
            byte             tope           = 0;

            foreach (GridViewRow row in this.grExcurciones.Rows)
            {
                CheckBox unChk = (CheckBox)row.FindControl("chkExcurcion");
                if (unChk.Checked && tope < 1)
                {
                    ex = FachadaAgencia.Instancia.RepoExcurciones.FindById(row.Cells[0].Text);
                    if (ex != null)
                    {
                        tope++;
                        foreach (GridViewRow row2 in this.grPasajeros.Rows)
                        {
                            CheckBox unChk2 = (CheckBox)row2.FindControl("chkPasajeros");
                            if (unChk2.Checked)
                            {
                                if (FachadaAgencia.Instancia.RepoPasajeros.FindById(row2.Cells[2].Text) != null)
                                {
                                    listaPasajeros.Add(FachadaAgencia.Instancia.RepoPasajeros.FindById(row2.Cells[2].Text));
                                }
                            }
                        }
                    }
                }
            }
            tope            = 0;
            lblMensaje.Text = FachadaAgencia.Instancia.CalcularCosto(ex, listaPasajeros).ToString();
        }
Пример #2
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            Excurcion        ex             = null;
            Cliente          cliente        = null;
            IList <Pasajero> listaPasajeros = new List <Pasajero>();
            string           id             = txtCodigo.Text;
            byte             tope           = 0;

            foreach (GridViewRow row in this.grExcurciones.Rows)
            {
                CheckBox unChk = (CheckBox)row.FindControl("chkExcurcion");
                if (unChk.Checked && tope < 1)
                {
                    ex = FachadaAgencia.Instancia.RepoExcurciones.FindById(row.Cells[0].Text);
                    if (ex != null)
                    {
                        tope++;
                        foreach (GridViewRow row2 in this.grPasajeros.Rows)
                        {
                            CheckBox unChk2 = (CheckBox)row2.FindControl("chkPasajeros");
                            if (unChk2.Checked)
                            {
                                if (FachadaAgencia.Instancia.RepoPasajeros.FindById(row2.Cells[2].Text) != null)
                                {
                                    listaPasajeros.Add(FachadaAgencia.Instancia.RepoPasajeros.FindById(row2.Cells[2].Text));
                                }
                            }
                        }
                        //ex.AgregarPasajeros(listaPasajeros);
                    }
                }
            }
            tope = 0;
            foreach (GridViewRow row in this.grClientes.Rows)
            {
                CheckBox unChk = (CheckBox)row.FindControl("chkCliente");
                if (unChk.Checked && tope < 1)
                {
                    cliente = FachadaAgencia.Instancia.RepoClientes.FindById(row.Cells[2].Text);
                    if (cliente != null)
                    {
                        tope++;
                    }
                }
            }
            if (FachadaAgencia.Instancia.AgregarContrato(ex, cliente, listaPasajeros, System.DateTime.Today, id))
            {
                lblMensaje.Text = "EXITO";
            }
            else
            {
                lblMensaje.Text = "ERROR";
            }
        }
        public bool AgregarContrato(Excurcion ex, Cliente cliente, IList <Pasajero> listaPasajeros, DateTime fechaContrato, string id)
        {
            bool     retorno = false;
            Contrato unC     = new Contrato(ex, cliente, listaPasajeros, fechaContrato, id);

            if (this.RepoContratos.Add(unC))
            {
                retorno = true;
                FachadaAgencia.Instancia.SerializarTodo();
                FachadaAgencia.Instancia.GuardarParametros(":");
            }
            return(retorno);
        }
Пример #4
0
        public bool Add(Contrato entity)
        {
            bool retorno = false;

            if (entity != null && !(this.ListaContratos.Contains(entity)) && entity.Validar())
            {
                Excurcion unaE = entity.Excurcion;
                if (unaE.Stock >= entity.ListaPasajeros.Count)
                {
                    if (!unaE.BuscarPasajeros(entity.ListaPasajeros))
                    {
                        this.ListaContratos.Add(entity);
                        unaE.AgregarPasajeros(entity.ListaPasajeros);
                        unaE.Stock -= (Byte)entity.ListaPasajeros.Count;
                        retorno     = true;
                    }
                }
            }

            return(retorno);
        }
 public decimal CalcularCosto(Excurcion ex, IList <Pasajero> pasajeros)
 {
     return(ex.CostoExcurcion() * pasajeros.Count);
 }