Exemplo n.º 1
0
    protected void btnConfirmar_Click(object sender, EventArgs e)
    {
        try
        {
            Int64   ruc;
            int     codigo, precio, cantidad;
            Usuario oUsu;

            oUsu = (Usuario)Session["Cliente"];

            Cliente oCli = LogicaUsuario.BuscarCliente(oUsu.nomUsu);

            ruc      = Convert.ToInt64(gvMedicamentos.SelectedRow.Cells[1].Text.Trim());
            codigo   = Convert.ToInt32(gvMedicamentos.SelectedRow.Cells[2].Text.Trim());
            precio   = Convert.ToInt32(gvMedicamentos.SelectedRow.Cells[5].Text.Trim());
            cantidad = Convert.ToInt32(txtCantidad.Text.Trim());

            Medicamento oMed = LogicaMedicamento.Buscar(ruc, codigo);

            Pedido oPed = new Pedido(0, cantidad, 0, oCli, oMed);

            LogicaPedido.Alta(oPed);
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    protected void btnAlta_Click(object sender, EventArgs e)
    {
        try
        {
            Int64 oRUC = Convert.ToInt64(txtRucMedicamento.Text.Trim());

            Farmaceutica oFar         = LogicaFarmaceutica.Buscar(oRUC);
            int          oCodigo      = Convert.ToInt32(txtCodMedicamento.Text.Trim());
            string       oNombre      = txtNombreMed.Text.Trim();
            string       oDescripcion = txtDescripcion.Text.Trim();
            int          oPrecio      = Convert.ToInt32(txtPrecio.Text.Trim());

            Medicamento oMed = new Medicamento(oFar, oCodigo, oNombre, oDescripcion, oPrecio);

            btnAlta.Enabled   = false;
            btnBuscar.Enabled = false;

            LogicaMedicamento.Alta(oMed);

            lblError.Text = "Alta exitosa";
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 3
0
    protected void gvMedicamentos_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow R = gvMedicamentos.SelectedRow;

        R.BackColor = System.Drawing.Color.Aqua;

        try
        {
            Int64 oRUC    = Convert.ToInt64(gvMedicamentos.SelectedRow.Cells[1].Text.Trim());
            int   oCodigo = Convert.ToInt32(gvMedicamentos.SelectedRow.Cells[2].Text.Trim());

            Medicamento oMed = LogicaMedicamento.Buscar(oRUC, oCodigo);

            gvSeleccion.DataSource = LogicaMedicamento.ListarMedicamentoUnico(oMed);
            gvSeleccion.DataBind();

            ActivarCalcularCosto();

            if (txtCantidad.Text != null)
            {
                btnConfirmar.Enabled = true;
            }
            else
            {
                btnConfirmar.Enabled = false;
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 4
0
    protected void ddlFarmaceutica_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            if (!string.IsNullOrEmpty(ddlFarmaceutica.SelectedItem.Value))
            {
                LogicaFarmaceutica logicaFarmaceutica = new LogicaFarmaceutica();
                Farmaceutica       farmaceutica       = logicaFarmaceutica.BuscarFarmaceutica(ddlFarmaceutica.SelectedItem.Value);

                LogicaMedicamento logicaMedicamento = new LogicaMedicamento();
                Session["ListaMedicamentos"] = logicaMedicamento.ListarMedicamentoPorFarmaceutica(farmaceutica);
                gvMedicamentos.DataSource    = (List <Medicamento>)Session["ListaMedicamentos"];
                gvMedicamentos.DataBind();

                //LIMPIAR GRIDVIEW PEDIDOS
                gvPedidos.DataSource = null;
                gvPedidos.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblERROR.ForeColor = System.Drawing.Color.Red;
            lblERROR.Text      = ex.Message;
        }
    }
Exemplo n.º 5
0
    protected void btnBuscar_Click(object sender, EventArgs e)
    {
        try
        {
            int intvalue;
            if (int.TryParse(txtCodigo.Text, out intvalue))
            {
                LogicaMedicamento logicaMedicamento = new LogicaMedicamento();
                Session["Medicamento"] = logicaMedicamento.BuscarMedicamento(Convert.ToInt32(txtCodigo.Text), ddlFarmaceuticas.SelectedItem.Value);

                if (Session["Medicamento"] == null)
                {
                    FormularioAlta();
                }
                else
                {
                    FormularioModificarCancelar();
                }
            }
            else
            {
                throw new Exception("Codigo debe ser un numero.");
            }
        }
        catch (Exception ex)
        {
            lblERROR.ForeColor = System.Drawing.Color.Red;
            lblERROR.Text      = ex.Message;
        }
    }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ddlFarmaceuticas.DataSource     = LogicaFarmaceutica.Listar();
                    ddlFarmaceuticas.DataTextField  = "Nombre";
                    ddlFarmaceuticas.DataValueField = "Ruc";
                    ddlFarmaceuticas.AutoPostBack   = true;
                    ddlFarmaceuticas.DataBind();

                    Farmaceutica       f     = LogicaFarmaceutica.Buscar(Convert.ToInt32(ddlFarmaceuticas.SelectedValue));
                    List <Medicamento> lista = LogicaMedicamento.Listar(f);
                    Session["listamed"]       = lista;
                    gvMedicamentos.DataSource = lista;
                    gvMedicamentos.DataBind();
                }

                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }
Exemplo n.º 7
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                Medicamento m = null;

                m = LogicaMedicamento.Buscar(Convert.ToInt32(txtCodigo.Text.Trim()), Convert.ToInt32(txtRuc.Text.Trim()));

                if (m != null)
                {
                    txtNombre.Text         = m.Nombre;
                    txtDescripcion.Text    = m.Descripcion;
                    txtRuc.Text            = m.Proveedor.Ruc.ToString();
                    txtPrecio.Text         = m.Precio.ToString();
                    Session["medicamento"] = m;
                }
                else
                {
                    lblError.Text = "No existe el medicamento";
                    this.ActivoBotonesAlta();
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
Exemplo n.º 8
0
    protected void btnLimpiar_Click(object sender, EventArgs e)
    {
        try
        {
            gvSeleccion.DataSource = null;
            gvSeleccion.DataBind();

            txtCantidad.Text   = "";
            lblCostoTotal.Text = "";
            lblError.Text      = "";

            txtCantidad.Enabled = false;

            btnCalcularCosto.Enabled = false;
            btnConfirmar.Enabled     = false;

            Session["ListaCompleta"] = LogicaMedicamento.Listar();
            Session["Seleccion"]     = new List <Medicamento>();

            gvMedicamentos.DataSource = (List <Medicamento>)Session["ListaCompleta"];
            gvMedicamentos.DataBind();
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 9
0
    protected void btnListar_Click(object sender, EventArgs e)
    {
        try
        {
            string Seleccion = ddlListadoMedicamento.SelectedValue;

            Farmaceutica oFar = LogicaFarmaceutica.BuscarXNombre(Seleccion);

            List <Medicamento> oLista = LogicaMedicamento.ListarMedicamentosXFarmaceutica(oFar);

            if (oLista != null)
            {
                gvListadoMedicamento.DataSource = oLista;
                gvListadoMedicamento.DataBind();
            }
            else
            {
                lblError.Text = oFar.nombre + " aun no tiene medicamentos asociados.";
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 10
0
 protected void ddlFarmaceuticas_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         Farmaceutica       f     = LogicaFarmaceutica.Buscar(Convert.ToInt32(ddlFarmaceuticas.SelectedValue));
         List <Medicamento> lista = LogicaMedicamento.Listar(f);
         Session["listamed"]       = lista;
         gvMedicamentos.DataSource = lista;
         gvMedicamentos.DataBind();
     }
     catch (Exception ex)
     {
         lblError.Text = ex.Message;
     }
 }
Exemplo n.º 11
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Medicamento m = null;
                m = (Medicamento)Session["medicamento"];

                LogicaMedicamento.Eliminar(m);
                this.Limpiar();
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
Exemplo n.º 12
0
    protected void btnTodos_Click(object sender, EventArgs e)
    {
        try
        {
            string Seleccion = ddlListadoMedicamento.SelectedValue;

            Farmaceutica oFar = LogicaFarmaceutica.BuscarXNombre(Seleccion);

            gvListadoMedicamento.DataSource = LogicaMedicamento.ListarMedicamentosXFarmaceutica(oFar);
            gvListadoMedicamento.DataBind();
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    protected void btnEliminar_Click(object sender, EventArgs e)
    {
        try
        {
            Medicamento oMed = (Medicamento)Session["MedicamentoABM"];

            LogicaMedicamento.Eliminar(oMed);

            this.LimpioFormulario();

            lblError.Text = "Eliminacion exitosa";
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 14
0
    protected void btnModificar_Click(object sender, EventArgs e)
    {
        try
        {
            LogicaFarmaceutica logicaFarmaceutica = new LogicaFarmaceutica();
            LogicaMedicamento  logicaMedicamento  = new LogicaMedicamento();

            Farmaceutica farmaceutica = logicaFarmaceutica.BuscarFarmaceutica(ddlFarmaceuticas.SelectedItem.Value);

            if (farmaceutica == null)
            {
                throw new Exception("La farmaceutica no existe.");
            }

            string descripcion = txtDescripcion.Text;
            double precio;
            string nombre = txtNombre.Text;
            int    codigo;

            //VARIFICAR INT
            try
            {
                codigo = Convert.ToInt32(txtCodigo.Text);
            }
            catch { throw new Exception("El codigo debe ser un numero."); }

            //VERIFICAR DOUBLE
            try
            {
                precio = double.Parse(txtPrecio.Text);
            }
            catch { throw new Exception("El precio debe ser un numero."); }

            Medicamento medicamento = new Medicamento(codigo, farmaceutica, nombre, descripcion, precio);

            logicaMedicamento.ModificarMedicamento(medicamento);

            lblERROR.ForeColor = System.Drawing.Color.Green;
            lblERROR.Text      = "Modificacion exitosa.";
        }
        catch (Exception ex)
        {
            lblERROR.ForeColor = System.Drawing.Color.Red;
            lblERROR.Text      = ex.Message;
        }
    }
Exemplo n.º 15
0
        protected void btnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                Medicamento m = (Medicamento)Session["medicamento"];

                m.Nombre      = txtNombre.Text.Trim();
                m.Descripcion = txtDescripcion.Text;
                m.Precio      = Convert.ToDouble(txtPrecio.Text);

                LogicaMedicamento.Modificar(m);
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
    protected void gvEstadoPedido_SelectedIndexChanged(object sender, EventArgs e)
    {
        int    numero         = Convert.ToInt32(gvEstadoPedido.SelectedRow.Cells[1].Text.Trim());
        string nomUsu         = gvEstadoPedido.SelectedRow.Cells[2].Text.Trim();
        Int64  rucMedicamento = Convert.ToInt64(gvEstadoPedido.SelectedRow.Cells[3].Text.Trim());
        int    codMedicamento = Convert.ToInt32(gvEstadoPedido.SelectedRow.Cells[4].Text.Trim());
        int    cantidad       = Convert.ToInt32(gvEstadoPedido.SelectedRow.Cells[5].Text.Trim());
        int    estado         = Convert.ToInt32(gvEstadoPedido.SelectedRow.Cells[6].Text.Trim());

        Cliente     oCli = LogicaUsuario.BuscarCliente(nomUsu);
        Medicamento oMed = LogicaMedicamento.Buscar(rucMedicamento, codMedicamento);

        Pedido oPed = new Pedido(numero, cantidad, estado, oCli, oMed);

        lblError.Text = oPed.ToString();

        btnCambiarEstado.Enabled = true;
    }
Exemplo n.º 17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         List <Medicamento> lista = new List <Medicamento>();
         try
         {
             lista = LogicaMedicamento.Listar();
             Session["listamedicamentos"] = lista;
             gvMedicamentos.DataSource    = lista;
             gvMedicamentos.SelectedRowStyle.BackColor = Color.LightSeaGreen;
             gvMedicamentos.DataBind();
         }
         catch (Exception ex)
         {
             lblError.Text = ex.Message;
         }
     }
 }
Exemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                Session["ListaCompleta"] = LogicaMedicamento.Listar();
                Session["Seleccion"]     = new List <Medicamento>();

                gvMedicamentos.DataSource = (List <Medicamento>)Session["ListaCompleta"];
                gvMedicamentos.DataBind();
                gvSeleccion.DataSource = (List <Medicamento>)Session["Seleccion"];
                gvMedicamentos.DataBind();

                txtCantidad.Enabled = false;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
    }
Exemplo n.º 19
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                int          Codigo      = Convert.ToInt32(txtCodigo.Text);
                Farmaceutica Proveedor   = LogicaFarmaceutica.Buscar(Convert.ToInt32(txtRuc.Text));
                string       Nombre      = txtNombre.Text.Trim();
                string       Descripcion = txtDescripcion.Text;
                double       Precio      = Convert.ToDouble(txtPrecio.Text);

                Medicamento m = new Medicamento(Codigo, Proveedor, Nombre, Descripcion, Precio);

                if (m != null)
                {
                    this.ActivoBotonesBM();
                    LogicaMedicamento.Agregar(m);
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
Exemplo n.º 20
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                Medicamento m = null;

                if (txtCodigo.Text.Trim() != "" && txtRuc.Text.Trim() != "")
                {
                    m = LogicaMedicamento.Buscar(Convert.ToInt32(txtCodigo.Text.Trim()), Convert.ToInt32(txtRuc.Text.Trim()));

                    if (m != null)
                    {
                        txtNombre.Text         = m.Nombre;
                        txtDescripcion.Text    = m.Descripcion;
                        txtRuc.Text            = m.Proveedor.Ruc.ToString();
                        txtPrecio.Text         = m.Precio.ToString();
                        Session["medicamento"] = m;
                        this.ActivoBotonesBM();
                    }
                    else
                    {
                        lblError.Text = "No existe el medicamento";
                        this.Limpiar();
                        this.ActivoBotonesAlta();
                    }
                }
                else
                {
                    lblError.Text = "El campo Codigo y Ruc no pueden estar vacios";
                }
            }
            catch (Exception ex)
            {
                lblError.Text = "Error! el codigo y ruc son invalidos";
            }
        }
Exemplo n.º 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //PASE DE SEGURIDAD
            if ((Usuario)Session["USUARIO"] is Empleado)
            {
                Response.Redirect("HomePage.aspx");
            }

            if (!Page.IsPostBack)
            {
                LogicaMedicamento logicaMedicamento = new LogicaMedicamento();
                Session["listaMedicamentos"] = logicaMedicamento.ListarMedicamento();
                gvMedicamentos.DataSource    = (List <Medicamento>)Session["listaMedicamentos"];
                gvMedicamentos.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblERROR.ForeColor = System.Drawing.Color.Red;
            lblERROR.Text      = ex.Message;
        }
    }