Inheritance: System.Data.Objects.DataClasses.EntityObject
コード例 #1
0
 public static void AddSpareParts(RepairCard repairCard, ListItemCollection selectedSparePartItems, 
     ICarServicePersister persister)
 {
     repairCard.SpareParts.Clear();
     foreach (ListItem item in selectedSparePartItems)
     {
         int sparePartId;
         if (Int32.TryParse(item.Value, out sparePartId))
         {
             SparePart sparePart = persister.GetSparePartById(sparePartId);
             if (sparePart != null)
             {
                 repairCard.SpareParts.Add(sparePart);
             }
         }
     }
 }
コード例 #2
0
 private void UpdateRepairCard(RepairCard repairCard, Automobile automobile, DateTime? finishRepairDate, 
     string description, decimal sparePartsPrice, decimal repairPrice, ListItemCollection sparePartItems)
 {
     repairCard.Automobile = automobile;
     repairCard.Description = (string.IsNullOrEmpty(description) ? null : description);
     repairCard.FinishRepair = finishRepairDate;
     repairCard.PartPrice = sparePartsPrice;
     repairCard.CardPrice = repairPrice;
     CarServicePresentationUtility.AddSpareParts(repairCard, sparePartItems, this.persister);
     this.persister.SaveChanges();
 }
コード例 #3
0
 private void SaveRepairCard(Automobile automobile, DateTime startRepairDate, string description, 
     decimal sparePartsPrice, decimal repairPrice, ListItemCollection sparePartItems)
 {
     MembershipUser currentUser = Membership.GetUser();
     RepairCard newRepairCard = new RepairCard()
     {
         Automobile = automobile,
         UserId = ((System.Guid)currentUser.ProviderUserKey),
         StartRepair = startRepairDate,
         Description = (string.IsNullOrEmpty(description) ? null : description),
         PartPrice = sparePartsPrice,
         CardPrice = repairPrice
     };
     CarServicePresentationUtility.AddSpareParts(newRepairCard, sparePartItems, this.persister);
     this.persister.CreateRepairCard(newRepairCard);
     this.persister.SaveChanges();
 }
コード例 #4
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;
        }
コード例 #5
0
 public void DeleteRepairCard(RepairCard repairCard)
 {
     this.carServiceEntities.RepairCards.DeleteObject(repairCard);
 }
コード例 #6
0
 public void CreateRepairCard(RepairCard repairCard)
 {
     this.carServiceEntities.RepairCards.AddObject(repairCard);
 }
コード例 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the RepairCards EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRepairCards(RepairCard repairCard)
 {
     base.AddObject("RepairCards", repairCard);
 }
コード例 #8
0
 /// <summary>
 /// Create a new RepairCard object.
 /// </summary>
 /// <param name="cardId">Initial value of the CardId property.</param>
 /// <param name="automobileId">Initial value of the AutomobileId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="startRepair">Initial value of the StartRepair property.</param>
 /// <param name="partPrice">Initial value of the PartPrice property.</param>
 /// <param name="cardPrice">Initial value of the CardPrice property.</param>
 public static RepairCard CreateRepairCard(global::System.Int32 cardId, global::System.Int32 automobileId, global::System.Guid userId, global::System.DateTime startRepair, global::System.Decimal partPrice, global::System.Decimal cardPrice)
 {
     RepairCard repairCard = new RepairCard();
     repairCard.CardId = cardId;
     repairCard.AutomobileId = automobileId;
     repairCard.UserId = userId;
     repairCard.StartRepair = startRepair;
     repairCard.PartPrice = partPrice;
     repairCard.CardPrice = cardPrice;
     return repairCard;
 }