コード例 #1
0
        private void LoadRepairCardInfo(RepairCard repairCard)
        {
            this.repairCardIdLbl.Text = repairCard.CardId.ToString();
            this.operatorLbl.Text     = repairCard.aspnet_Users.UserName;
            List <Automobile> automobiles = new List <Automobile>();

            automobiles.Add(repairCard.Automobile);
            var customAutomobileFormat =
                from auto in automobiles
                select new
            {
                AutomobileId             = auto.AutomobileId,
                AutomobileRepresentation = auto.Vin + " / " + auto.ChassisNumber
            };

            this.automobileDropDown.DataSource = customAutomobileFormat;
            this.automobileDropDown.DataBind();

            this.sparePartsPrice.Text = repairCard.PartPrice.ToString();
            this.repairPrice.Text     = repairCard.CardPrice.ToString();

            CultureInfo englishCultureInfo = new CultureInfo(CarServiceConstants.ENGLISH_CULTURE_INFO);

            this.startRepairDate.SelectedDate = repairCard.StartRepair.ToString(CarServiceConstants.DATE_FORMAT, englishCultureInfo);
            DateTime?finishRepairDate = repairCard.FinishRepair;

            if (finishRepairDate.HasValue)
            {
                this.finishRepairDate.SelectedDate = finishRepairDate.Value.ToString(CarServiceConstants.DATE_FORMAT, englishCultureInfo);
                DisableAllInputControls();
            }
            else
            {
                this.finishRepairDate.Enabled = true;
            }
            EntityCollection <SparePart> selectedParts    = repairCard.SpareParts;
            List <SparePart>             unselectedParts  = new List <SparePart>();
            IQueryable <SparePart>       activeSpareParts = this.persister.GetActiveSpareParts();

            foreach (SparePart part in activeSpareParts)
            {
                if (selectedParts.Contains(part) == false)
                {
                    unselectedParts.Add(part);
                }
            }
            object customUnselectedSpareParts = CarServicePresentationUtility.GetSparePartsFormatForListBox(unselectedParts);
            object customSelectedSpareParts   = CarServicePresentationUtility.GetSparePartsFormatForListBox(selectedParts);

            CarServicePresentationUtility.BindListBox(this.unselectedSpareParts, customUnselectedSpareParts);
            CarServicePresentationUtility.BindListBox(this.selectedSpareParts, customSelectedSpareParts);
            this.repairCardDescription.Text = repairCard.Description;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.persister == null)
            {
                this.persister = new CarServicePersister();
            }
            if (IsPostBack == false)
            {
                this.finishRepairDate.Enabled = false;
                object repairCardIdObject = Session[CarServiceConstants.REPAIR_CARD_ID_PARAM_NAME];
                if (repairCardIdObject != null)
                {
                    int repairCardId;
                    if (Int32.TryParse(repairCardIdObject.ToString(), out repairCardId))
                    {
                        RepairCard repairCard = this.persister.GetRepairCardById(repairCardId);
                        LoadRepairCardInfo(repairCard);

                        Guid           creatorUserId = repairCard.UserId;
                        MembershipUser currentUser   = Membership.GetUser();
                        Guid           currentUserId = (Guid)currentUser.ProviderUserKey;
                        if (currentUserId.Equals(creatorUserId) == false)
                        {
                            DisableAllInputControls();
                        }
                        else
                        {
                            this.startRepairDate.Enabled = false;
                        }
                    }
                }
                else
                {
                    IQueryable <SparePart> spareParts = this.persister.GetActiveSpareParts();
                    object customSpareParts           = CarServicePresentationUtility.GetSparePartsFormatForListBox(spareParts);
                    CarServicePresentationUtility.BindListBox(this.unselectedSpareParts, customSpareParts);
                    this.startRepairDate.SelectedDate =
                        DateTime.Now.ToString(CarServiceConstants.DATE_FORMAT, new CultureInfo(CarServiceConstants.ENGLISH_CULTURE_INFO));
                    this.finishRepairDate.Enabled = false;
                    this.operatorLbl.Text         = this.User.Identity.Name;
                }
            }
            CarServicePresentationUtility.ClearNotificationMsgList(this.notificationMsgList);
            CarServicePresentationUtility.HideNotificationMsgList(this.notificationMsgList);
            Session[CarServiceConstants.AUTOMOBILE_ID_REQUEST_PARAM_NAME] = null;
        }