protected void btn_buscar_Click(object sender, EventArgs e)
        {
            try
            {
                //Entidad.Cat_Servicio cs = new Entidad.Cat_Servicio();
                //cs.IdServicio = Convert.ToInt32(tb_id.Text);
                Negocio.serviciosNegocio sn = new Negocio.serviciosNegocio();
                Entidad.Cat_Servicio cs = sn.BuscarServicio(int.Parse(tb_id.Text));
                if (cs != null)
                {
                    tb_descripcion.Text = cs.Descripcion;
                    tb_precio.Text = Convert.ToString(cs.Precio);
                    Session["s_Servicio"] = cs;
                    Response.Redirect("Servicios.aspx",false);
                    //Session["id_servicio"] = tb_id.Text;
                    //Session["descripcion_servicio"] = tb_descripcion.Text;
                    //Session["precio_servicio"] = tb_precio.Text;
                    /*Response.Redirect("Servicios.aspx");
                    Response.End();*/
                }
                else
                {
                    tb_descripcion.Text = "";
                    tb_precio.Text = "";
                    cv_validacion.IsValid = false;
                    cv_validacion.ErrorMessage = "No existe registro con ese id!!!";
                    tb_id.Focus();
                    //Response.Write("<script>window.alert('No existe registro con ese ID!!!');</script>");
                }

            }
            catch (Exception err)
            {

                //throw new Exception(err.Message);
                cv_validacion.IsValid = false;
                cv_validacion.ErrorMessage = err.Message;
            }
        }
Example #2
0
 protected void CargarControles(int idservicio)
 {
     try
     {
         Negocio.serviciosNegocio sv = new Negocio.serviciosNegocio();
         Entidad.Cat_Servicio serv = sv.BuscarServicio(idservicio);
         if (serv != null)
         {
             tb_id.Text = serv.IdServicio.ToString();
             tb_descripcion.Text = serv.Descripcion;
             tb_precio.Text = serv.Precio.ToString();
             btn_guardar.Text = "Modificar";
         }
     }
     catch (Exception err)
     {
         cv_wfServicios.IsValid = false;
         cv_wfServicios.ErrorMessage = err.Message;
     }
 }
 protected void Seleccion_Servicio(int id)
 {
     Negocio.serviciosNegocio sn = new Negocio.serviciosNegocio();
     Entidad.Cat_Servicio cs = sn.BuscarServicio(id);
     if (cs != null)
     {
         tb_id.Text = Convert.ToString(cs.IdServicio);
         tb_descripcion.Text = cs.Descripcion;
         tb_precio.Text = Convert.ToString(cs.Precio);
         Session["s_Servicio"] = cs;
         Response.Redirect("Servicios.aspx", false);
     }
 }
Example #4
0
        protected void btn_agregar_Click(object sender, EventArgs e)
        {
            try
            {
                List<DetalleFactura> detallef = new List<DetalleFactura>();
                if (Session["S_DetalleFac"] != null)
                    detallef = (List<DetalleFactura>)Session["S_DetalleFac"];
                if (!ExisteServicio(int.Parse(ddl_motivo.SelectedValue), detallef))
                {
                    DetalleFactura df = new DetalleFactura();
                    //int idservicio = int.Parse(ddl_motivo.SelectedValue);
                    df.id = int.Parse(ddl_motivo.SelectedValue);
                    df.descripcion = ddl_motivo.SelectedItem.Text;
                    Negocio.serviciosNegocio dc = new Negocio.serviciosNegocio();
                    df.precio = (int)dc.BuscarServicio(df.id).Precio;
                    df.cantidad = int.Parse(tb_cantidad.Text);
                    df.importe = df.precio * df.cantidad;
                    //Calculando el total de la factura ------------------
                    /*decimal Total = 0;
                    if (lb_Total.Text != "")
                        Total = decimal.Parse(lb_Total.Text) + df.importe;
                    else
                        Total = df.importe;
                    lb_Total.Text = Total.ToString();
                    lb_TotalFac.Text = Total.ToString("C");
                    //--- Termina el calculo ----------------------------*/
                    Label1.Visible = true;
                    lb_total.Visible = true;
                    lb_moneda.Visible = true;
                    //lb_moneda.Text = "C$";
                    //Calculando el total de la factura ------------------
                    int totalfact = 0;
                    if (lb_total.Text != "")
                        totalfact = int.Parse(lb_total.Text) + df.importe;
                    else
                        totalfact = df.importe;
                    lb_total.Text = totalfact.ToString();
                    lb_moneda.Text = totalfact.ToString("C");
                    //--- Termina el calculo ----------------------------*/
                    detallef.Add(df);
                    /*int totalfact = 0;
                    lb_total.Text = detallef.Sum(dep => dep.precio).ToString();
                    totalfact = int.Parse(lb_total.Text);
                    lb_moneda.Text = totalfact.ToString("C");*/
                    /*Label2.Text = (from x in detallef select x.importe).Sum().ToString("C"); //----*/
                    Session.Add("S_DetalleFac", detallef);
                    gv_detalle.DataSource = detallef;
                    gv_detalle.DataBind();
                    btn_facturar.Enabled = true;
                    btn_cancelar.Enabled = true;
                    ddl_paciente.Enabled = false;
                    ddl_motivo.SelectedIndex = 0;
                    tb_cantidad.Text = "";
                }
                else
                {
                    cv_informacion.IsValid = false;
                    cv_informacion.ErrorMessage = "El servicio ya esta incluido en la lista!!!";
                }

            }
            catch (Exception err)
            {
                //MANEJAMOS EL ERROR
                cv_informacion.IsValid = false;
                cv_informacion.ErrorMessage = "Error al agregar el servicio al detalle, " + err.Message;
            }
        }