public List <Servicios_dto> ListarServicios()
        {
            OracleComand exec = new OracleComand();

            List <Servicios_dto> retorno = new List <Servicios_dto>();

            try
            {
                var       Parameters = new Dictionary <string, string>();
                DataTable dataTable  = new DataTable();
                exec.ExecStoredProcedure("SP_DDL_LISTAR_SERVICIO", dataTable, Parameters);
                foreach (DataRow rows in dataTable.Rows)
                {
                    Servicios_dto entidad = new Servicios_dto();
                    entidad.ID          = int.Parse(rows["id_servicio"].ToString());
                    entidad.Descripción = rows["desc_servicio"].ToString();
                    retorno.Add(entidad);
                    entidad = null;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(retorno);
        }
Exemplo n.º 2
0
        private void Btn_Eliminar_Servi_Click(object sender, RoutedEventArgs e)
        {
            List <Servicios_dto> list_serv = new List <Servicios_dto>();

            if (cmb_servicio_Vta.Text == "")
            {
                MessageBox.Show("Debe seleccionar un servicio");
                limpiar();
            }
            else
            {
                bool    eliminado     = false;
                string  id_prod       = cmb_servicio_Vta.SelectedValue.ToString();
                int     cantidad_prod = int.Parse(txt_Cant_servicios.Text);
                decimal total         = 0;
                decimal subT          = 0;
                decimal IVA           = 0;

                // Aqui trae lo previamente guardado en la grilla, si la variable se session esta nula no entra
                if (Application.Current.Properties["ListadoVenta"] != null)
                {
                    // trae lo que esta en la variable de sesion
                    var jsonValueToGet = JsonConvert.DeserializeObject(Application.Current.Properties["ListadoVenta"].ToString());

                    // lo convierte en un array
                    JArray jsonPreservar = JArray.Parse(jsonValueToGet.ToString());

                    //lo recorre para añadir al listado que luego se mostrará en la grilla
                    foreach (JObject item in jsonPreservar.Children <JObject>())
                    {
                        Servicios_dto entidad = new Servicios_dto();
                        entidad.ID          = int.Parse(item["ID"].ToString());
                        entidad.Descripción = item["Descripción"].ToString();
                        entidad.Cantidad    = int.Parse(item["Cantidad"].ToString());
                        entidad.Total       = decimal.Parse(item["Total"].ToString()).ToString("n2");
                        entidad.Precio      = decimal.Parse(item["Precio"].ToString()).ToString("n2");
                        entidad.T           = item["T"].ToString();

                        if (cmb_Documento_Vta.Text == "Factura")
                        {
                            subT  = ((total + decimal.Parse(entidad.Total)) * 81) / 100;
                            IVA   = ((total + decimal.Parse(entidad.Total)) * 19) / 100;
                            total = total + decimal.Parse(entidad.Total);
                        }
                        else
                        {
                            subT  = ((total + decimal.Parse(entidad.Total)) * 81) / 100;
                            IVA   = ((total + decimal.Parse(entidad.Total)) * 19) / 100;
                            total = total + decimal.Parse(entidad.Total);
                        }

                        if (id_prod == item["ID"].ToString() && item["T"].ToString() == "S")
                        {
                            eliminado = true;
                            total     = total - decimal.Parse(entidad.Total);
                        }
                        else
                        {
                            list_serv.Add(entidad);
                        }
                    }
                    var jsonValueToSave = JsonConvert.SerializeObject(list_serv);
                    Application.Current.Properties["ListadoVenta"] = jsonValueToSave;

                    txt_Sub.Text   = subT.ToString("n2");
                    txt_iva.Text   = IVA.ToString("n2");
                    txt_total.Text = total.ToString("n2");

                    if (eliminado == true)
                    {
                        MessageBox.Show("Servicio eliminado");
                    }
                    else
                    {
                        MessageBox.Show("El Servicio no existe!");
                    }


                    Dt_G_list_pedido.ItemsSource = list_serv;
                }
                limpiar();
            }
        }
Exemplo n.º 3
0
        /// ///////////////////////////////////////
        /// //////////SERVICIOS////////////////////
        /// ///////////////////////////////////////

        private void Btn_Agregar_serv_Click(object sender, RoutedEventArgs e)
        {
            decimal              total     = 0;
            Servicio_Negocio     Serv_Neg  = new Servicio_Negocio();
            List <Servicios_dto> list_serv = new List <Servicios_dto>();

            if (cmb_Documento_Vta.Text == "")
            {
                MessageBox.Show("Favor de seleccionar tipo de documento");
                limpiar();
            }
            else
            {
                if (cmb_servicio_Vta.Text == "")
                {
                    MessageBox.Show("Debe seleccionar un servicio");
                }
                else
                {
                    bool    existe        = false;
                    string  id_serv       = cmb_servicio_Vta.SelectedValue.ToString();
                    int     cantidad_serv = int.Parse(txt_Cant_servicios.Text);
                    string  txt_tipo      = "S";
                    decimal subT          = 0;
                    decimal IVA           = 0;

                    // Aqui trae lo previamente guardado en la grilla, si la variable se session esta nula no entra
                    if (Application.Current.Properties["ListadoVenta"] != null)
                    {
                        // trae lo que esta en la variable de sesion
                        var jsonValueToGet = JsonConvert.DeserializeObject(Application.Current.Properties["ListadoVenta"].ToString());

                        // lo convierte en un array
                        JArray jsonPreservar = JArray.Parse(jsonValueToGet.ToString());

                        //lo recorre para añadir al listado que luego se mostrará en la grilla
                        foreach (JObject item in jsonPreservar.Children <JObject>())
                        {
                            // estos datos vienen de la grilla, creamosla entidad para añadir al listado
                            Servicios_dto entidad = new Servicios_dto();

                            entidad.ID          = int.Parse(item["ID"].ToString());
                            entidad.Descripción = item["Descripción"].ToString();
                            entidad.Cantidad    = int.Parse(item["Cantidad"].ToString());
                            entidad.Total       = decimal.Parse(item["Total"].ToString()).ToString("n2");
                            entidad.Precio      = decimal.Parse(item["Precio"].ToString()).ToString("n2");
                            entidad.T           = item["T"].ToString();


                            if (cmb_Documento_Vta.Text == "Factura")
                            {
                                subT  = ((total + decimal.Parse(entidad.Total)) * 81) / 100;
                                IVA   = ((total + decimal.Parse(entidad.Total)) * 19) / 100;
                                total = total + decimal.Parse(entidad.Total);
                            }
                            else
                            {
                                subT  = ((total + decimal.Parse(entidad.Total)) * 81) / 100;
                                IVA   = ((total + decimal.Parse(entidad.Total)) * 19) / 100;
                                total = total + decimal.Parse(entidad.Total);
                            }

                            list_serv.Add(entidad);
                            if (id_serv == item["ID"].ToString() && item["T"].ToString() == "S")
                            {
                                existe = true;
                            }
                        }
                    }

                    if (existe)
                    {
                        MessageBox.Show(" El Servicio : " + cmb_servicio_Vta.Text + " ya existe en el listado");
                    }
                    else
                    {
                        DataTable respuesta = Serv_Neg.Buscar_SERV_id(id_serv);
                        foreach (DataRow item in respuesta.Rows)
                        {
                            Servicios_dto entidad = new Servicios_dto();


                            entidad.ID          = int.Parse(item["ID_SERVICIO"].ToString());
                            entidad.Descripción = item["DESC_SERVICIO"].ToString();
                            entidad.Cantidad    = cantidad_serv;
                            entidad.Precio      = decimal.Parse(item["VALOR_SERVICIO"].ToString()).ToString("n2");
                            entidad.Total       = (decimal.Parse(item["VALOR_SERVICIO"].ToString()) * cantidad_serv).ToString("n2");
                            entidad.T           = txt_tipo;


                            if (cmb_Documento_Vta.Text == "Factura")
                            {
                                subT  = ((total + decimal.Parse(entidad.Total)) * 81) / 100;
                                IVA   = ((total + decimal.Parse(entidad.Total)) * 19) / 100;
                                total = total + decimal.Parse(entidad.Total);
                            }
                            else
                            {
                                subT  = ((total + decimal.Parse(entidad.Total)) * 81) / 100;
                                IVA   = ((total + decimal.Parse(entidad.Total)) * 19) / 100;
                                total = total + decimal.Parse(entidad.Total);
                            }
                            list_serv.Add(entidad);
                        }
                    }

                    // actualiza variable de sesion con los datos actuales de la grilla
                    var jsonValueToSave = JsonConvert.SerializeObject(list_serv);
                    Application.Current.Properties["ListadoVenta"] = jsonValueToSave;


                    txt_Sub.Text   = subT.ToString("n2");
                    txt_iva.Text   = IVA.ToString("n2");
                    txt_total.Text = total.ToString("n2");
                    Dt_G_list_pedido.ItemsSource = list_serv;
                }

                limpiar();
            }
        }