Summary description for RepairCardFilter
Пример #1
0
 protected void FilterRepairCards_OnClick(object sender, EventArgs e)
 {
     CarServicePresentationUtility.ClearNotificationMsgList(this.notificationMsgList);
     CarServicePresentationUtility.HideNotificationMsgList(this.notificationMsgList);
     int filterType = this.repairCardsFilterType.SelectedIndex;
     RepairCardFilter filter = new RepairCardFilter(filterType);
     if (filterType == CarServiceConstants.ALL_REPAIR_CARDS_FILTER_TYPE)
     {
         filter.VinChassis = this.VinChassisAllRepairCardsTxt.Text;
     }
     else if (filterType == CarServiceConstants.FINISHED_REPAIR_CARDS_FILTER_TYPE)
     {
         DateTime? fromFinishRepairDate = null;
         bool validFromFinishRepairDate = false;
         string fromFinishDateTxt = this.fromFinishRepairDate.SelectedDate;
         if (string.IsNullOrEmpty(fromFinishDateTxt) == false)
         {
             DateTime fromFinishRepairDateValue = DateTime.Now;
             validFromFinishRepairDate = CarServiceUtility.IsValidDate(fromFinishDateTxt, out fromFinishRepairDateValue);
             if (validFromFinishRepairDate == true)
             {
                 fromFinishRepairDate = fromFinishRepairDateValue;
             }
         }
         DateTime? toFinishRepairDate = null;
         bool validToFinishRepairDate = false;
         string toFinishRepairDateTxt = this.toFinishRepairDate.SelectedDate;
         if (string.IsNullOrEmpty(toFinishRepairDateTxt) == false)
         {
             DateTime toFinishRepairDateValue = DateTime.Now;
             validToFinishRepairDate = CarServiceUtility.IsValidDate(toFinishRepairDateTxt, out toFinishRepairDateValue);
             if (validToFinishRepairDate == true)
             {
                 toFinishRepairDate = toFinishRepairDateValue;
             }
         }
         if (validFromFinishRepairDate && validToFinishRepairDate)
         {
             filter.FromFinishRepair = fromFinishRepairDate.Value;
             filter.ToFinishRepair = toFinishRepairDate.Value;
         }
         else
         {
             if (validFromFinishRepairDate == false)
             {
                 CarServicePresentationUtility.AppendNotificationMsg("From finish repair date is not valid format", this.notificationMsgList);
             }
             if (validToFinishRepairDate == false)
             {
                 CarServicePresentationUtility.AppendNotificationMsg("To finish repair date is not valid format", this.notificationMsgList);
             }
             CarServicePresentationUtility.ShowNotificationMsgList(this.notificationMsgList);
             return;
         }
     }
     else if (filterType == CarServiceConstants.UNFINISHED_REPAIR_CARDS_FILTER_TYPE)
     {
         bool validDate = false;
         string startRepairDateTxt = this.startRepairDate.SelectedDate;
         if (string.IsNullOrEmpty(startRepairDateTxt) == false)
         {
             DateTime startRepairDateValue = DateTime.Now;
             validDate = CarServiceUtility.IsValidDate(startRepairDateTxt, out startRepairDateValue);
             if (validDate == true)
             {
                 filter.StartRepair = startRepairDateValue;
             }
         }
         if (validDate == false)
         {
             CarServicePresentationUtility.AppendNotificationMsg("Start repair date is not valid format", this.notificationMsgList);
             CarServicePresentationUtility.ShowNotificationMsgList(this.notificationMsgList);
             return;
         }
         filter.VinChassis = this.VinChassisTxt.Text;
     }
     ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR] = SortDirection.Ascending;
     ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR] = CarServiceConstants.REPAIR_CARD_ID_SORT_EXPRESSION;
     Session[CarServiceConstants.REPAIR_CARDS_FILTER_SESSION_ATTR_NAME] = filter;
     IQueryable<RepairCard> customRepairCards = FilterRepairCards(filter);
     BindRepairCardsGrid(customRepairCards);
 }
Пример #2
0
 private IQueryable<RepairCard> FilterRepairCards(RepairCardFilter filter)
 {
     IQueryable<RepairCard> repairCards = null;
     int filterType = filter.Type;
     switch (filterType)
     {
         case CarServiceConstants.ALL_REPAIR_CARDS_FILTER_TYPE:
             repairCards = FilterRepairCards(filter.VinChassis);
             break;
         case CarServiceConstants.UNFINISHED_REPAIR_CARDS_FILTER_TYPE:
             repairCards = FilterUnfinishedRepairCards(filter.StartRepair, filter.VinChassis);
             break;
         case CarServiceConstants.FINISHED_REPAIR_CARDS_FILTER_TYPE:
             repairCards = FilterFinishedRepairCards(filter.FromFinishRepair, filter.ToFinishRepair);
             break;
     }
     return repairCards;
 }