Beispiel #1
0
        internal static QuoteEntity GetQuoteDetails(string quoteNumber)
        {
            QuoteEntity quoteDetails = null;

            DataSet result = null;
            try
            {
                SqlParameter pQuoteNumber = new SqlParameter();
                pQuoteNumber.ParameterName = "QuoteNumber";
                pQuoteNumber.Value = quoteNumber;

                result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.GetQuoteDetails, pQuoteNumber);
                if (result == null || result.Tables == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
                {
                    return quoteDetails;
                }
                quoteDetails = new QuoteEntity();
                quoteDetails.Header = new QuoteHeader();
                quoteDetails.Header.CustomerPO = result.Tables[0].Rows[0][ColumnNames.CustomerPO].ToString();
                quoteDetails.Header.IsShipToOtherAddress = bool.Parse(result.Tables[0].Rows[0][ColumnNames.ShipToOtherAddress].ToString());
                quoteDetails.Header.LeadTimeID = int.Parse(result.Tables[0].Rows[0][ColumnNames.LeadTimeID].ToString());
                quoteDetails.Header.LeadTimeTypeID = int.Parse(result.Tables[0].Rows[0][ColumnNames.LeadTimeTypeID].ToString());
                quoteDetails.Header.QuoteCreatedOn = result.Tables[0].Rows[0][ColumnNames.CreatedOn].ToString();
                quoteDetails.Header.QuoteNumber = result.Tables[0].Rows[0][ColumnNames.QuoteNumber].ToString();
                quoteDetails.Header.QuoteRequestedOn = result.Tables[0].Rows[0][ColumnNames.RequestedShipDate].ToString();
                quoteDetails.Header.ShippingMethodID = int.Parse(result.Tables[0].Rows[0][ColumnNames.ShippingMethodID].ToString());
                quoteDetails.Header.OperatorName = result.Tables[0].Rows[0][ColumnNames.OperatorName].ToString();
                quoteDetails.Header.PaymentModeID = int.Parse(result.Tables[0].Rows[0][ColumnNames.PaymentModeID].ToString());
                quoteDetails.Header.QuoteStatusID = int.Parse(result.Tables[0].Rows[0][ColumnNames.QuoteStatusID].ToString());
                quoteDetails.Header.SalesOrderNumber = result.Tables[0].Rows[0][ColumnNames.SONumber].ToString();
                quoteDetails.Header.SaleOrderConfirmedOn = result.Tables[0].Rows[0][ColumnNames.ConfirmedDate].ToString();
                quoteDetails.Header.WorksheetNumber = result.Tables[0].Rows[0][ColumnNames.WSNumber].ToString();
                quoteDetails.Header.InvoiceNumber = result.Tables[0].Rows[0][ColumnNames.InvoiceNumber].ToString();
                quoteDetails.Header.InvoiceCompletedOn = result.Tables[0].Rows[0][ColumnNames.CompletedDate].ToString();

                quoteDetails.Header.BalanceDue = double.Parse(double.Parse(result.Tables[0].Rows[0][ColumnNames.BalanceDue].ToString()).ToString("0.00"));

                quoteDetails.Header.SoldTo = new CustomerDetails();
                quoteDetails.Header.SoldTo.FirstName = result.Tables[0].Rows[0][ColumnNames.SoldTo_FirstName].ToString();
                quoteDetails.Header.SoldTo.LastName = result.Tables[0].Rows[0][ColumnNames.SoldTo_LastName].ToString();
                quoteDetails.Header.SoldTo.Address = result.Tables[0].Rows[0][ColumnNames.SoldTo_Address].ToString();
                quoteDetails.Header.SoldTo.Email = result.Tables[0].Rows[0][ColumnNames.SoldTo_Email].ToString();
                quoteDetails.Header.SoldTo.Fax = result.Tables[0].Rows[0][ColumnNames.SoldTo_Fax].ToString();
                quoteDetails.Header.SoldTo.Phone = result.Tables[0].Rows[0][ColumnNames.SoldTo_Phone].ToString();
                quoteDetails.Header.SoldTo.Misc = result.Tables[0].Rows[0][ColumnNames.SoldTo_Misc].ToString();

                if (quoteDetails.Header.IsShipToOtherAddress)
                {
                    quoteDetails.Header.ShipTo = new CustomerDetails();
                    quoteDetails.Header.ShipTo.FirstName = result.Tables[0].Rows[0][ColumnNames.ShipTo_FirstName].ToString();
                    quoteDetails.Header.ShipTo.LastName = result.Tables[0].Rows[0][ColumnNames.ShipTo_LastName].ToString();
                    quoteDetails.Header.ShipTo.Address = result.Tables[0].Rows[0][ColumnNames.ShipTo_Address].ToString();
                    quoteDetails.Header.ShipTo.Email = result.Tables[0].Rows[0][ColumnNames.ShipTo_Email].ToString();
                    quoteDetails.Header.ShipTo.Fax = result.Tables[0].Rows[0][ColumnNames.ShipTo_Fax].ToString();
                    quoteDetails.Header.ShipTo.Phone = result.Tables[0].Rows[0][ColumnNames.ShipTo_Phone].ToString();
                    quoteDetails.Header.ShipTo.Misc = result.Tables[0].Rows[0][ColumnNames.ShipTo_Misc].ToString();
                }

                if (result == null || result.Tables == null || result.Tables.Count == 0 || result.Tables[1].Rows.Count == 0)
                {
                    return quoteDetails;
                }

                quoteDetails.LineItems = new ObservableCollection<QuoteGridEntity>();
                QuoteGridEntity lineItem = null;
                foreach (DataRow currentRow in result.Tables[1].Rows)
                {
                    lineItem = new QuoteGridEntity();
                    lineItem.LineID = int.Parse(currentRow[ColumnNames.LineID].ToString());
                    lineItem.Quantity = int.Parse(currentRow[ColumnNames.Quantity].ToString());
                    lineItem.Description = currentRow[ColumnNames.Description].ToString();
                    lineItem.Dimension = currentRow[ColumnNames.Dimension].ToString();
                    lineItem.TotalSqFt = double.Parse(currentRow[ColumnNames.SqFt].ToString());
                    lineItem.UnitPrice = double.Parse(currentRow[ColumnNames.PricePerUnit].ToString()).ToString("0.00");
                    lineItem.Total = double.Parse(currentRow[ColumnNames.Total].ToString()).ToString("0.00");

                    quoteDetails.LineItems.Add(lineItem);
                }

                if (result == null || result.Tables == null || result.Tables.Count == 0 || result.Tables[2].Rows.Count == 0)
                {
                    return quoteDetails;
                }
                quoteDetails.Footer = new QuoteFooter();
                quoteDetails.Footer.SubTotal = double.Parse(result.Tables[2].Rows[0][ColumnNames.SubTotal].ToString());
                quoteDetails.Footer.IsDollar = bool.Parse(result.Tables[2].Rows[0][ColumnNames.IsDollar].ToString());
                quoteDetails.Footer.EnergySurcharge = double.Parse(result.Tables[2].Rows[0][ColumnNames.EnergySurcharge].ToString());
                quoteDetails.Footer.Discount = double.Parse(result.Tables[2].Rows[0][ColumnNames.Discount].ToString());
                quoteDetails.Footer.Delivery = double.Parse(result.Tables[2].Rows[0][ColumnNames.Delivery].ToString());
                quoteDetails.Footer.IsRushOrder = bool.Parse(result.Tables[2].Rows[0][ColumnNames.IsRush].ToString());
                quoteDetails.Footer.RushOrder = double.Parse(result.Tables[2].Rows[0][ColumnNames.RushOrder].ToString());
                quoteDetails.Footer.Tax = double.Parse(result.Tables[2].Rows[0][ColumnNames.Tax].ToString());
                quoteDetails.Footer.GrandTotal = double.Parse(result.Tables[2].Rows[0][ColumnNames.GrandTotal].ToString());
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return quoteDetails;
        }
        private void btnAddToQuote_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (currentItem.Quantity <= 0)
                {
                    Helper.ShowErrorMessageBox("Quantity can not be zero!");
                    return;
                }
                Dashboard parent = Window.GetWindow(this) as Dashboard;
                if (parent != null)
                {
                    NewQuoteContent content = parent.ucMainContent.CurrentPage as NewQuoteContent;
                    if (content != null)
                    {
                        NewQuoteGridContent grid = content.ucNewQuoteGrid.CurrentPage as NewQuoteGridContent;
                        if (grid != null)
                        {
                            QuoteGridEntity newItem = new QuoteGridEntity();

                            if (grid.allQuoteData == null)
                            {
                                grid.allQuoteData = new ObservableCollection<QuoteGridEntity>();
                            }
                            newItem.LineID = grid.allQuoteData.Count + 1;
                            newItem.Quantity = currentItem.Quantity;
                            // item description string have charged dimension of glass to be print on quote
                            newItem.Description = currentItem.GetDescriptionString();
                            newItem.Dimension = GetDimensionString();
                            newItem.TotalSqFt = currentItem.TotalSqFTCharged;
                            newItem.UnitPrice = currentItem.PricePerUnit.ToString("0.00");
                            newItem.Total = currentItem.CurrentTotal.ToString("0.00");
                            newItem.Shape = currentItem.Shape;

                            // Line item details
                            newItem.IsPolish = currentItem.IsMiter || currentItem.IsStraightPolish || currentItem.IsCustomShapePolish;
                            newItem.IsDrill = currentItem.IsHoles;
                            newItem.IsWaterJet = currentItem.IsNotch || currentItem.IsHinges || currentItem.IsPatches || currentItem.IsCutout;
                            newItem.IsTemper = currentItem.IsTempered;
                            newItem.IsInsulate = currentItem.IsInsulation;

                            // Actual description string have action dimension of glass to be sent to worker for cutting glass
                            newItem.ActualDescription = currentItem.GetDescriptionString(true);
                            newItem.ActualDimension = GetActualDimensionString();
                            newItem.ActualTotalSQFT = currentItem.TotalSqFT;
                            newItem.IsLogo = currentItem.IsLogoRequired;
                            grid.allQuoteData.Add(newItem);

                            grid.allLineItemDetails.Add(currentItem);
                            //ResetAllControls();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
        private void btnAddNewLineItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                QuoteGridEntity entity = new QuoteGridEntity();
                entity.LineID = dgQuoteItems.Items.Count + 1;
                allQuoteData.Add(entity);

                ICollectionView dataView = CollectionViewSource.GetDefaultView(dgQuoteItems.ItemsSource);
                //clear the existing sort order
                dataView.SortDescriptions.Clear();
                //create a new sort order for the sorting that is done lastly
                dataView.SortDescriptions.Add(new SortDescription("LineID", ListSortDirection.Ascending));
                //refresh the view which in turn refresh the grid
                dataView.Refresh();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }