private void btnModificar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ServiciosNEG serviciosNEG    = new ServiciosNEG();
         int          tipo_servicio   = int.Parse(cbxTipoServicio.SelectedValue.ToString());
         int          estado_servicio = int.Parse(cbxEstadoServicio.SelectedValue.ToString());
         int          sucursal        = int.Parse(cbxSucursal.SelectedValue.ToString());
         int          _id             = 0;
         string       a = lbl_IdServicio.Content.ToString();
         int.TryParse(a, out _id);
         int    costo     = int.Parse(txtCostoBase.ToString());
         string respuesta = serviciosNEG.ActualizarServicio(tipo_servicio, estado_servicio, sucursal, _id, costo);
         if (respuesta == "actualizado")
         {
             LimpiarFormulario();
             MessageBox.Show("El servicio ha sido actualizado satisfactoriamente");
         }
         else
         {
             MessageBox.Show(respuesta);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
     }
 }
        public void CargarTablaServicios()
        {
            dgServicios.ItemsSource = null;
            DataTable    dt           = new DataTable();
            ServiciosNEG serviciosNEG = new ServiciosNEG();

            try
            {
                List <ServiciosVIEW> lista = serviciosNEG.ListarTodosServicios();
                dt.Columns.Add("ID");
                dt.Columns.Add("TIPO_SERVICIO");
                dt.Columns.Add("ESTADO_SERVICIO");
                dt.Columns.Add("SUCURSAL");
                dt.Columns.Add("COSTO");
                if (lista.Count > 0)
                {
                    foreach (var x in lista)
                    {
                        dt.Rows.Add(x.ID, x.TIPO_SERVICIO, x.ESTADO_SERVICIO, x.SUCURSAL, x.COSTO);
                    }
                }
                dgServicios.ItemsSource = dt.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
            }
        }
        private void btnBuscar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string tipo  = cbxTipoBusqueda.Text;
                string valor = txtBusqueda.Text.ToUpper();

                dgServicios.ItemsSource = null;
                DataTable            dt           = new DataTable();
                ServiciosNEG         serviciosNEG = new ServiciosNEG();
                List <ServiciosVIEW> lista        = serviciosNEG.FiltrarServicios(tipo, valor);
                dt.Columns.Add("ID");
                dt.Columns.Add("TIPO_SERVICIO");
                dt.Columns.Add("ESTADO_SERVICIO");
                dt.Columns.Add("SUCURSAL");
                dt.Columns.Add("COSTO");
                if (lista.Count > 0)
                {
                    foreach (var x in lista)
                    {
                        dt.Rows.Add(x.ID, x.TIPO_SERVICIO, x.ESTADO_SERVICIO, x.SUCURSAL, x.COSTO);
                    }
                }
                else
                {
                    MessageBox.Show("No existen servicios registrados para los filtros indicados");
                }
                dgServicios.ItemsSource = dt.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
            }
        }
 private void btnCrear_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ServiciosNEG serviciosNEG    = new ServiciosNEG();
         int          tipo_servicio   = int.Parse(cbxTipoServicio.SelectedValue.ToString());
         int          estado_servicio = int.Parse(cbxEstadoServicio.SelectedValue.ToString());
         int          sucursal        = int.Parse(cbxSucursal.SelectedValue.ToString());
         int          costo           = int.Parse(txtCostoBase.ToString());
         string       respuesta       = serviciosNEG.CrearServicio(tipo_servicio, estado_servicio, sucursal, costo);
         if (respuesta == "creado")
         {
             LimpiarFormulario();
             MessageBox.Show("El servicio ha sido ingresado satisfactoriamente a la base de datos");
         }
         else
         {
             MessageBox.Show(respuesta);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
     }
 }
 private void btnAgregarServicio_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (cbxSerivioc.SelectedValue != null)
         {
             int          _idServicio  = int.Parse(cbxSerivioc.SelectedValue.ToString());
             ServiciosNEG serviciosNEG = new ServiciosNEG();
             var          datos        = serviciosNEG.CargarServicio(_idServicio);
             string       _cantidad    = "1";
             string       _tipoItem    = "SER";
             string       _idItem      = cbxSerivioc.SelectedValue.ToString();
             string       _nombreItem  = datos.TIPO_SERVICIO;
             string       _precioUni   = datos.COSTO.ToString();
             string       _total       = _precioUni;
             emitirBoleta_AD.AgregarItemDetalle(_cantidad, _tipoItem, _idItem, _nombreItem, _precioUni, _total);
             this.Close();
         }
         else
         {
             MessageBox.Show("Debe seleccionar un servicio");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void dgServicios_MouseDoubleClick(object sender, EventArgs e)
        {
            DataRowView  dr           = dgServicios.SelectedItem as DataRowView;
            DataRow      dr1          = dr.Row;
            int          idServicio   = Convert.ToInt32(dr1.ItemArray[0]);
            ServiciosNEG serviciosNEG = new ServiciosNEG();
            var          datos        = serviciosNEG.CargarServicio(idServicio);

            cbxTipoServicio.SelectedValue   = datos.Tipo_Servicio_Id;
            cbxEstadoServicio.SelectedValue = datos.Estado_Servicio_Id;
            cbxSucursal.SelectedValue       = datos.Sucursal_Id;
            txtCostoBase.Text      = datos.COSTO.ToString();
            lbl_IdServicio.Content = idServicio;
        }
Пример #7
0
 private void cbxSerivioc_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cbxSerivioc.SelectedValue != null)
     {
         try
         {
             int          idServicio   = int.Parse(cbxSerivioc.SelectedValue.ToString());
             ServiciosNEG serviciosNEG = new ServiciosNEG();
             int          valor        = int.Parse(serviciosNEG.CargarServicio(idServicio).COSTO.ToString());
             txtValor.Text = valor.ToString();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
         }
     }
 }
Пример #8
0
 private void btnAgregarServicio_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (cbxSerivioc.SelectedValue != null)
         {
             int          _idServicio  = int.Parse(cbxSerivioc.SelectedValue.ToString());
             ServiciosNEG serviciosNEG = new ServiciosNEG();
             var          datos        = serviciosNEG.CargarServicio(_idServicio);
             ingresarRequerimientos_AD.AgregarItemTablaServicios(_idServicio, datos.TIPO_SERVICIO, datos.COSTO);
             Limpiar();
         }
         else
         {
             MessageBox.Show("Debe seleccionar un servicio");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #9
0
        private void CargarCombos()
        {
            ServiciosNEG serviciosNEG = new ServiciosNEG();
            SucursalNEG  sucursalNEG  = new SucursalNEG();

            try
            {
                txtNombreSucursal.Text = sucursalNEG.CargarSucursal(sucursal).NOMBRE;

                List <ServiciosVIEW> listaServicio = serviciosNEG.FiltrarServicios("ID SUCURSAL", sucursal.ToString());
                if (listaServicio.Count > 0)
                {
                    cbxSerivioc.ItemsSource       = listaServicio;
                    cbxSerivioc.DisplayMemberPath = "TIPO_SERVICIO";
                    cbxSerivioc.SelectedValuePath = "ID";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
            }
        }