private bool RevisarFechas(ServicioModel i) { bool result = true; foreach (var s in Items) { result = i.fechaDesde > s.Servicio.fechaHasta ? true : false; } return(result); }
/// <summary> /// Crea una nueva instancia de ModifyServicio y se pasa asi mismo como parámetro y el item seleccionado /// </summary> /// <returns></returns> public ModifyServicioViewModel CreateModifyServicioViewModel() { ServicioModel servicioModel = new ServicioModel(new ServicioDataMapper(), this.ActualUser); if (this._catalogServicioModel != null && this._catalogServicioModel.SelectedServicio != null) { servicioModel.ServicioName = this._catalogServicioModel.SelectedServicio.SERVICIO_NAME; servicioModel.UnidServicio = this._catalogServicioModel.SelectedServicio.UNID_SERVICIO; } return(new ModifyServicioViewModel(this, servicioModel)); }
private void BtnAgregar_Click(object sender, RoutedEventArgs e) { ServicioModel item = (ServicioModel)comboxServicioR.SelectedItem; ClienteModel cliente = (ClienteModel)comboxClienteR.SelectedItem; if (item != null && cliente != null) { if (RevisarFechas(item)) { int qty = (int)qtyPicker.Value; decimal subtotal = item.Precio * qty; decimal itbis = subtotal * (decimal)0.18; //decimal total = subtotal + itbis; if (qty >= 1) { reservacion = new ReservacionModel(); reservacionDetalle = new ReservacionDetalle(); reservacion.ClienteID = cliente.ID; reservacion.Fecha = dateReservacion.SelectedDate.Value.Date; reservacionDetalle.Servicio = item; reservacionDetalle.Cantidad = qty; reservacionDetalle.Subtotal = subtotal; reservacionDetalle.Itbis = itbis; Items.Add(reservacionDetalle); dgReservacion.Items.Add(reservacionDetalle); ActualizarPrecios(reservacionDetalle, null); //item.CuposDisponibles -= qty; qtyPicker.Value = 1; comboxClienteR.IsEnabled = false; txtClienteCodigo.IsEnabled = false; comboxServicioR.SelectedIndex = -1; } else { _ = MessageBox.Show("LA CANTIDAD SELECCIONADA NO ES VALIDA", "ERROR", MessageBoxButton.OK); } } else { _ = MessageBox.Show("FECHA DEL SERVICIO CHOCA CON OTRO SERVICIO SELECCIONADO", "ERROR", MessageBoxButton.OK); } } else { _ = MessageBox.Show("DEBE SELECCIONAR EL CLIENTE Y AL MENOS UN PRODUCTO", "ERROR", MessageBoxButton.OK); } }
private ServicioModel Servicio() { var Servicio = new ServicioModel(); Servicio.Id_servicio = Id_Servicio.Text; Servicio.User = UserLoginCache.UserId; Servicio.Fecha = DateTime.Now.ToString("MM/dd/yyyy"); Servicio.Area_Bri = AreaPro1.Text; Servicio.Nombre_Brin = NombreServicio1.Text; Servicio.Description1 = Description1.Text; Servicio.Area_Busq = AreaPro2.Text; Servicio.Nombre_Busq = NombreServicio2.Text; Servicio.Description2 = Description2.Text; Servicio.ValorPromedio = double.Parse(ValorPRomedio.Text); return(Servicio); }
public JsonResult CrearServicio(string nombre, decimal valor, string descripcion, bool estado) { var response = new { valid = true, message = "" }; var servicio = new ServicioModel { Servicio = nombre, Descripcion = descripcion, Valor = valor, Estado = estado }; var crear = new ServiciosBo().AgregaServicio(new ServiciosRequest { Servicio = new ViewModelMapperHelper().CrearServicio(servicio) }); if (crear.EsValido) { response = new { valid = true, message = "" }; } else { response = new { valid = false, message = crear.MensajeError }; } return(Json(response, JsonRequestBehavior.AllowGet)); }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { if (opc == 1) { if (ValidarDatos()) { var ubicacion = cbxDetallePais.SelectedItem as UbicacionModel; var servicio = new ServicioModel() { Descripcion = txtDescripcion.Text, Precio = Convert.ToDecimal(txtPrecio.Text), CuposDisponibles = (int)qtyPicker.Value, fechaDesde = dateDetailsFrom.SelectedDate.Value, fechaHasta = dateDetailsTo.SelectedDate.Value, UbicacionID = ubicacion.ID }; var output = da.Insert(servicio); if (output > 0) { MessageBox.Show("NUEVO SERVICIO REGISTRADO EXITOSAMENTE!", "REGISTRADO", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("HA OCURRIDO UN ERROR", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } } } else if (opc == 2) { if (ValidarDatos()) { var selection = dgServicios.SelectedItem as ServicioModel; var ubicacion = cbxDetallePais.SelectedItem as UbicacionModel; var servicio = new ServicioModel() { ID = selection.ID, Descripcion = txtDescripcion.Text, Precio = decimal.Parse((string)txtPrecio.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.Number), CuposDisponibles = (int)qtyPicker.Value, fechaDesde = dateDetailsFrom.SelectedDate.Value, fechaHasta = dateDetailsTo.SelectedDate.Value, UbicacionID = ubicacion.ID }; var output = da.Edit(servicio); if (output > 0) { MessageBox.Show("SERVICIO ACTUALIZADO", "ACTUALIZADO", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("HA OCURRIDO UN ERROR", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } } } MainWindow mw = (MainWindow)Window.GetWindow(this); mw.GridPrincipal.Children.Clear(); mw.GridPrincipal.Children.Add(new CatalogoUC()); mw.ListViewMenu.IsEnabled = true; }
/// <summary> /// Ejecuta la acción del command /// </summary> /// <param name="catalogItemStatusViewModel"></param> public ModifyServicioViewModel(CatalogServicioViewModel catalogServicioViewModel, ServicioModel selectedServicioModel) { this._modiServicio = new ServicioModel(new ServicioDataMapper(), catalogServicioViewModel.ActualUser); this._catalogServicioViewModel = catalogServicioViewModel; this._modiServicio.UnidServicio = selectedServicioModel.UnidServicio; this._modiServicio.ServicioName = selectedServicioModel.ServicioName; }
public HistorialViewModel(ServicioModel b) { unid = b.UnidServicio; HistorialCollection = GetHistorial("SERVICIO"); }
/// <summary> /// Ejecuta la acción del command /// </summary> /// <param name="catalogItemStatusViewModel"></param> public AddServicioViewModel(CatalogServicioViewModel catalogServicioViewModel) { this._addServicio = new ServicioModel(new ServicioDataMapper(), catalogServicioViewModel.ActualUser); this._catalogServicioViewModel = catalogServicioViewModel; }