Exemplo n.º 1
0
        protected void CancelAuto_OnClick(object sender, EventArgs e)
        {
            CarServiceUtility.ClearSessionAttributes(Session);
            string continueUrl = "~/Members/Cars/Cars.aspx";

            Response.Redirect(continueUrl);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        protected void SaveRepairCard_OnClick(object sender, EventArgs e)
        {
            CarServicePresentationUtility.ClearNotificationMsgList(this.notificationMsgList);
            CarServicePresentationUtility.HideNotificationMsgList(this.notificationMsgList);
            this.notificationMsgList.CssClass = CarServiceConstants.NEGATIVE_CSS_CLASS_NAME;

            DateTime?startRepairDate      = null;
            string   startRepairDateTxt   = this.startRepairDate.SelectedDate;
            bool     validStartRepairDate = CarServicePresentationUtility.ProcessStartRepairDate(startRepairDateTxt,
                                                                                                 this.notificationMsgList, out startRepairDate);

            decimal sparePartsPrice    = 0M;
            decimal repairPrice        = 0M;
            string  repairPriceTxt     = this.repairPrice.Text;
            string  sparePartsPriceTxt = this.sparePartsPrice.Text;
            bool    validPrices        = CarServicePresentationUtility.ProcessRepairPrices(sparePartsPriceTxt, repairPriceTxt,
                                                                                           this.notificationMsgList, out sparePartsPrice, out repairPrice);

            string     automobileIdTxt   = this.automobileDropDown.SelectedValue;
            Automobile automobile        = CarServiceUtility.GetAutomobile(automobileIdTxt, this.persister);
            bool       validAutomobileId = (automobile != null);

            ListItemCollection selectedSparePartItems = this.selectedSpareParts.Items;
            bool validSpareParts = CarServicePresentationUtility.IsSparePartItemsValid(selectedSparePartItems, this.notificationMsgList);

            if (validAutomobileId && validPrices && validSpareParts &&
                (validStartRepairDate && startRepairDate.HasValue))
            {
                string description        = this.repairCardDescription.Text;
                object repairCardIdObject = Session[CarServiceConstants.REPAIR_CARD_ID_PARAM_NAME];
                if (repairCardIdObject != null)
                {
                    int repairCardId;
                    if (Int32.TryParse(repairCardIdObject.ToString(), out repairCardId))
                    {
                        DateTime?finishRepairDate      = null;
                        string   finishRepairDateTxt   = this.finishRepairDate.SelectedDate;
                        bool     validFinishRepairDate = CarServicePresentationUtility.ProcessFinishRepairDate(finishRepairDateTxt,
                                                                                                               this.notificationMsgList, out finishRepairDate);
                        if (validFinishRepairDate == true)
                        {
                            RepairCard repairCard = this.persister.GetRepairCardById(repairCardId);
                            UpdateRepairCard(repairCard, automobile, finishRepairDate, description,
                                             sparePartsPrice, repairPrice, selectedSparePartItems);
                            CarServicePresentationUtility.AppendNotificationMsg("Repair card is updated successfully", this.notificationMsgList);
                            this.notificationMsgList.CssClass = CarServiceConstants.POSITIVE_CSS_CLASS_NAME;
                        }
                    }
                }
                else
                {
                    SaveRepairCard(automobile, startRepairDate.Value, description,
                                   sparePartsPrice, repairPrice, selectedSparePartItems);
                    CarServicePresentationUtility.AppendNotificationMsg("Repair card is saved successfully", this.notificationMsgList);
                    this.notificationMsgList.CssClass = CarServiceConstants.POSITIVE_CSS_CLASS_NAME;
                }
            }
            CarServicePresentationUtility.ShowNotificationMsgList(this.notificationMsgList);
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (persister == null)
     {
         persister = new CarServicePersister();
     }
     if (IsPostBack == false)
     {
         CarServiceUtility.ClearSessionAttributes(Session);
         BindAutomobilesGrid();
     }
 }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (persister == null)
     {
         this.persister = new CarServicePersister();
     }
     if (IsPostBack == false)
     {
         BindRepairCardsGrid();
         CarServiceUtility.ClearSessionAttributes(Session);
         this.notificationMsgList.CssClass = CarServiceConstants.NEGATIVE_CSS_CLASS_NAME;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Moves spare part items from source list box to destination list box.
        /// </summary>
        /// <param name="srcListBox">Source list box to be specified</param>
        /// <param name="destListBox">Destination list box to be specified</param>
        /// <param name="srcPriceCalculation">True - adds prices of selected spare parts, false - doesn't add prices of selected spare parts</param>
        /// <param name="persister">Persister to be specified</param>
        /// <param name="totalPrice">Stores total price of selected spare parts</param>
        public static void MoveListItems(ListBox srcListBox, ListBox destListBox,
                                         bool srcPriceCalculation, ICarServicePersister persister, out decimal totalPrice)
        {
            totalPrice = 0M;
            int[] srcSelectedIndices          = srcListBox.GetSelectedIndices();
            ListItemCollection destListItems  = destListBox.Items;
            int        totalNumberOfDestItems = destListItems.Count + srcSelectedIndices.Length;
            List <int> destItemValues         = new List <int>(totalNumberOfDestItems);

            foreach (ListItem item in destListItems)
            {
                CarServiceUtility.AddEntityId(destItemValues, item.Value);
            }
            foreach (int selectedIndex in srcSelectedIndices)
            {
                ListItem item = srcListBox.Items[selectedIndex];
                CarServiceUtility.AddEntityId(destItemValues, item.Value);
            }
            BindSparePartsLists(destItemValues, srcListBox, destListBox, srcPriceCalculation, persister, out totalPrice);
        }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack == false)
     {
         string userId = Request.QueryString[CarServiceConstants.USER_ID_REQUEST_PARAM_NAME];
         Guid   userProviderKey;
         if (CarServiceUtility.GuidTryParse(userId, out userProviderKey) == true)
         {
             MembershipUser user = Membership.GetUser(userProviderKey);
             if (user != null)
             {
                 this.UserName.Text            = user.UserName;
                 this.Email.Text               = user.Email;
                 this.UserActive.SelectedValue = (user.IsApproved ?
                                                  CarServiceConstants.ACTIVE_STATUS.ToString() : CarServiceConstants.INACTIVE_STATUS.ToString());
                 ProfileCommon userProfile = Profile.GetProfile(user.UserName);
                 this.FirstName.Text = userProfile.FirstName;
                 this.LastName.Text  = userProfile.LastName;
             }
         }
     }
 }
Exemplo n.º 8
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);
        }