/// <summary> /// Abre la ventana detalle en modo "detalle" o "edición" dependiendo de sus permisos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 10/06/2016 /// </history> private async void Cell_DoubleClick(object sender, RoutedEventArgs e) { PersonnelShort personnelShort = (PersonnelShort)dgrPersonnels.SelectedItem; Personnel personnel = BRPersonnel.GetPersonnelById(personnelShort.peID); frmPersonnelDetail frmPersonnelDetail = new frmPersonnelDetail(); frmPersonnelDetail.Owner = this; frmPersonnelDetail.enumMode = (_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly; frmPersonnelDetail.oldPersonnel = personnel; if (frmPersonnelDetail.ShowDialog() == true) { int nIndex = 0; List <PersonnelShort> lstPersonnel = (List <PersonnelShort>)dgrPersonnels.ItemsSource; var persons = await BRPersonnel.GetPersonnel(idPersonnel : frmPersonnelDetail.personnel.peID); if (persons.Count > 0) { PersonnelShort person = persons.FirstOrDefault(); ObjectHelper.CopyProperties(personnelShort, person); //Actualizamos los datos lstPersonnel.Sort((x, y) => string.Compare(x.peN, y.peN)); //Ordenamos la lista nIndex = lstPersonnel.IndexOf(personnelShort); //Obtenemos la posición del registro } else { lstPersonnel.Remove(personnelShort);//Quitamos el registro } btnDel.IsEnabled = (lstPersonnel.Count > 0) ? _blnDel : false; dgrPersonnels.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrPersonnels, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstPersonnel.Count + " Personnels."; //Actualizamos el contador } }
/// <summary> /// Obtiene personnels ligados a FoliosCxCPR /// </summary> /// <param name="personnelShort">Objeto con filtros adicionales</param> /// <returns>Lista tipo PersonnelShort</returns> /// <history> /// [emoguel] created 05/05/2016 /// </history> public async static Task <List <PersonnelShort> > GetPRByFoliosCXC(PersonnelShort personnelShort = null) { List <PersonnelShort> lstPersonnelShort = await Task.Run(() => { using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString())) { var query = from pe in dbContext.Personnels join pr in dbContext.FoliosCxCPR on pe.peID equals pr.fcppe group pe by new { pe.peID, pe.peN } into p select p; if (personnelShort != null) { if (!string.IsNullOrWhiteSpace(personnelShort.peID))//Filtro por ID { query = query.Where(pe => pe.Key.peID == personnelShort.peID); } if (!string.IsNullOrWhiteSpace(personnelShort.peN))//Filtro por descripción { query = query.Where(pe => pe.Key.peN.Contains(personnelShort.peN)); } } List <PersonnelShort> lstPersonnelShorts = query.ToList().Select(pe => new PersonnelShort { peID = pe.Key.peID, peN = pe.Key.peN }).ToList(); return(lstPersonnelShorts.OrderBy(pe => pe.peN).ToList()); } }); return(lstPersonnelShort); }
/// <summary> /// Llena el grid de personnels /// </summary> /// <param name="personnel">objeto a seleccionar</param> /// <history> /// [emoguel] created 10/06/2016 /// </history> private async void LoadPersonnel(PersonnelShort personnel = null) { try { status.Visibility = Visibility.Visible; int nIndex = 0; List <PersonnelShort> lstPersonnels = await BRPersonnel.GetPersonnel(_leadSource, _salesRoom, _roles, _status, _permission , _relationalOperator, _enumPermission, _dept); dgrPersonnels.ItemsSource = lstPersonnels; if (lstPersonnels.Count > 0) { if (personnel != null) { personnel = lstPersonnels.Where(pe => pe.peID == personnel.peID).FirstOrDefault(); nIndex = lstPersonnels.IndexOf(personnel); } GridHelper.SelectRow(dgrPersonnels, nIndex); } else { btnDel.IsEnabled = false; } StatusBarReg.Content = lstPersonnels.Count + " Personnels"; status.Visibility = Visibility.Collapsed; } catch (Exception ex) { UIHelper.ShowMessage(ex); } }
/// <summary> /// Valida los campos obligatorios segun sea requerido /// </summary> /// <returns> False - Algun Campo Vacio | True - Campos llenados correctamente </returns> /// <history> /// [vipacheco] 01/04/2016 Created /// [vipahceco] 15/Agosto/2016 Modified -> Se valida que el ticket tenga pax asociados. /// </history> private bool ValidateGeneral() { MealTicketType ticketCurrent = cboType.SelectedItem as MealTicketType; if (frmMealTickets._guestID == 0) { RateType rateType = cboRateType.SelectedItem as RateType; PersonnelShort personnel = cboCollaborator.SelectedItem as PersonnelShort; AgencyShort agency = cboAgency.SelectedItem as AgencyShort; if (rateType == null) { UIHelper.ShowMessage("Select an option of rate type, please", MessageBoxImage.Information); return(false); } else if (rateType.raID >= 2 && rateType.raID < 4 && personnel == null) { UIHelper.ShowMessage("Select a collaborator, please", MessageBoxImage.Information); return(false); } else if (rateType.raID == 4 && (agency == null || txtRepresentative.Text == "")) { UIHelper.ShowMessage("Select an agency and write the representative name in the field for External option.", MessageBoxImage.Information); return(false); } else if (ticketCurrent == null) { UIHelper.ShowMessage("Select an option of meal type, please", MessageBoxImage.Information); return(false); } // Verificamos el Pax int adults, minors = 0; if (string.IsNullOrEmpty(txtAdults.Text) && string.IsNullOrEmpty(txtMinors.Text)) { UIHelper.ShowMessage("Set the Pax information, adults or minors", MessageBoxImage.Information); return(false); } else if (int.TryParse(txtAdults.Text, out adults) && int.TryParse(txtMinors.Text, out minors)) { // Verificamos que no sean ambos 0 if (adults == 0 && minors == 0) { UIHelper.ShowMessage("Set the Pax information, adults or minors", MessageBoxImage.Information); return(false); } } } else { if (ticketCurrent == null) { UIHelper.ShowMessage("Select an option of meal type, please", MessageBoxImage.Information); return(false); } } return(true); }
/// <summary> /// Muestra la ventada detalle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 07/05/2016 /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { PersonnelShort personnel = (PersonnelShort)dgrPRs.SelectedItem; frmFoliosInvitationsOuthousePRDetail frmFolioDetail = new frmFoliosInvitationsOuthousePRDetail(); frmFolioDetail.Owner = this; frmFolioDetail.personnel = personnel; frmFolioDetail.enumMode = (_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly; frmFolioDetail.ShowDialog(); }
/// <summary> /// Abre la ventana de PostLog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 10/06/2016 /// </history> private void btnPostLog_Click(object sender, RoutedEventArgs e) { PersonnelShort personnel = (PersonnelShort)dgrPersonnels.SelectedItem; frmPostsLog frmPostLog = new frmPostsLog(); frmPostLog.Owner = this; frmPostLog._postLogFilter = new PostLog { pppe = personnel.peID }; frmPostLog.btnSearch.Visibility = Visibility.Collapsed; frmPostLog.ShowDialog(); }
/// <summary> /// Abre la ventana de busqueda /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 12/05/2016 /// </history> private void btnSearch_Click(object sender, RoutedEventArgs e) { frmFoliosInvitationsOuthousePRDetail frmFolioDetail = new frmFoliosInvitationsOuthousePRDetail(); frmFolioDetail.Owner = this; frmFolioDetail.personnel = _prFilter; frmFolioDetail.enumMode = EnumMode.Search; if (frmFolioDetail.ShowDialog() == true) { _prFilter = frmFolioDetail.personnel; LoadPrs(); } }
/// <summary> /// Obtiene los statistics del antiguo personnel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 24/06/2016 /// </history> private async void btnGetStaticsOld_Click(object sender, RoutedEventArgs e) { if (cmbPersonnelOld.SelectedValue != null) { idOldSelect = cmbPersonnelOld.SelectedValue.ToString(); lockButtons(false); txtStatus.Text = "Loading..."; PersonnelShort personnelShort = (PersonnelShort)cmbPersonnelOld.SelectedItem; PersonnelStatistics personnelStatistics = await BRPersonnel.GetPersonnelStatistics(personnelShort.peID); LoadStatistics(tvwOld, personnelStatistics, personnelShort); lockButtons(true); } else { UIHelper.ShowMessage("Please select a Personnel"); } }
/// <summary> /// Verifica que cumpla con los filtros actuales /// </summary> /// <param name="personnel">objeto a validar</param> /// <returns>True. SI cumple | False. No cumple</returns> /// <history> /// [emoguel] created 09/05/2016 /// </history> private bool ValidateFilter(PersonnelShort personnel) { if (!string.IsNullOrWhiteSpace(_prFilter.peID)) { if (personnel.peID != _prFilter.peID) { return(false); } } if (!string.IsNullOrWhiteSpace(_prFilter.deN)) { if (_prFilter.deN != personnel.deN) { return(false); } } return(true); }
/// <summary> /// Abre la ventana de changeID /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 10/06/2016 /// </history> private void btnChangeID_Click(object sender, RoutedEventArgs e) { frmPersonnelChangeID frmPersonnelChangeID = new frmPersonnelChangeID(); frmPersonnelChangeID.Owner = this; if (dgrPersonnels.SelectedItem != null) { PersonnelShort personnelShort = (PersonnelShort)dgrPersonnels.SelectedItem; frmPersonnelChangeID.idOldSelect = personnelShort.peID; } if (frmPersonnelChangeID.ShowDialog() == true) { List <PersonnelShort> lstPersonnel = (List <PersonnelShort>)dgrPersonnels.ItemsSource; PersonnelShort personnelShort = lstPersonnel.Where(pe => pe.peID == frmPersonnelChangeID.idOldSelect).FirstOrDefault(); lstPersonnel.Remove(personnelShort); dgrPersonnels.Items.Refresh(); GridHelper.SelectRow(dgrPersonnels, 0); } }
/// <summary> /// Obtiene los statistics del nuevo personnel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 24/06/2016 /// </history> private async void btnGetStaticsNew_Click(object sender, RoutedEventArgs e) { if (cmbPersonnelNew.SelectedValue != null) { idNewSelect = cmbPersonnelNew.SelectedValue.ToString(); lockButtons(false); status.Visibility = Visibility.Visible; txtStatus.Text = "Loading..."; PersonnelShort personnelShort = (PersonnelShort)cmbPersonnelNew.SelectedItem; PersonnelStatistics personnelStatistics = await BRPersonnel.GetPersonnelStatistics(personnelShort.peID); LoadStatistics(tvwNew, personnelStatistics, personnelShort); status.Visibility = Visibility.Collapsed; lockButtons(true); } else { UIHelper.ShowMessage("Please select a Personnel"); } }
/// <summary> /// Evento que se lanza cuando realizamos la consulta boton Search /// </summary> /// <history> /// [erosado] 22/Mar/2016 Created /// </history> private void imgButtonOk_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (DateHelper.ValidateValueDate(dtpkFrom, dtpkTo)) { if (cbxPersonnel?.SelectedValue != null) { imgButtonOk.Focus(); StaStart("Loading data..."); imgButtonOk.IsEnabled = false; filtersBool = new List <bool>(); PersonnelShort closer = cbxPersonnel.SelectedValue as PersonnelShort; filtersReport = new List <Tuple <string, string> >(); filtersReport.Add(new Tuple <string, string>("Closer", string.Concat(closer.peID, " - ", closer.peN))); DoGetSalesByCloser(dtpkFrom.Value.Value, dtpkTo.Value.Value, Context.User.SalesRoom.srID, closer.peID); } else { UIHelper.ShowMessage("Please select a personnel", MessageBoxImage.Warning); cbxPersonnel.Focus(); } } }
/// <summary> /// Llena el grid de personnels /// </summary> /// <param name="personnel">Objeto a seleccionar</param> /// <history> /// [emoguel] created 07/05/2016 /// </history> private async void LoadPrs(PersonnelShort personnel = null) { try { status.Visibility = Visibility.Visible; int nIndex = 0; List <PersonnelShort> lstPersonnel = await BRFoliosInvitationsOuthousePR.GetPRbyFolioOuthouse(_prFilter); dgrPRs.ItemsSource = lstPersonnel; if (lstPersonnel.Count > 0 && personnel != null) { personnel = lstPersonnel.Where(pe => pe.peID == personnel.peID).FirstOrDefault(); nIndex = lstPersonnel.IndexOf(personnel); } GridHelper.SelectRow(dgrPRs, nIndex); StatusBarReg.Content = lstPersonnel.Count + " PRs."; status.Visibility = Visibility.Collapsed; } catch (Exception ex) { UIHelper.ShowMessage(ex); } }
/// <summary> /// Agrega Folios CxCPR y FolioCxCCancellation /// </summary> /// <param name="personnel"></param> /// <param name="lstFoliosCxCPR"></param> /// <param name="lstFoliosCancell"></param> /// <returns>0. No se guardó | >0. Se guardó correctamente</returns> /// <history> /// [emoguel] created 07/05/2016 /// [emoguel] modified 09/06/2016 -->Se volvió async /// </history> public async static Task <int> SaveFoliosCxCByPR(PersonnelShort personnel, List <FolioCxCPR> lstFoliosCxCPR, List <FolioCxCCancellation> lstFoliosCancell) { int nRes = await Task.Run(() => { using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString())) { using (var transacction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable)) { try { lstFoliosCxCPR.ForEach(fcp => { fcp.fcppe = personnel.peID; dbContext.Entry(fcp).State = (fcp.fcpID > 0) ? EntityState.Modified : EntityState.Added; }); lstFoliosCancell.ForEach(fcc => { fcc.fccpe = personnel.peID; dbContext.Entry(fcc).State = (fcc.fccID > 0) ? EntityState.Modified : EntityState.Added; }); int nSave = dbContext.SaveChanges(); transacction.Commit(); return(nSave); } catch { transacction.Rollback(); return(0); } } } }); return(nRes); }
/// <summary> /// Abre la ventana detalle en modo Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 10/06/2016 /// </history> private async void btnAdd_Click(object sender, RoutedEventArgs e) { frmPersonnelDetail frmPersonnelDetail = new frmPersonnelDetail(); frmPersonnelDetail.Owner = this; frmPersonnelDetail.enumMode = EnumMode.Add; if (frmPersonnelDetail.ShowDialog() == true) { var persons = await BRPersonnel.GetPersonnel(idPersonnel : frmPersonnelDetail.personnel.peID); if (persons.Count > 0) { List <PersonnelShort> lstPersonnel = (List <PersonnelShort>)dgrPersonnels.ItemsSource; PersonnelShort person = persons.FirstOrDefault(); lstPersonnel.Add(person); //Agregamos el registro lstPersonnel.Sort((x, y) => string.Compare(x.peN, y.peN)); //Ordenamos la lista int nIndex = lstPersonnel.IndexOf(person); //Obtenemos la posición del registro btnDel.IsEnabled = (lstPersonnel.Count > 0) ? _blnDel : false; dgrPersonnels.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrPersonnels, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstPersonnel.Count + " Personnels."; //Actualizamos el contador } } }
/// <summary> /// Envia el correo electronico de huespedes que se presentaron sin su invitacion impresa /// </summary> /// <param name="guest">Guest</param> /// <param name="salesRoom">SalesRoom</param> /// <param name="leadSource">LeadSource</param> /// <param name="personnel">Personal PRInvit1</param> /// <param name="bookingDepositTable">Datatable de Deposit</param> /// <returns>mensaje si ocurre error</returns> /// <history> /// [aalcocer] 18/08/2016 Created /// </history> internal static string SendMail(Guest guest, SalesRoomShort salesRoom, LeadSource leadSource, PersonnelShort personnel, DataTable bookingDepositTable) { Assembly assembly = Assembly.GetExecutingAssembly(); string strtemplate; using (Stream stream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".Template.emailShowTemplate.html")) using (StreamReader reader = new StreamReader(stream)) { strtemplate = reader.ReadToEnd(); } var values = Regex.Matches(strtemplate, @"(\[.*?\])+").Cast <Match>().Select(m => m.Value).ToList(); //Obtenemos los tipos de objeto var objects = new List <object> { guest, salesRoom, leadSource, personnel }; //Remplazamos objects.ForEach(obj => { Type type = obj.GetType();//Obtenemos el tipo de objeto foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(pi => !pi.GetMethod.IsVirtual).Where(pi => values.Contains($"[{pi.Name}]"))) { var value = type.GetProperty(pi.Name).GetValue(obj, null) ?? string.Empty; var strValue = value.ToString(); if (value is DateTime) { strValue = ((DateTime)value).ToString("dd/MM/yyyy"); } strtemplate = strtemplate.Replace($"[{pi.Name}]", strValue); } }); strtemplate = strtemplate.Replace("[BookingDepositTable]", BookingDepositDataTableToHtml(bookingDepositTable)); try { Notifier.SendMail(Settings.Default.Subject, strtemplate, Settings.Default.ToEmail.Cast <string>().ToArray(), string.Empty, string.Empty); return(string.Empty); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// Crea un nuevo mealticket /// </summary> /// <param name="_rateType"></param> /// <param name="_mealType"></param> /// <param name="_personnel"></param> /// <param name="_agency"></param> /// <param name="_meAdults"></param> /// <param name="_meMinors"></param> /// <param name="_meTAdultsString"></param> /// <param name="_meTMinorsString"></param> /// <param name="folioNew"></param> /// <returns></returns> /// <history> /// [vipacheco] 25/Abril/2016 Created /// </history> private MealTicket CreateMealTicket(RateType _rateType, MealTicketType _mealType, PersonnelShort _personnel, AgencyShort _agency, int _meAdults, int _meMinors, string _meTAdultsString, string _meTMinorsString, int folioNew) { return(new MealTicket { meD = dtpDate.Value.Value.Date, megu = frmMealTickets._guestID, meQty = frmMealTickets._Qty, meType = _mealType.myID, meAdults = _meAdults, meMinors = _meMinors, meFolios = folioNew + "", meTAdults = Convert.ToDecimal(_meTAdultsString), meTMinors = Convert.ToDecimal(_meTMinorsString), meComments = txtComments.Text, mesr = Context.User.SalesRoom.srID, meCanc = chkCancel.IsChecked.Value, mera = cboRateType.IsVisible ? _rateType.raID : 1, mepe = cboCollaborator.IsVisible ? _personnel.peID : null, mePrinted = chkPrinted.IsChecked.Value, meag = cboAgency.IsVisible ? _agency.agID : null, merep = txtRepresentative.IsVisible ? txtRepresentative.Text : null, meAuthorizedBy = Context.User.User.peID }); }
/// <summary> /// Agrega los statistics a un treeview /// </summary> /// <param name="trv">treeview a modificar</param> /// <param name="idPersonnel">id del personnel a buscar sus statistics</param> /// <history> /// [emoguel] created 24/06/2016 /// </history> private void LoadStatistics(TreeView trv, PersonnelStatistics personnelStatistics, PersonnelShort personnelShort) { if (personnelStatistics != null) { #region Operations //Total de Guest int?valueGuest = personnelStatistics.Guests_PR + personnelStatistics.Guests_Liner + personnelStatistics.Guests_Closer + personnelStatistics.Guests_Exit + personnelStatistics.Guests_Podium + personnelStatistics.Guests_VLO + personnelStatistics.Guests_Host + personnelStatistics.Guests_Captain + personnelStatistics.Shows_Salesmen + personnelStatistics.Guests_Log + personnelStatistics.Guests_Movements; //Total de sales int?valueSales = personnelStatistics.Sales_PR + personnelStatistics.Sales_Liner + personnelStatistics.Sales_Closer + personnelStatistics.Sales_Exit + personnelStatistics.Sales_Podium + personnelStatistics.Sales_VLO + personnelStatistics.Sales_Captain + personnelStatistics.Sales_Salesmen + personnelStatistics.Sales_Log; //Total de GiftsReceipts int?valueGiftsReceipts = personnelStatistics.Gifts_Receipts_Authorized + personnelStatistics.Gifts_Receipts_Host + personnelStatistics.Gifts_Receipts_PR + personnelStatistics.Gifts_Receipts_Payments + personnelStatistics.Gifts_Receipts_Log; //Total operations int?valueOperations = valueGuest + valueSales + valueGiftsReceipts + personnelStatistics.Meal_Tickets + personnelStatistics.Exchange_Rate_Log + personnelStatistics.Warehouse_Movements + personnelStatistics.PR_Notes + personnelStatistics.Logins_Log + personnelStatistics.Assistance + personnelStatistics.Days_Off + personnelStatistics.Efficiency_Salesmen; //Add operation TreeViewItem tviOperations = addTreeViewItem("Operations", valueOperations); trv.Items.Add(tviOperations); //Huespedes TreeViewItem tviGuest = addTreeViewItem("Guests", valueGuest); tviOperations.Items.Add(tviGuest); tviGuest.Items.Add(addTreeViewItem("Guests PR", personnelStatistics.Guests_PR)); tviGuest.Items.Add(addTreeViewItem("Guests Liner", personnelStatistics.Guests_Liner)); tviGuest.Items.Add(addTreeViewItem("Guests Closer", personnelStatistics.Guests_Closer)); tviGuest.Items.Add(addTreeViewItem("Guests Exit", personnelStatistics.Guests_Exit)); tviGuest.Items.Add(addTreeViewItem("Guests Podium", personnelStatistics.Guests_Podium)); tviGuest.Items.Add(addTreeViewItem("Guests VLO", personnelStatistics.Guests_VLO)); tviGuest.Items.Add(addTreeViewItem("Guests Host", personnelStatistics.Guests_Host)); tviGuest.Items.Add(addTreeViewItem("Guests Captain", personnelStatistics.Guests_Captain)); tviGuest.Items.Add(addTreeViewItem("Shows Salesmen", personnelStatistics.Shows_Salesmen)); tviGuest.Items.Add(addTreeViewItem("Guests Log", personnelStatistics.Guests_Log)); tviGuest.Items.Add(addTreeViewItem("Guests Movements", personnelStatistics.Guests_Movements)); //Ventas TreeViewItem tviSales = addTreeViewItem("Sales", valueSales); tviOperations.Items.Add(tviSales); tviSales.Items.Add(addTreeViewItem("Sales PR", personnelStatistics.Sales_PR)); tviSales.Items.Add(addTreeViewItem("Sales Liner", personnelStatistics.Sales_Liner)); tviSales.Items.Add(addTreeViewItem("Sales Closer", personnelStatistics.Sales_Closer)); tviSales.Items.Add(addTreeViewItem("Sales Exit", personnelStatistics.Sales_Podium)); tviSales.Items.Add(addTreeViewItem("Sales VLO", personnelStatistics.Sales_VLO)); tviSales.Items.Add(addTreeViewItem("Sales Captain", personnelStatistics.Sales_Captain)); tviSales.Items.Add(addTreeViewItem("Sales Salesmen", personnelStatistics.Sales_Salesmen)); tviSales.Items.Add(addTreeViewItem("Sales Log", personnelStatistics.Sales_Log)); //Recibos de regalo TreeViewItem tviGiftReceip = addTreeViewItem("Gifts Receipts", valueGiftsReceipts); tviOperations.Items.Add(tviGiftReceip); tviGiftReceip.Items.Add(addTreeViewItem("Gifts Receipts Authorized", personnelStatistics.Gifts_Receipts_Authorized)); tviGiftReceip.Items.Add(addTreeViewItem("Gifts Receipts Host", personnelStatistics.Gifts_Receipts_Host)); tviGiftReceip.Items.Add(addTreeViewItem("Gifts Receipts PR", personnelStatistics.Gifts_Receipts_PR)); tviGiftReceip.Items.Add(addTreeViewItem("Gifts Receipts Payments", personnelStatistics.Gifts_Receipts_Payments)); tviGiftReceip.Items.Add(addTreeViewItem("Gifts Receipts Log", personnelStatistics.Gifts_Receipts_Log)); //cupones de comida tviOperations.Items.Add(addTreeViewItem("Meal Tickets", personnelStatistics.Meal_Tickets)); //Tipos de cambio tviOperations.Items.Add(addTreeViewItem("Exchange Rate Log", personnelStatistics.Exchange_Rate_Log)); //Movimientos al inventario tviOperations.Items.Add(addTreeViewItem("Warehouse Movements", personnelStatistics.Warehouse_Movements)); //Notas de PR tviOperations.Items.Add(addTreeViewItem("PR Notes", personnelStatistics.PR_Notes)); //Sesiones tviOperations.Items.Add(addTreeViewItem("Logins Log", personnelStatistics.Logins_Log)); //Asistencia tviOperations.Items.Add(addTreeViewItem("Assistance", personnelStatistics.Assistance)); tviOperations.Items.Add(addTreeViewItem("Days Off", personnelStatistics.Days_Off)); //Eficiencia tviOperations.Items.Add(addTreeViewItem("Efficiency Salesmen", personnelStatistics.Efficiency_Salesmen)); #endregion #region Catalogs //Total de personnel int?valuePersonnel = personnelStatistics.Places_Access + personnelStatistics.Roles + personnelStatistics.Permissions + personnelStatistics.Personnel_Liner + personnelStatistics.Posts_Log + personnelStatistics.Teams_Log + personnelStatistics.Teams_Guest_Services + personnelStatistics.Teams_Salesmen; //Total de sales Room int?valueSalesRoom = personnelStatistics.Sales_Rooms + personnelStatistics.Sales_Rooms_Log; //Total de catalogs int?valueCatalogs = valuePersonnel + valueSalesRoom + personnelStatistics.Gifts_Log + personnelStatistics.Lead_Sources + personnelStatistics.Configurations; //Add operation TreeViewItem tviCatalogs = addTreeViewItem("Catalogs", valueCatalogs); trv.Items.Add(tviCatalogs); //Personnel TreeViewItem tviPersonnel = addTreeViewItem("Personnel", valuePersonnel); tviCatalogs.Items.Add(tviPersonnel); tviPersonnel.Items.Add(addTreeViewItem("Places Acces", personnelStatistics.Places_Access)); tviPersonnel.Items.Add(addTreeViewItem("Roles", personnelStatistics.Roles)); tviPersonnel.Items.Add(addTreeViewItem("Permissions", personnelStatistics.Permissions)); tviPersonnel.Items.Add(addTreeViewItem("Personnel Liner", personnelStatistics.Personnel_Liner)); tviPersonnel.Items.Add(addTreeViewItem("Post Log", personnelStatistics.Posts_Log)); tviPersonnel.Items.Add(addTreeViewItem("Teams log", personnelStatistics.Teams_Log)); tviPersonnel.Items.Add(addTreeViewItem("Teams Guest Services", personnelStatistics.Teams_Guest_Services)); tviPersonnel.Items.Add(addTreeViewItem("Teams Salesmen", personnelStatistics.Teams_Salesmen)); //Gifts TreeViewItem tviGift = addTreeViewItem("Gifts", personnelStatistics.Gifts_Log); tviCatalogs.Items.Add(tviGift); tviGift.Items.Add(addTreeViewItem("Gifts Log", personnelStatistics.Gifts_Log)); //Lead Sources tviCatalogs.Items.Add(addTreeViewItem("Lead Sources", personnelStatistics.Lead_Sources)); //SalesRooom TreeViewItem tviSalesRoom = addTreeViewItem("Sales Room", valueSalesRoom); tviCatalogs.Items.Add(tviSalesRoom); tviSalesRoom.Items.Add(addTreeViewItem("Sales Room Boss", personnelStatistics.Sales_Rooms)); tviSalesRoom.Items.Add(addTreeViewItem("Sales Rooms Log", personnelStatistics.Sales_Rooms_Log)); //Configurations tviCatalogs.Items.Add(addTreeViewItem("Configurations", personnelStatistics.Configurations)); #endregion if (trv.Name == "tvwOld") { msjOld = "\n Old ID=" + personnelShort.peID + ", " + personnelShort.peN + " \n Records " + valueOperations + valueCatalogs + " " + valueOperations + " Operations + " + valueCatalogs + " Catalogs"; } else { msjNew = "\n New ID=" + personnelShort.peID + ", " + personnelShort.peN + " \n Records " + valueOperations + valueCatalogs + " " + valueOperations + " Operations + " + valueCatalogs + " Catalogs"; } } else { trv.Items.Add(addTreeViewItem("No Data", null)); } }
/// <summary> /// Guarda la informacion proporcionada! /// </summary> /// <history> /// [vipacheco] 23/03/2016 Created /// </history> private void btnSave_Click(object sender, RoutedEventArgs e) { if (ValidateGeneral()) { RateType _rateType = cboRateType.SelectedItem as RateType; MealTicketType _mealType = cboType.SelectedItem as MealTicketType; PersonnelShort _personnel = cboCollaborator.SelectedItem as PersonnelShort; AgencyShort _agency = cboAgency.SelectedItem as AgencyShort; int _meAdults = Convert.ToInt32((txtAdults.Text == "") ? "0" : txtAdults.Text); int _meMinors = Convert.ToInt32((txtMinors.Text == "") ? "0" : txtMinors.Text); string _meTAdultsString = txtTAdults.Text.TrimStart('$'); string _meTMinorsString = txtTMinors.Text.TrimStart('$'); // Agrega un nuevo Meal Ticket if (_modeOpen == EnumMode.Add) { // Obtenemos el folio a asignar int folioNew = 1 + BRMealTicketFolios.GetMaxMealTicketFolio(Context.User.SalesRoom.srID, _mealType.myID, _rateType == null ? 1 : _rateType.raID); _mealTicketCurrency = CreateMealTicket(_rateType, _mealType, _personnel, _agency, _meAdults, _meMinors, _meTAdultsString, _meTMinorsString, folioNew); //Actualizamos el folio! BRMealTicketFolios.UpdateMealTicketFolio(Context.User.SalesRoom.srID, _mealType.myID, _rateType == null ? 1 : _rateType.raID, $"{folioNew}"); //Guardamos el Meal Ticket Creado BRMealTickets.InsertNewMealTicket(_mealTicketCurrency); } // Modo edicion else { int folio = Convert.ToInt32(_mealTicketCurrency.meFolios); // Creamos el Meal Ticket con el guestID _mealTicketCurrency.meD = dtpDate.Value.Value.Date; _mealTicketCurrency.megu = _mealTicketCurrency.megu != 0 ? _mealTicketCurrency.megu : frmMealTickets._guestID; _mealTicketCurrency.meQty = frmMealTickets._Qty; _mealTicketCurrency.meType = _mealType.myID; _mealTicketCurrency.meAdults = _meAdults; _mealTicketCurrency.meMinors = _meMinors; _mealTicketCurrency.meFolios = $"{folio}"; _mealTicketCurrency.meTAdults = Convert.ToDecimal(_meTAdultsString); _mealTicketCurrency.meTMinors = Convert.ToDecimal(_meTMinorsString); _mealTicketCurrency.meComments = txtComments.Text; _mealTicketCurrency.mesr = Context.User.SalesRoom.srID; _mealTicketCurrency.meCanc = chkCancel.IsChecked.Value; _mealTicketCurrency.mera = frmMealTickets._guestID > 0 ? 1 : _rateType.raID; _mealTicketCurrency.mepe = cboCollaborator.IsVisible ? _personnel.peID : null; _mealTicketCurrency.mePrinted = chkPrinted.IsChecked.Value; _mealTicketCurrency.meag = cboAgency.IsVisible ? _agency.agID : null; _mealTicketCurrency.merep = txtRepresentative.IsVisible ? txtRepresentative.Text : null; _mealTicketCurrency.meAuthorizedBy = Context.User.User.peID; //Actualizamos el folio! BRMealTicketFolios.UpdateMealTicketFolio(Context.User.SalesRoom.srID, _mealType.myID, _rateType.raID, _mealTicketCurrency.meFolios); // Insertamos el nuevo Meal Ticket con el folio asignado BRMealTickets.UpdateMealTicket(_mealTicketCurrency); } //Actualizamos el campo guMealTicket del Guest BRGuests.UpdateFieldguMealTicket(true, frmMealTickets._guestID); DialogResult = true; Close(); } }
/// <summary> /// Recarga los registros del grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 10/06/2016 /// </history> private void btnRef_Click(object sender, RoutedEventArgs e) { PersonnelShort personnel = (PersonnelShort)dgrPersonnels.SelectedItem; LoadPersonnel(personnel); }
/// <summary> /// Agrega|Actualiza un folioCxcPR /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 05/05/2016 /// </history> private async void btnAccept_Click(object sender, RoutedEventArgs e) { btnAccept.Focus(); if (enumMode != EnumMode.Search) { List <FolioCxCPR> lstFoliosPR = (List <FolioCxCPR>)dgrAssigned.ItemsSource; List <FolioCxCCancellation> lstFoliosCan = (List <FolioCxCCancellation>)dgrCancelled.ItemsSource; bool blnHasChanged = ValidateChanged(lstFoliosPR, lstFoliosCan); if (enumMode != EnumMode.Add && !blnHasChanged) { blnClosing = true; Close(); } else { txtStatus.Text = "Saving Data..."; skpStatus.Visibility = Visibility.Visible; PersonnelShort personnelSave = (PersonnelShort)cmbPersonnel.SelectedItem; if (personnelSave != null) { string strMsj = ""; if (enumMode == EnumMode.Add) { var lstFolioCXC = await BRFoliosCXCPR.GetPRByFoliosCXC(personnelSave); var folioCxC = lstFolioCXC.FirstOrDefault(); if (folioCxC != null) { UIHelper.ShowMessage("The current PR already has folios, edit the correspoding PR."); return; } if (lstFoliosPR.Count == 0) { UIHelper.ShowMessage("Cannot save an empty record, please add folios.."); return; } } #region FoliosPR strMsj = ValidateFoliosPR(lstFoliosPR); if (strMsj != "") { UIHelper.ShowMessage(strMsj); return; } strMsj = ValidateCancelled(lstFoliosCan, lstFoliosPR); if (strMsj != "") { UIHelper.ShowMessage(strMsj); return; } int nRes = await BRFoliosCXCPR.SaveFoliosCxCByPR(personnelSave, lstFoliosPR, lstFoliosCan); UIHelper.ShowMessageResult("Folios", nRes); if (nRes > 0) { blnClosing = true; DialogResult = true; Close(); } #endregion } else { UIHelper.ShowMessage("Select a PR."); } skpStatus.Visibility = Visibility.Collapsed; } } else { #region Search if (cmbPersonnel.SelectedItem != null) { blnClosing = true; personnel = (PersonnelShort)cmbPersonnel.SelectedItem; DialogResult = true; Close(); } else if (!string.IsNullOrWhiteSpace(personnel.peID)) { cmbPersonnel.Focus(); UIHelper.ShowMessage("Please select a PR."); } else { blnClosing = true; Close(); } #endregion } }
/// <summary> /// Cambia el ID del personnel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 24/06/2016 /// </history> private async void btnChangeID_Click(object sender, RoutedEventArgs e) { try { lockButtons(false); if (cmbPersonnelNew.SelectedValue != null && cmbPersonnelOld.SelectedValue != null) { if (cmbPersonnelNew.SelectedValue != cmbPersonnelOld.SelectedValue) { #region Tasks lockButtons(false); txtStatus.Text = "Loading..."; if (cmbPersonnelOld.SelectedValue.ToString() != idOldSelect) { idOldSelect = cmbPersonnelOld.SelectedValue.ToString(); PersonnelShort personnelShort = (PersonnelShort)cmbPersonnelOld.SelectedItem; PersonnelStatistics personnelStatistics = await BRPersonnel.GetPersonnelStatistics(personnelShort.peID); LoadStatistics(tvwOld, personnelStatistics, personnelShort); } if (cmbPersonnelNew.SelectedValue.ToString() != idNewSelect) { idNewSelect = cmbPersonnelNew.SelectedValue.ToString(); PersonnelShort personnelShort = (PersonnelShort)cmbPersonnelNew.SelectedItem; PersonnelStatistics personnelStatistics = await BRPersonnel.GetPersonnelStatistics(personnelShort.peID); LoadStatistics(tvwNew, personnelStatistics, personnelShort); } #endregion MessageBoxResult msgResult = UIHelper.ShowMessage("Are you sure you want to change the User's ID? \n " + msjOld + " \n " + msjNew, MessageBoxImage.Question, "Personnel Change ID"); if (msgResult == MessageBoxResult.Yes) { txtStatus.Text = "Changing ID..."; int nRes = await BRPersonnel.UpdatePersonnelId(cmbPersonnelOld.SelectedValue.ToString(), cmbPersonnelNew.SelectedValue.ToString()); UIHelper.ShowMessageResult("ID", nRes); if (nRes > 0) { DialogResult = true; Close(); } } lockButtons(true); } } else { UIHelper.ShowMessage("Please select old ID and new ID"); } lockButtons(true); } catch (Exception ex) { UIHelper.ShowMessage(ex); } }