예제 #1
0
파일: Location.cs 프로젝트: HedinRakot/KVS
        /// <summary>
        /// Loescht den aktuellen Standort
        /// </summary>
        /// <param name="dbContext">DB Kontext</param>
        /// <param name="lc">Standtort Objekt</param>
        public static void ChangeLocations(DataClasses1DataContext dbContext, Location lc)
        {
            var changeAddress = dbContext.Adress.FirstOrDefault(q => q.Id != lc.AdressId);

            var tempId = lc.AdressId;
            var tempIA = lc.InvoiceAdressId;
            var tempIDA = lc.InvoiceDispatchAdressId;
            if (changeAddress != null)
            {
                lc.AdressId = changeAddress.Id;
                lc.InvoiceAdressId = null;
                lc.InvoiceDispatchAdressId = null;
            }
            else
            {
                throw new Exception("Das löschen vom Standort " + lc.Name + "  ist aus Refernzierungsgründen nicht möglich, bitte legen Sie Datensatz an bei dem mind. eine neue Adresse erstellt wird");
            }

            var changeCustomer = dbContext.LargeCustomer.FirstOrDefault(q => q.CustomerId == lc.CustomerId && q.MainLocationId == lc.Id);

               // tempId = lc.CustomerId.Value;

            if (changeCustomer != null )
            {
                changeCustomer.Customer._dbContext = dbContext;
                lc._dbContext = dbContext;
                changeCustomer.Location1= null;
            }

            lc.LogDBContext = dbContext;
            //if (changeCustomer != null)
            //{
                //changeCustomer.LogDBContext = dbContext;
                lc.Name = lc.Name + "_" + DateTime.Now.Ticks;
                dbContext.SubmitChanges();
                //lc.CustomerId = changeCustomer.CustomerId;

                lc.CustomerId = null;
            //}
            //else
            //{
            //    throw new Exception("Das löschen vom Standort " + lc.Name + "  ist aus Refernzierungsgründen nicht möglich, bitte legen Sie Datensatz an bei dem mind. ein neuer Kunde erstellt wird");
            //}
            //Adress.DeleteAdress(tempId, dbContext);

            if (tempIA != null)
                Adress.DeleteAdress(tempIA.Value, dbContext);

            if (tempIDA != null)
                Adress.DeleteAdress(tempIDA.Value, dbContext);

            dbContext.SubmitChanges();
        }
예제 #2
0
        /// <summary>
        /// Fügt dem Grosskunden einen neuen Standort hinzu.
        /// </summary>
        /// <param name="name">Name des Standorts.</param>
        /// <param name="street">Straße des Standorts.</param>
        /// <param name="streetnumber">Hausnummer des Standorts.</param>
        /// <param name="zipcode">Postleitzahl des Standorts.</param>
        /// <param name="city">Ort des Standorts.</param>
        /// <param name="country">Land des Standorts.</param>
        /// <param name="phone">Telefonnummer des Standorts.</param>
        /// <param name="fax">Faxnummer des Standorts.</param>
        /// <param name="mobilephone">Mobiltelefonnummer des Standorts.</param>
        /// <param name="email">Emailadresse des Standorts.</param>        
        /// <param name="vat">Mehrwertsteuersatz für den Standort.</param>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <returns>Den neuen Standort.</returns>
        public Location AddNewLocation(string name, string street, string streetnumber, string zipcode, string city, string country, string phone, string fax, string mobilephone, string email, decimal? vat, DataClasses1DataContext dbContext)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("Der Name des Standorts darf nicht leer sein.");
            }

            if (this.Location.Any(q => q.Name == name))
            {
                throw new Exception("Der Kunde " + this.Customer.Name + " besitzt bereits einen Standort mit Namen " + name + ".");
            }

            Location location = new Location()
            {
                Name = name,
                Adress = new Adress()
                {
                    Zipcode = zipcode,
                    Country = country,
                    City = city,
                    StreetNumber = streetnumber,
                    Street = street
                },
                Contact = new Contact()
                {
                    Email = email,
                    MobilePhone = mobilephone,
                    Fax = fax,
                    Phone = phone
                },
                VAT = vat
            };
            location._dbContext = dbContext;
            this.Location.Add(location);

            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Neuer Standort " + name + " angelegt.", LogTypes.INSERT, this.CustomerId, "Customer", location.Id);
            return location;
        }
예제 #3
0
		private void detach_Location2(Location entity)
		{
			this.SendPropertyChanging();
			entity.InvoiceDispatchAdress = null;
		}
예제 #4
0
 protected void DeclareInvoiceSendAdress(Location createdLocation)
 {
     DataClasses1DataContext dbContext = new DataClasses1DataContext(((Guid)Session["CurrentUserId"]));
     if (chbLocationRechnungsaderesse.Checked == false)
     {
         var newInvoiceAdress = Adress.CreateAdress(txbLocationInvoiceAdressStreet.Text,
                                                    txbLocationInvoiceAdressStreetNr.Text,
                                                    cmbLocationInvoiceZip.Text,
                                                    cmbLocationCityInvoice.Text,
                                                    cmbLocationInvoiceCountry.Text,
                                                    dbContext);
         createdLocation.InvoiceAdress = newInvoiceAdress;
     }
     else if (chbLocationRechnungsaderesse.Checked == true)
     {
         createdLocation.InvoiceAdress = createdLocation.Adress;
     }
     if (chbLocationVersandadresse.Checked == false)
     {
         var newInvoiceAdress = Adress.CreateAdress(txbLocationSendAdressStreet.Text,
                                                    txbLocationSendAdressStreetNr.Text,
                                                    cmbLocationSendZip.Text,
                                                    cmbLocationCitySend.Text,
                                                    cmbLocationSendCountry.Text, dbContext);
         createdLocation.InvoiceDispatchAdress = newInvoiceAdress;
     }
     else if (chbLocationVersandadresse.Checked == true && chbLocationRechnungsaderesse.Checked == true)
     {
         createdLocation.InvoiceDispatchAdress = createdLocation.Adress;
     }
     else if (chbLocationRechnungsaderesse.Checked == false && chbLocationVersandadresse.Checked == true)
     {
         createdLocation.InvoiceDispatchAdress = createdLocation.InvoiceAdress;
     }
 }
예제 #5
0
		private void detach_Location(Location entity)
		{
			this.SendPropertyChanging();
			entity.Adress = null;
		}
예제 #6
0
		private void attach_Location1(Location entity)
		{
			this.SendPropertyChanging();
			entity.InvoiceAdress = this;
		}
예제 #7
0
 partial void DeleteLocation(Location instance);
예제 #8
0
 partial void UpdateLocation(Location instance);
예제 #9
0
 partial void InsertLocation(Location instance);
예제 #10
0
		private void attach_Location(Location entity)
		{
			this.SendPropertyChanging();
			entity.Contact = this;
		}
예제 #11
0
		private void detach_Location(Location entity)
		{
			this.SendPropertyChanging();
			entity.LargeCustomer = null;
		}