Пример #1
0
        public static bool ProcessStartRepairDate(string startRepairDateTxt, BulletedList notificationMsgList,
                                                  out DateTime?startRepairDate)
        {
            startRepairDate = null;
            bool validStartRepairDate = string.IsNullOrEmpty(startRepairDateTxt) == false;

            if (validStartRepairDate == false)
            {
                CarServicePresentationUtility.AppendNotificationMsg("Start repair date is required", notificationMsgList);
            }
            else
            {
                DateTime startRepairDateValue = DateTime.Now;
                validStartRepairDate = CarServiceUtility.IsValidDate(startRepairDateTxt, out startRepairDateValue);
                if (validStartRepairDate == true)
                {
                    startRepairDate = startRepairDateValue;
                }
                else
                {
                    CarServicePresentationUtility.AppendNotificationMsg("Start repair date is not in valid format", notificationMsgList);
                }
            }
            return(validStartRepairDate);
        }
Пример #2
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);
        }