public NewQuoteItemsContent()
        {
            InitializeComponent();
            isInitialized = true;
            currentItem = new NewQuoteItemEntity();

            FillGlassTypes();
            FillShapes();

            FillCutoutData();
            FillInsulationDetails();
            currentItem.GlassType1 = new InsulationDetails();
            currentItem.GlassType2 = new InsulationDetails();
        }
        private void btnNewItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (currentItem != null)
                {
                    var result = Helper.ShowQuestionMessageBox("Are you sure to discard current changes?");
                    if (result == MessageBoxResult.Yes)
                    {
                        currentItem = new NewQuoteItemEntity();
                        allCutoutData.Clear();
                        currentItem.GlassType1 = new InsulationDetails();
                        currentItem.GlassType2 = new InsulationDetails();

                        UpdateCurrentTotal();
                        ResetAllControls();
                    }
                }
                else
                {
                    currentItem = new NewQuoteItemEntity();
                    allCutoutData.Clear();
                    currentItem.GlassType1 = new InsulationDetails();
                    currentItem.GlassType2 = new InsulationDetails();

                    UpdateCurrentTotal();
                    ResetAllControls();
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 3
0
        internal static NewQuoteItemEntity GetLineItemDetails(string quoteNumber, int lineID)
        {
            NewQuoteItemEntity item = null;
            try
            {
                SqlParameter pQuoteNumber = new SqlParameter();
                pQuoteNumber.ParameterName = "quoteNumber";
                pQuoteNumber.Value = quoteNumber;

                SqlParameter pLineID = new SqlParameter();
                pLineID.ParameterName = "lineID";
                pLineID.Value = lineID;

                var result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.GetLineItemInformation, pQuoteNumber, pLineID);

                if (result == null || result.Tables == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
                    return item;

                item = new NewQuoteItemEntity();
                if (result.Tables.Count > 0)
                {
                    item.GlassTypeID = int.Parse(result.Tables[0].Rows[0][ColumnNames.SelectedGlassIndex].ToString());
                    item.ThicknessID = int.Parse(result.Tables[0].Rows[0][ColumnNames.SelectedThicknessIndex].ToString());
                    item.IsLogoRequired = bool.Parse(result.Tables[0].Rows[0][ColumnNames.IsLogo].ToString());
                    item.IsTempered = bool.Parse(result.Tables[0].Rows[0][ColumnNames.IsTempered].ToString());
                    item.ShapeID = int.Parse(result.Tables[0].Rows[0][ColumnNames.SelectedShapeIndex].ToString());
                    item.GlassWidth = int.Parse(result.Tables[0].Rows[0][ColumnNames.ActualWidth].ToString());
                    item.GlassWidthFraction = result.Tables[0].Rows[0][ColumnNames.ActualWidthFraction].ToString();
                    item.GlassHeight = int.Parse(result.Tables[0].Rows[0][ColumnNames.ActualHeight].ToString());
                    item.GlassHeightFraction = result.Tables[0].Rows[0][ColumnNames.ActualHeightFraction].ToString();
                    item.Quantity = int.Parse(result.Tables[0].Rows[0][ColumnNames.Quantity].ToString());
                    item.TotalSqFT = int.Parse(result.Tables[0].Rows[0][ColumnNames.ActualTotalSqft].ToString());
                    item.GlassWidthCharged = int.Parse(result.Tables[0].Rows[0][ColumnNames.ChargedWidth].ToString());
                    item.GlassHeightCharged = int.Parse(result.Tables[0].Rows[0][ColumnNames.ChargedHeight].ToString());
                    item.TotalSqFTCharged = int.Parse(result.Tables[0].Rows[0][ColumnNames.ChargedTotal].ToString());
                    item.StraightPolishTotalInches = int.Parse(result.Tables[0].Rows[0][ColumnNames.StraightTotalPolish].ToString());
                    item.StraightPolishLongSide = int.Parse(result.Tables[0].Rows[0][ColumnNames.StraightLongSide].ToString());
                    item.StraightPolishShortSide = int.Parse(result.Tables[0].Rows[0][ColumnNames.StraightShortSide].ToString());
                    item.CustomPolishTotalInches = int.Parse(result.Tables[0].Rows[0][ColumnNames.CustomTotalPolish].ToString());
                    item.MiterTotalInches = int.Parse(result.Tables[0].Rows[0][ColumnNames.MiterTotalPolish].ToString());
                    item.MiterLongSide = int.Parse(result.Tables[0].Rows[0][ColumnNames.MiterLongSide].ToString());
                    item.MiterShortSide = int.Parse(result.Tables[0].Rows[0][ColumnNames.MiterShortSide].ToString());
                    item.Notches = int.Parse(result.Tables[0].Rows[0][ColumnNames.Notches].ToString());
                    item.Patches = int.Parse(result.Tables[0].Rows[0][ColumnNames.Patches].ToString());
                    item.Holes = int.Parse(result.Tables[0].Rows[0][ColumnNames.Holes].ToString());
                    item.Hinges = int.Parse(result.Tables[0].Rows[0][ColumnNames.Hinges].ToString());
                    item.CutoutTotal = int.Parse(result.Tables[0].Rows[0][ColumnNames.CutoutTotal].ToString());
                }
                if (result.Tables.Count > 1)
                {
                    item._allCutoutData = new ObservableCollection<CutoutData>();
                    CutoutData tempItem = null;
                    for (int rowIndex = 0; rowIndex < result.Tables[1].Rows.Count; rowIndex++)
                    {
                        tempItem = new CutoutData();
                        tempItem.Quantity = int.Parse(result.Tables[1].Rows[rowIndex][ColumnNames.Quantity].ToString());
                        tempItem.Width = int.Parse(result.Tables[1].Rows[rowIndex][ColumnNames.Width].ToString());
                        tempItem.Height = int.Parse(result.Tables[1].Rows[rowIndex][ColumnNames.Height].ToString());
                        tempItem.Price = int.Parse(result.Tables[1].Rows[rowIndex][ColumnNames.Price].ToString());
                        item._allCutoutData.Add(tempItem);
                    }
                }
                if (result.Tables.Count > 2)
                {
                    item.GlassType1 = new InsulationDetails();
                    item.GlassType2 = new InsulationDetails();

                    item.GlassType1.GlassTypeID = int.Parse(result.Tables[2].Rows[0][ColumnNames.GlassType1Index].ToString());
                    item.GlassType1.ThicknessID = int.Parse(result.Tables[2].Rows[0][ColumnNames.Thickness1Index].ToString());
                    item.GlassType1.IsTempered = bool.Parse(result.Tables[2].Rows[0][ColumnNames.IsTemp1].ToString());
                    item.GlassType1.SqFt = int.Parse(result.Tables[2].Rows[0][ColumnNames.Sqft].ToString());
                    item.GlassType1.Total = int.Parse(result.Tables[2].Rows[0][ColumnNames.Total1].ToString());
                    item.GlassType2.GlassTypeID = int.Parse(result.Tables[2].Rows[0][ColumnNames.GlassType2Index].ToString());
                    item.GlassType2.ThicknessID = int.Parse(result.Tables[2].Rows[0][ColumnNames.Thickness2Index].ToString());
                    item.GlassType2.IsTempered = bool.Parse(result.Tables[2].Rows[0][ColumnNames.IsTemp2].ToString());
                    item.GlassType2.SqFt = int.Parse(result.Tables[2].Rows[0][ColumnNames.Sqft].ToString());
                    item.GlassType2.Total = int.Parse(result.Tables[2].Rows[0][ColumnNames.Total2].ToString());
                    item.MaterialCost = int.Parse(result.Tables[2].Rows[0][ColumnNames.MaterialCost].ToString());
                    item.InsulationTier = int.Parse(result.Tables[2].Rows[0][ColumnNames.InsulationTier].ToString());
                    item.InsulationTierTotal = int.Parse(result.Tables[2].Rows[0][ColumnNames.InsulationTierTotal].ToString());
                    item.InsulationTotal = int.Parse(result.Tables[2].Rows[0][ColumnNames.InsulationTotal].ToString());
                    item.IsInsulation = bool.Parse(result.Tables[2].Rows[0][ColumnNames.IsInsulate].ToString());
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return item;
        }
Exemplo n.º 4
0
        private static void SaveLineItemInsulationDetails(string quoteNubmer, int lineID, NewQuoteItemEntity currentLineItem)
        {
            try
            {
                List<SqlParameter> allParameters;

                allParameters = new List<SqlParameter>();
                SqlParameter tempParameter = new SqlParameter() { ParameterName = "QuoteNumber", Value = quoteNubmer };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "LineID", Value = lineID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "GlassType1Index", Value = currentLineItem.GlassType1.GlassTypeID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Thickness1Index", Value = currentLineItem.GlassType1.ThicknessID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "IsTemp1", Value = currentLineItem.GlassType1.IsTempered };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Sqft", Value = currentLineItem.GlassType1.SqFt };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Total1", Value = currentLineItem.GlassType1.Total };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Total2", Value = currentLineItem.GlassType2.Total };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "GlassType2Index", Value = currentLineItem.GlassType2.GlassTypeID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Thickness2Index", Value = currentLineItem.GlassType2.ThicknessID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "IsTemp2", Value = currentLineItem.GlassType2.IsTempered };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "MaterialCost", Value = currentLineItem.MaterialCost };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "InsulationTier", Value = currentLineItem.InsulationTier };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "InsulationTierTotal", Value = currentLineItem.InsulationTierTotal };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "InsulationTotal", Value = currentLineItem.InsulationTotal };
                allParameters.Add(tempParameter);

                var result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.InsertLineItemInsulationDetails, allParameters.ToArray());
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 5
0
        private static void SaveLineItemCutoutDetails(string quoteNubmer, int lineID, NewQuoteItemEntity currentLineItem)
        {
            try
            {
                List<SqlParameter> allParameters;

                foreach (CutoutData item in currentLineItem._allCutoutData)
                {
                    allParameters = new List<SqlParameter>();
                    SqlParameter tempParameter = new SqlParameter() { ParameterName = "QuoteNumber", Value = quoteNubmer };
                    allParameters.Add(tempParameter);

                    tempParameter = new SqlParameter() { ParameterName = "LineID", Value = lineID };
                    allParameters.Add(tempParameter);

                    tempParameter = new SqlParameter() { ParameterName = "Quantity", Value = item.Quantity };
                    allParameters.Add(tempParameter);

                    tempParameter = new SqlParameter() { ParameterName = "Width", Value = item.Width };
                    allParameters.Add(tempParameter);

                    tempParameter = new SqlParameter() { ParameterName = "Height", Value = item.Height };
                    allParameters.Add(tempParameter);

                    tempParameter = new SqlParameter() { ParameterName = "Price", Value = item.Price };
                    allParameters.Add(tempParameter);

                    var result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.InsertLineCutoutDetails, allParameters.ToArray());
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 6
0
        internal static void SaveQuoteItems(string quoteNumber, ObservableCollection<QuoteGridEntity> allQuoteData, ObservableCollection<NewQuoteItemEntity> allLineItems)
        {
            try
            {
                SqlParameter pQuoteNumber = new SqlParameter();
                pQuoteNumber.ParameterName = "QuoteNumber";
                pQuoteNumber.Value = quoteNumber;

                SqlParameter pLineID = null;
                SqlParameter pQuantity = null;
                SqlParameter pDescription = null;
                SqlParameter pDimension = null;
                SqlParameter pSqFt = null;
                SqlParameter pPricePerUnit = null;
                SqlParameter pTotal = null;

                SqlParameter pActualDescription = null;
                SqlParameter pActualDimension = null;
                SqlParameter pActualTotalSQFT = null;
                SqlParameter pIsLogo = null;
                SqlParameter pShape = null;

                SqlParameter pIsPolish = null;
                SqlParameter pIsDrills = null;
                SqlParameter pIsWaterjet = null;
                SqlParameter pIsTemper = null;
                SqlParameter pIsInsulate = null;

                int counter = 0;
                NewQuoteItemEntity currentLineItem = new NewQuoteItemEntity();

                foreach (QuoteGridEntity item in allQuoteData)
                {
                    pQuantity = new SqlParameter();
                    pQuantity.ParameterName = "Quantity";
                    pQuantity.Value = item.Quantity;

                    pLineID = new SqlParameter();
                    pLineID.ParameterName = "LineID";
                    pLineID.Value = item.LineID;

                    pDescription = new SqlParameter();
                    pDescription.ParameterName = "Description";
                    pDescription.Value = item.Description;

                    pDimension = new SqlParameter();
                    pDimension.ParameterName = "Dimension";
                    pDimension.Value = item.Dimension;

                    pSqFt = new SqlParameter();
                    pSqFt.ParameterName = "SqFt";
                    pSqFt.Value = double.Parse(item.TotalSqFt.ToString());

                    pPricePerUnit = new SqlParameter();
                    pPricePerUnit.ParameterName = "PricePerUnit";
                    pPricePerUnit.Value = double.Parse(item.UnitPrice);

                    pTotal = new SqlParameter();
                    pTotal.ParameterName = "Total";
                    pTotal.Value = item.Total;

                    pActualDescription = new SqlParameter();
                    pActualDescription.ParameterName = "ActualDescription";
                    pActualDescription.Value = item.ActualDescription ?? item.Description;

                    pActualDimension = new SqlParameter();
                    pActualDimension.ParameterName = "ActualDimension";
                    pActualDimension.Value = item.ActualDimension ?? item.Dimension;

                    pActualTotalSQFT = new SqlParameter();
                    pActualTotalSQFT.ParameterName = "ActualTotalSQFT";
                    pActualTotalSQFT.Value = item.ActualTotalSQFT.ToString("0.00") ?? item.TotalSqFt.ToString("0.00");

                    pIsLogo = new SqlParameter();
                    pIsLogo.ParameterName = "IsLogo";
                    pIsLogo.Value = item.IsLogo;

                    pShape = new SqlParameter();
                    pShape.ParameterName = "Shape";
                    pShape.Value = item.Shape ?? "Square";

                    pIsPolish = new SqlParameter();
                    pIsPolish.ParameterName = "IsPolish";
                    pIsPolish.Value = item.IsPolish;

                    pIsDrills = new SqlParameter();
                    pIsDrills.ParameterName = "IsDrills";
                    pIsDrills.Value = item.IsDrill;

                    pIsWaterjet = new SqlParameter();
                    pIsWaterjet.ParameterName = "IsWaterjet";
                    pIsWaterjet.Value = item.IsWaterJet;

                    pIsTemper = new SqlParameter();
                    pIsTemper.ParameterName = "IsTemper";
                    pIsTemper.Value = item.IsTemper;

                    pIsInsulate = new SqlParameter();
                    pIsInsulate.ParameterName = "IsInsulate";
                    pIsInsulate.Value = item.IsInsulate;

                    SQLHelper.ExecuteStoredProcedure(StoredProcedures.InsertQuoteLineItem, pLineID, pQuoteNumber, pQuantity, pDescription, pDimension, pSqFt, pPricePerUnit, pTotal,
                                     pActualTotalSQFT, pIsLogo, pShape
                                     , pIsPolish, pIsDrills, pIsWaterjet, pIsTemper, pIsInsulate);

                    // Save line item details
                    currentLineItem = allLineItems[counter];

                    SaveLineItemDetails(quoteNumber, item.LineID, currentLineItem);

                    SaveLineItemCutoutDetails(quoteNumber, item.LineID, currentLineItem);

                    SaveLineItemInsulationDetails(quoteNumber, item.LineID, currentLineItem);
                    counter++;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 7
0
        internal static void SaveLineItemDetails(string quoteNubmer, int lineID, NewQuoteItemEntity currentLineItem)
        {
            try
            {
                List<SqlParameter> allParameters = new List<SqlParameter>();

                SqlParameter tempParameter = new SqlParameter() { ParameterName = "QuoteNumber", Value = quoteNubmer };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "LineID", Value = lineID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "SelectedGlassIndex", Value = currentLineItem.GlassTypeID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "SelectedThicknessIndex", Value = currentLineItem.ThicknessID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "IsLogo", Value = currentLineItem.IsLogoRequired };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "IsTempered", Value = currentLineItem.IsTempered };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "SelectedShapeIndex", Value = currentLineItem.ShapeID };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ActualWidth", Value = currentLineItem.GlassWidth };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ActualWidthFraction", Value = currentLineItem.GlassWidthFraction };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ActualHeight", Value = currentLineItem.GlassHeight };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ActualHeightFraction", Value = currentLineItem.GlassHeightFraction };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Quantity", Value = currentLineItem.Quantity };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ActualTotalSqft", Value = currentLineItem.TotalSqFT };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ChargedWidth", Value = currentLineItem.GlassWidthCharged };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ChargedHeight", Value = currentLineItem.GlassHeightCharged };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "ChargedTotal", Value = currentLineItem.TotalSqFTCharged };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "StraightTotalPolish", Value = currentLineItem.StraightPolishTotalInches };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "StraightLongSide", Value = currentLineItem.StraightPolishLongSide };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "StraightShortSide", Value = currentLineItem.StraightPolishShortSide };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "CustomTotalPolish", Value = currentLineItem.CustomPolishTotalInches };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "MiterTotalPolish", Value = currentLineItem.MiterTotalInches };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "MiterLongSide", Value = currentLineItem.MiterLongSide };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "MiterShortSide", Value = currentLineItem.MiterShortSide };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Notches", Value = currentLineItem.Notches };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Patches", Value = currentLineItem.Patches };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Holes", Value = currentLineItem.Holes };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "Hinges", Value = currentLineItem.Hinges };
                allParameters.Add(tempParameter);

                tempParameter = new SqlParameter() { ParameterName = "CutoutTotal", Value = currentLineItem.CutoutTotal };
                allParameters.Add(tempParameter);

                var result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.InsertLineItemDetails, allParameters.ToArray());

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

            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }