Exemplo n.º 1
0
        /// <summary>
        /// Erstellt einen Abmeldeauftrag.
        /// </summary>
        /// <param name="userId">Id des Benutzers, der den Auftrag anlegt.</param>
        /// <param name="customerId">Id des Kunden.</param>
        /// <param name="vehicleId">Id des Fahrzeugs.</param>
        /// <param name="registrationId">Id der Zulassung.</param>
        /// <param name="locationId">Id des Kundenstandorts.</param>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <returns>Den neuen Abmeldeauftrag.</returns>
        /// <remarks>Erstellt auch gleichzeitig den Order-Datensatz.</remarks>
        public static DeregistrationOrder CreateDeregistrationOrder(int userId, int customerId, Vehicle vehicle, Registration registration, int? locationId, 
            int zulassungsstelleId, DataClasses1DataContext dbContext)
        {
            var orderTypeId = dbContext.OrderType.Single(q => q.Id == (int)OrderTypes.Cancellation).Id;
            Order order = Order.CreateOrder(userId, customerId, orderTypeId, zulassungsstelleId, dbContext);
            order.LocationId = locationId;
            DeregistrationOrder deregistrationOrder = new DeregistrationOrder()
            {
                Order = order,
                Vehicle = vehicle,
                Registration = registration
            };

            dbContext.DeregistrationOrder.InsertOnSubmit(deregistrationOrder);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Abmeldeauftrag angelegt.", LogTypes.INSERT, deregistrationOrder.OrderNumber, "DeregistrationOrder", vehicle.Id);
            return deregistrationOrder;
        }
 protected void MakeInvoiceForSmallCustomer(int customerId, DeregistrationOrder regOrder)
 {
     try
     {
         DataClasses1DataContext dbContext = new DataClasses1DataContext(Int32.Parse(Session["CurrentUserId"].ToString()));
         var newOrder = dbContext.Order.Single(q => q.CustomerId == customerId && q.OrderNumber == regOrder.OrderNumber);
         smallCustomerOrderHiddenField.Value = regOrder.OrderNumber.ToString();
         //updating order status
         newOrder.LogDBContext = dbContext;
         newOrder.Status = (int)OrderStatusTypes.Closed;
         //updating orderitems status
         foreach (OrderItem ordItem in newOrder.OrderItem)
         {
             ordItem.LogDBContext = dbContext;
             if (ordItem.Status != (int)OrderItemStatusTypes.Cancelled)
             {
                 ordItem.Status = (int)OrderItemStatusTypes.Closed;
             }
         }
         dbContext.SubmitChanges();
         //updating order und items status one more time to make it abgerechnet
         newOrder.LogDBContext = dbContext;
         newOrder.Status = (int)OrderStatusTypes.Payed;
         dbContext.SubmitChanges();
         //opening window for adress
         string script = "function f(){$find(\"" + AddAdressRadWindow.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
         SetValuesForAdressWindow();
     }
     catch (Exception ex)
     {
         ErrorLeereTextBoxenLabel.Text = "Error: " + ex.Message;
         ErrorLeereTextBoxenLabel.Visible = true;
     }
 }
        protected bool AddAnotherProducts(DeregistrationOrder deRegOrd, int? locationId)
        {
            bool allesHatGutGelaufen = false;
            string ProduktId = "";
            string CostCenterId = "";
            int skipFirst = 0;
            foreach (RadTreeNode node in DienstleistungTreeView.Nodes)
            {
                if (skipFirst > 0)
                {
                    if (!String.IsNullOrEmpty(node.Value))
                    {
                        string[] splited = node.Value.Split(';');
                        if (splited.Length == 2)
                        {
                            try
                            {
                                DataClasses1DataContext dbContext = new DataClasses1DataContext(Int32.Parse(Session["CurrentUserId"].ToString()));
                                var orderNumber = deRegOrd.OrderNumber;
                                Price newPrice;
                                OrderItem newOrderItem1 = null;
                                OrderItem newOrderItem2 = null;
                                ProduktId = splited[0];
                                CostCenterId = splited[1];
                                if (!String.IsNullOrEmpty(ProduktId))
                                {
                                    var productId = Int32.Parse(ProduktId);
                                    int? costCenterId = null;
                                    KVSCommon.Database.Product newProduct = dbContext.Product.SingleOrDefault(q => q.Id == productId);
                                    if (RadComboBoxCustomer.SelectedIndex == 1 || locationId == null) //small
                                    {
                                        newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == null);
                                    }
                                    else //large
                                    {
                                        costCenterId = Int32.Parse(CostCenterId);
                                        newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == locationId);
                                        if (newPrice == null)
                                            newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == null);
                                    }
                                    var orderToUpdate = dbContext.Order.SingleOrDefault(q => q.OrderNumber == orderNumber);
                                    orderToUpdate.LogDBContext = dbContext;
                                    if (orderToUpdate != null)
                                    {
                                        if (RadComboBoxCustomer.SelectedIndex == 1)
                                        {
                                            newOrderItem1 = orderToUpdate.AddOrderItem(newProduct.Id, newPrice.Amount, 1, null, null, false, dbContext);
                                            if (newPrice.AuthorativeCharge.HasValue)
                                            {
                                                orderToUpdate.AddOrderItem(newProduct.Id, newPrice.AuthorativeCharge.Value, 1, null, newOrderItem1.Id, newPrice.AuthorativeCharge.HasValue, dbContext);
                                            }
                                        }
                                        else
                                        {

                                            CostCenter costCenter = null;
                                            if (costCenterId.HasValue)
                                            {
                                                costCenter = dbContext.CostCenter.FirstOrDefault(o => o.Id == costCenterId.Value);
                                            }

                                            newOrderItem1 = orderToUpdate.AddOrderItem(newProduct.Id, newPrice.Amount, 1, costCenter, null, false, dbContext);
                                            if (newPrice.AuthorativeCharge.HasValue)
                                            {
                                                orderToUpdate.AddOrderItem(newProduct.Id, newPrice.AuthorativeCharge.Value, 1, costCenter, newOrderItem1.Id, newPrice.AuthorativeCharge.HasValue, dbContext);
                                            }
                                        }
                                        dbContext.SubmitChanges();
                                        allesHatGutGelaufen = true;
                                    }
                                }
                                if (allesHatGutGelaufen)
                                    dbContext.SubmitChanges();
                            }
                            catch (Exception ex)
                            {
                                return false;
                            }
                        }
                    }
                }
                else
                {
                    skipFirst = 1;
                }
            }
            return allesHatGutGelaufen;
        }
Exemplo n.º 4
0
 protected void AddAnotherProducts(DeregistrationOrder regOrd, Guid? locationId)
 {
     string ProduktId = "";
     int itemIndexValue = 0;
     decimal amount = 0;
     decimal authCharge = 0;
     var nodes = this.Request.Form.AllKeys.Where(q => q.Contains("txtItemPrice_"));
     foreach (var node in nodes)
     {
         if (!String.IsNullOrEmpty(node))
         {
             DataClasses1DataContext dbContext = new DataClasses1DataContext(new Guid(Session["CurrentUserId"].ToString()));
             Guid orderId = regOrd.OrderId;
             Price newPrice = null;
             OrderItem newOrderItem1 = null;
             ProduktId = node.Split('_')[1];
             if (!String.IsNullOrEmpty(ProduktId))
             {
                 Guid productId = new Guid(ProduktId);
                 Guid costCenterId = Guid.Empty;
                 KVSCommon.Database.Product newProduct = dbContext.Product.SingleOrDefault(q => q.Id == productId);
                 if (locationId == null) //small
                 {
                     newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == null);
                 }
                 var orderToUpdate = dbContext.Order.SingleOrDefault(q => q.Id == orderId);
                 orderToUpdate.LogDBContext = dbContext;
                 if (orderToUpdate != null)
                 {
                     if (this.Request.Form.GetValues(node) != null)
                     {
                         string itemPrice = this.Request.Form.GetValues(node)[0];
                         if (EmptyStringIfNull.IsNumber(itemPrice))
                         {
                             amount = Convert.ToDecimal(itemPrice.Replace('.', ','));
                         }
                         else if (itemPrice == "")
                         {
                             amount = 0;
                         }
                         else
                         {
                             amount = newPrice.Amount;
                         }
                     }
                     else
                     {
                         amount = newPrice.Amount;
                     }
                     newOrderItem1 = orderToUpdate.AddOrderItem(newProduct.Id, amount, 1, null, null, false, dbContext);
                     if (newPrice.AuthorativeCharge.HasValue)
                     {
                         if (this.Request.Form.GetValues(node.Replace("txtItemPrice_", "txtAuthPrice_")) != null)
                         {
                             string itemPrice = this.Request.Form.GetValues(node.Replace("txtItemPrice_", "txtAuthPrice_"))[0];
                             if (EmptyStringIfNull.IsNumber(itemPrice))
                             {
                                 amount = Convert.ToDecimal(itemPrice.Replace('.', ','));
                             }
                             else if (itemPrice == "")
                             {
                                 amount = 0;
                             }
                             else
                             {
                                 amount = newPrice.AuthorativeCharge.Value;
                             }
                         }
                         else
                         {
                             amount = newPrice.AuthorativeCharge.Value;
                         }
                         orderToUpdate.AddOrderItem(newProduct.Id, amount, 1, null, newOrderItem1.Id, newPrice.AuthorativeCharge.HasValue, dbContext);
                     }
                     itemIndexValue = itemIndexValue + 1;
                     dbContext.SubmitChanges();
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 protected bool AddAnotherProducts(DeregistrationOrder deRegOrd, Guid? locationId)
 {
     bool allesHatGutGelaufen = false;
     string ProduktId = "";
     string CostCenterId = "";
     int skipFirst = 0;
     foreach (RadTreeNode node in DienstleistungTreeView.Nodes)
     {
         if (skipFirst > 0)
         {
             if (!String.IsNullOrEmpty(node.Value))
             {
                 string[] splited = node.Value.Split(';');
                 if (splited.Length == 2)
                 {
                     try
                     {
                         DataClasses1DataContext dbContext = new DataClasses1DataContext(new Guid(Session["CurrentUserId"].ToString()));
                         Guid orderId = deRegOrd.OrderId;
                         Price newPrice;
                         OrderItem newOrderItem1 = null;
                         OrderItem newOrderItem2 = null;
                         ProduktId = splited[0];
                         CostCenterId = splited[1];
                         if (!String.IsNullOrEmpty(ProduktId))
                         {
                             Guid productId = new Guid(ProduktId);
                             Guid costCenterId = Guid.Empty;
                             KVSCommon.Database.Product newProduct = dbContext.Product.SingleOrDefault(q => q.Id == productId);
                                 costCenterId = new Guid(CostCenterId);
                                 newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == locationId);
                                 if (newPrice == null)
                                     newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == null);
                             var orderToUpdate = dbContext.Order.SingleOrDefault(q => q.Id == orderId);
                             orderToUpdate.LogDBContext = dbContext;
                             if (orderToUpdate != null)
                             {
                                     newOrderItem1 = orderToUpdate.AddOrderItem(newProduct.Id, newPrice.Amount, 1, costCenterId, null, false, dbContext);
                                     if (newPrice.AuthorativeCharge.HasValue)
                                     {
                                         orderToUpdate.AddOrderItem(newProduct.Id, newPrice.AuthorativeCharge.Value, 1, costCenterId, newOrderItem1.Id, newPrice.AuthorativeCharge.HasValue, dbContext);
                                     }
                                 dbContext.SubmitChanges();
                                 allesHatGutGelaufen = true;
                             }
                         }
                         if (allesHatGutGelaufen)
                             dbContext.SubmitChanges();
                     }
                     catch
                     {
                         return false;
                     }
                 }
             }
         }
         else
         {
             skipFirst = 1;
         }
     }
     return allesHatGutGelaufen;
 }
Exemplo n.º 6
0
		private void detach_DeregistrationOrder(DeregistrationOrder entity)
		{
			this.SendPropertyChanging();
			entity.Vehicle = null;
		}
Exemplo n.º 7
0
		private void attach_DeregistrationOrder(DeregistrationOrder entity)
		{
			this.SendPropertyChanging();
			entity.Registration = this;
		}
Exemplo n.º 8
0
 partial void DeleteDeregistrationOrder(DeregistrationOrder instance);
Exemplo n.º 9
0
 partial void UpdateDeregistrationOrder(DeregistrationOrder instance);
Exemplo n.º 10
0
 partial void InsertDeregistrationOrder(DeregistrationOrder instance);
Exemplo n.º 11
0
 private static void AddAnotherProducts(DeregistrationOrder deRegOrd, Guid? locationId, DeregistrationAbmeldungHeader ProductCostCenterListHeader, Guid currentUserId)
 {
     bool allesHatGutGelaufen = false;
     string ProduktId = "";
     string CostCenterId = "";
     int skipFirst = 0;
     foreach (var productCostCenterPair in ProductCostCenterListHeader.ProductCostCenterList)
     {
         if (skipFirst > 0)
         {
             if (!String.IsNullOrEmpty(productCostCenterPair.ProductId) && !String.IsNullOrEmpty(productCostCenterPair.CostCenterId))
             {
                 try
                 {
                     DataClasses1DataContext dbContext = new DataClasses1DataContext(currentUserId);
                     Guid orderId = deRegOrd.OrderId;
                     Price newPrice;
                     OrderItem newOrderItem1 = null;
                     ProduktId = productCostCenterPair.ProductId;
                     CostCenterId = productCostCenterPair.CostCenterId;
                     if (!String.IsNullOrEmpty(ProduktId))
                     {
                         Guid productId = new Guid(ProduktId);
                         Guid costCenterId = Guid.Empty;
                         KVSCommon.Database.Product newProduct = dbContext.Product.SingleOrDefault(q => q.Id == productId);
                         if (locationId == null) //small
                         {
                             newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == null);
                         }
                         else //large
                         {
                             costCenterId = new Guid(CostCenterId);
                             newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == locationId);
                             if (newPrice == null)
                                 newPrice = dbContext.Price.SingleOrDefault(q => q.ProductId == newProduct.Id && q.LocationId == null);
                         }
                         var orderToUpdate = dbContext.Order.SingleOrDefault(q => q.Id == orderId);
                         orderToUpdate.LogDBContext = dbContext;
                         if (orderToUpdate != null)
                         {
                             newOrderItem1 = orderToUpdate.AddOrderItem(newProduct.Id, newPrice.Amount, 1, costCenterId, null, false, dbContext);
                             if (newPrice.AuthorativeCharge.HasValue)
                             {
                                 orderToUpdate.AddOrderItem(newProduct.Id, newPrice.AuthorativeCharge.Value, 1, costCenterId, newOrderItem1.Id, newPrice.AuthorativeCharge.HasValue, dbContext);
                             }
                             dbContext.SubmitChanges();
                             allesHatGutGelaufen = true;
                         }
                     }
                     if (allesHatGutGelaufen)
                         dbContext.SubmitChanges();
                 }
                 catch (Exception ex)
                 {
                     throw new Exception(ex.Message);
                 }
             }
         }
         else
         {
             skipFirst = 1;
         }
     }
 }