public CallContext ProfileSettingSave(ProfileSetting entity, CallContext resultContext)
        {
            resultContext.securitySettings  = ETEMEnums.SecuritySettings.ProfilesSave;
            CallContext resContext          = new ProfileSettingBL().EntitySave<ProfileSetting>(entity, resultContext);

            return resContext;
        }
Example #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProfileSettings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProfileSettings(ProfileSetting profileSetting)
 {
     base.AddObject("ProfileSettings", profileSetting);
 }
Example #3
0
 /// <summary>
 /// Create a new ProfileSetting object.
 /// </summary>
 /// <param name="idProfileSetting">Initial value of the idProfileSetting property.</param>
 /// <param name="idProfileType">Initial value of the idProfileType property.</param>
 /// <param name="idProfileCategory">Initial value of the idProfileCategory property.</param>
 /// <param name="idProfileComplexity">Initial value of the idProfileComplexity property.</param>
 /// <param name="hasA">Initial value of the hasA property.</param>
 /// <param name="hasB">Initial value of the hasB property.</param>
 /// <param name="hasC">Initial value of the hasC property.</param>
 /// <param name="hasD">Initial value of the hasD property.</param>
 /// <param name="hasS">Initial value of the hasS property.</param>
 /// <param name="diameterFormula">Initial value of the DiameterFormula property.</param>
 public static ProfileSetting CreateProfileSetting(global::System.Int32 idProfileSetting, global::System.Int32 idProfileType, global::System.Int32 idProfileCategory, global::System.Int32 idProfileComplexity, global::System.Boolean hasA, global::System.Boolean hasB, global::System.Boolean hasC, global::System.Boolean hasD, global::System.Boolean hasS, global::System.String diameterFormula)
 {
     ProfileSetting profileSetting = new ProfileSetting();
     profileSetting.idProfileSetting = idProfileSetting;
     profileSetting.idProfileType = idProfileType;
     profileSetting.idProfileCategory = idProfileCategory;
     profileSetting.idProfileComplexity = idProfileComplexity;
     profileSetting.hasA = hasA;
     profileSetting.hasB = hasB;
     profileSetting.hasC = hasC;
     profileSetting.hasD = hasD;
     profileSetting.hasS = hasS;
     profileSetting.DiameterFormula = diameterFormula;
     return profileSetting;
 }
Example #4
0
        public override Tuple<CallContext, string> UserControlSave()
        {


            bool isNewOffer = false;

            if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING)
            {
                isNewOffer = true;
                this.currentEntity = new Offer();
                this.currentEntityBeforeSave = new Offer();
                this.currentEntity.idCreateUser = Int32.Parse(this.ownerPage.UserProps.IdUser);
                this.currentEntity.dCreate = DateTime.Now;
                
                this.NeedReCalculation = false;

                SetDefaultValues();
            }
            else
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
                this.currentEntity =  this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);
                this.currentEntityBeforeSave = this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);
                
                if (this.currentEntity == null)
                {
                    string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("InquiryData_Data"));

                    this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                    this.ownerPage.CallContext.Message = falseResult;

                    return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
                }
             
            }

            
            this.currentEntity.idModifyUser = Int32.Parse(this.ownerPage.UserProps.IdUser);
            this.currentEntity.dModify = DateTime.Now;

            this.currentEntity.Customer = this.tbxCustomer.Text.Trim();
            this.currentEntity.InquiryNumber = this.tbxInquiryNumber.Text.Trim();

            if (this.tbxOfferDate.TextAsDateParseExact.HasValue)
            {
                this.currentEntity.OfferDate = this.tbxOfferDate.TextAsDateParseExact.Value;
            }
            else
            {
                this.currentEntity.OfferDate = DateTime.MinValue;
            }

          
            this.currentEntity.WeightPerMeter = BaseHelper.ConvertToDecimalOrZero(this.tbxWeightPerMeter.Text);

            SetOfferDataDependOnWeightPerMeter(this.currentEntity);
            

            if (!ValidateRequiredField())
            {   
                return new Tuple<CallContext, string>(this.ownerPage.CallContext, string.Empty);
            }


            


            GeneralPage.LogDebug("this.currentEntity.OfferDate = " + this.currentEntity.OfferDate);


            #region ProfileSetting

            if (this.hdnIdProfileSetting.Value.IsNotNullOrEmpty())
            {
                this.currentEntity.idProfileSetting = Int32.Parse(this.hdnIdProfileSetting.Value);
            }
            else
            {
                string falseResult = "The field `Profile` is required!";

                this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                this.ownerPage.CallContext.Message = falseResult;

                return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
            }

           



            if (this.currentEntity.idNumberOfCavities.HasValue)
            {
                //this.currentEntity.idNumberOfCavities = this.ddlNumberOfCavities.SelectedValueNullINT;
                this.ddlNumberOfCavities.SelectedValue = this.currentEntity.idNumberOfCavities.ToString();
            }
         
            

            if (this.tbxValueForA.Enabled && this.tbxValueForA.Text.IsNotNullOrEmpty())
            {
                this.currentEntity.ValueForA =  BaseHelper.ConvertToIntOrZero(this.tbxValueForA.Text.Trim());
            }

            if (this.tbxValueForB.Enabled && this.tbxValueForB.Text.IsNotNullOrEmpty())
            {
                this.currentEntity.ValueForB =  BaseHelper.ConvertToIntOrZero(this.tbxValueForB.Text.Trim());
            }

            if (this.tbxValueForC.Enabled && this.tbxValueForC.Text.IsNotNullOrEmpty())
            {
                this.currentEntity.ValueForC =  BaseHelper.ConvertToIntOrZero(this.tbxValueForC.Text.Trim());
            }

            if (this.tbxValueForD.Enabled && this.tbxValueForD.Text.IsNotNullOrEmpty())
            {
                this.currentEntity.ValueForD =  BaseHelper.ConvertToIntOrZero(this.tbxValueForD.Text.Trim());
            }

            if (this.tbxValueForS.Enabled && this.tbxValueForS.Text.IsNotNullOrEmpty())
            {
                this.currentEntity.ValueForS =  BaseHelper.ConvertToDecimalOrZero(this.tbxValueForS.Text.Trim());
            }

            this.currentEntity.Diameter = BaseHelper.ConvertToIntOrMinValue(this.tbxDiameter.Text.Trim());
            this.currentEntity.DieDiameter = BaseHelper.ConvertToIntOrMinValue(this.tbxDieDiameter.Text.Trim());

            

            this.profileSetting = this.ownerPage.CostCalculationRef.GetProfileSettingById(this.currentEntity.idProfileSetting.ToString());

            try
            {
                if (profileSetting != null)
                {

                     AddPrimitives();
                     this.tmpDiameter = Convert.ToDouble( evalHelper.EvalExpression(profileSetting.DiameterFormula, primitives) );

                     this.tbxDiameter.Text = this.tmpDiameter.ToStringNotFormatted();
                     this.currentEntity.Diameter = BaseHelper.ConvertToDecimalOrZero(this.tbxDiameter.Text);
                    
                }
            }
            catch (Exception ex)
            {
                string falseResult = ex.Message;

                this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                this.ownerPage.CallContext.Message = falseResult;

                return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
            } 
            #endregion

            #region DieFormula Die Dieamter

            if (this.currentEntity.idNumberOfCavities.HasValue)
            {
                DieFormula dieFormula = this.ownerPage.CostCalculationRef.GetDieFormulaParams(
                                    profileSetting.idProfileCategory,
                                    profileSetting.idProfileType,
                                    this.currentEntity.idNumberOfCavities.Value,
                                    this.ownerPage.CallContext);


                if (dieFormula != null)
                {
                    AddPrimitives();

                    this.tmpDieDiameter = Convert.ToDouble(evalHelper.EvalExpression(dieFormula.DieFormulaText, primitives));
                    this.tbxDieDiameter.Text = tmpDieDiameter.ToStringNotFormatted();                     
                    this.currentEntity.DieDiameter= BaseHelper.ConvertToDecimalOrZero(this.tbxDieDiameter.Text);
               
                    string result = ValidateFormulas();


                    if (result.IsNotNullOrEmpty())
                    {
                        string falseResult = "Is not met either of the following conditions: " + result;

                        this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                        this.ownerPage.CallContext.Message = falseResult;

                        return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
                    }

                    

                }
                else
                {

                    string falseResult = BaseHelper.GetCaptionString("InquiryData_DieFormula_not_found");

                    this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                    this.ownerPage.CallContext.Message = falseResult;

                    return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
                }
            }
            else
            {
                    string falseResult = "The field `Number of cavities` is required!";

                    this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                    this.ownerPage.CallContext.Message = falseResult;

                    return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
            }
            
            #endregion

            #region DiePrice
            ICollection<AbstractSearch> searchCriteria = new List<AbstractSearch>();
            AddCustomSearchCriterias(searchCriteria);

            GeneralPage.LogDebug("this.currentEntity.OfferDate = " + this.currentEntity.OfferDate.ToString());
            List<DiePriceListDetailDataView> listDiePrice = this.ownerPage
                                                                .CostCalculationRef
                                                                .GetAllDiePriceListDetails(
                                                                        searchCriteria,
                                                                        this.currentEntity.OfferDate, 
                                                                        "Price", 
                                                                        Constants.SORTING_ASC
                                                                        );


             GeneralPage.LogDebug("listDiePrice.count = " + listDiePrice.Count);

            listDiePrice = listDiePrice.OrderBy(s => s.DimensionA).ThenByDescending(s => s.Price).ToList();

            DiePriceListDetailDataView tmpDiePrice = listDiePrice.FirstOrDefault();



            if (tmpDiePrice != null)
            {
                this.tbxDieDimensions.Text = tmpDiePrice.DimensionA_String;
                this.tbxDiePrice.Text = tmpDiePrice.Price.ToStringNotFormatted();
                this.tbxVendor.Text = tmpDiePrice.VendorName;
                this.tbxPriceListStr.Text = tmpDiePrice.DateFromString + "-" + tmpDiePrice.DateToString;


                this.currentEntity.DiePrice = tmpDiePrice.Price;
                this.currentEntity.CostOfDie = tmpDiePrice.Price;
                
                this.currentEntity.DieDimensions = tmpDiePrice.DimensionA;
                this.currentEntity.idDiePriceListDetail = tmpDiePrice.idDiePriceListDetail;

            }
            else
            {
                string falseResult = "No die price is found. Please change your offer data..";

                this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                this.ownerPage.CallContext.Message = falseResult;

                return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
            } 
            #endregion

          
            
           
            
            this.currentEntity.ValueForPin = BaseHelper.ConvertToIntOrZero(this.tbxPin.Text.Trim());
            this.currentEntity.ValueForPout = BaseHelper.ConvertToIntOrZero(this.tbxPout.Text.Trim());
            this.currentEntity.SDI = 75;
            
            this.currentEntity.Lifespan = this.currentEntity.Lifespan_Computable; 

            this.currentEntity.LME = BaseHelper.ConvertToDecimalOrZero(this.tbxLME.Text);
            this.currentEntity.PREMIUM = BaseHelper.ConvertToDecimalOrZero(this.tbxPREMIUM.Text);

            this.currentEntity.LengthOfFinalPC = BaseHelper.ConvertToDecimalOrZero(this.tbxLengthOfFinalPC.Text);
            

            this.currentEntity.WeightPerPC = BaseHelper.ConvertToDecimalOrZero(this.tbxWeightPerPC.Text);

            if (this.currentEntity.WeightPerPC == Decimal.Zero)
            {
                this.currentEntity.WeightPerPC = this.currentEntity.WeightPerPCComputable;
                this.tbxWeightPerPC.Text = this.currentEntity.WeightPerPC.ToStringNotFormatted();
            }
            
            
            this.currentEntity.PcsForTheWholeProject = BaseHelper.ConvertToDecimalOrZero(this.tbxPcsForTheWholeProject.Text);
            
            this.currentEntity.Tonnage = this.currentEntity.TonnageComputable;          

            
            this.currentEntity.DaysOfCredit = BaseHelper.ConvertToIntOrMinValue(this.tbxDaysOfCredit.Text);
            this.currentEntity.GrossMargin = BaseHelper.ConvertToDecimalOrZero(this.tbxGrossMargin.Text);
            this.currentEntity.SavingsRate = BaseHelper.ConvertToDecimalOrZero(this.tbxSavingsRate.Text);

            this.currentEntity.idCommision = this.ddlCommision.SelectedValueNullINT;
            this.currentEntity.idAgent= this.ddlAgent.SelectedValueNullINT;
            this.currentEntity.idAging= this.ddlAging.SelectedValueINT;

            this.currentEntity.idHardness= this.ddlHardness.SelectedValueINT;
            this.currentEntity.idStandardPackaging = this.ddlStandardPackaging.SelectedValueINT;

            this.currentEntity.idCalculationCommission= this.ddlCalculationCommission.SelectedValueNullINT;

            
            this.currentEntity.CostOfScrap = this.currentEntity.NetConsumptionComputable - this.currentEntity.MaterialComputable;
            this.currentEntity.AdministrationExpenses = BaseHelper.ConvertToDecimalOrZero(this.tbxAdministrationExpenses.Text);
            this.currentEntity.SalesExpenses = BaseHelper.ConvertToDecimalOrZero(this.tbxSalesExpenses.Text);
            this.currentEntity.FinancialFixedExpenses = BaseHelper.ConvertToDecimalOrZero(this.tbxFinancialFixedExpenses.Text);

            this.currentEntity.FinancialVariableExpenses= BaseHelper.ConvertToDecimalOrZero(this.tbxFinancialVariableExpenses.Text);

            this.currentEntity.TransportationCost = BaseHelper.ConvertToDecimalOrZero(this.tbxTransportationCost.Text);

            this.currentEntity.ActualTotalSalesPriceToCustomer = BaseHelper.ConvertToDecimalOrZero(this.tbxActualTotalSalesPriceToCustomer.Text);

            this.currentEntity.TargetPrice_EUR_TON = BaseHelper.ConvertToDecimalOrZero(this.tbxTargetPrice.Text);

            

            this.ownerPage.CallContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser;


            PresetData();


           

            

            if (!ValidateBeforeSave())
            {   
                return new Tuple<CallContext, string>(this.ownerPage.CallContext, string.Empty);
            }
        
            ProductivityAndScrap ps = this.ownerPage.CostCalculationRef.GetProductivityAndScrapByDateActiveTo(this.currentEntity.OfferDate);

            ProductivityAndScrapDataView psDataView = this.ownerPage.CostCalculationRef.GetProductivityAndScrapByDateActiveToWithAvgData(this.currentEntity.OfferDate);

            ProductivityAndScrapDetail productivityAndScrapDetail = this.ownerPage.CostCalculationRef.GetProductivityAndScrapDetailByDateActiveToAndPressAndProfile(this.currentEntity.OfferDate, this.currentEntity.idPress.Value, this.currentEntity.idProfileSetting.Value);

            if (productivityAndScrapDetail != null)
            {
                this.currentEntity.ConsumptionRatio = 1 +  productivityAndScrapDetail.ScrapRate;
            }
            

            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.OfferSave(this.currentEntity, this.ownerPage.CallContext);


            this.lbResultContext.Text = this.ownerPage.CallContext.Message;

            if (isNewOffer)
            {
                this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID;
                this.CurrentEntityMasterID = this.ownerPage.CallContext.EntityID;
            }
           
            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {

                 if (this.currentEntity.idPress.HasValue)
                {
                    this.tbxPress.Text = this.ownerPage.GetKeyValueByID(this.currentEntity.idPress.Value).Name;
                    this.ddlPress.SelectedValue = this.currentEntity.idPress.ToString();
                }
               
                this.NeedReCalculation = !this.currentEntity.Equals(this.currentEntityBeforeSave);
                
                this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID;
                this.CurrentEntityMasterID = this.ownerPage.CallContext.EntityID;


                #region OfferDataExpenseGroup
                if (NeedReCalculation)
                {
                    List<Expense> listGroupExpense = this.ownerPage.CostCalculationRef.GetListGroupExpense(this.currentEntity, this.ownerPage.CallContext);

                    if (listGroupExpense == null || listGroupExpense.Count == 0)
                    {
                      

                        this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;
                        this.ownerPage.CallContext.Message = "No press is found. Please change your offer data.";

                        return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
                    }
                    List<OfferDataExpenseGroup> listOfferDataExpenseGroup = new List<OfferDataExpenseGroup>();

                    foreach (Expense expense in listGroupExpense)
                    {
                        OfferDataExpenseGroup odeg = new OfferDataExpenseGroup();

                        odeg.idOffer = Int32.Parse(this.ownerPage.CallContext.EntityID);
                        odeg.idSAPData = expense.IdSAPData;
                        odeg.idCostCenter = expense.CostCenter.idKeyValue;
                        odeg.idExpensesType = expense.ExpenseGroup.idKeyValue;
                        odeg.ValueData = expense.ExpenseValue_MH;
                        listOfferDataExpenseGroup.Add(odeg);
                    }


                    this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.OfferDataExpenseGroupDelete(this.currentEntity.idOffer, this.ownerPage.CallContext);
                    this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.OfferDataExpenseGroupSave(listOfferDataExpenseGroup, this.ownerPage.CallContext);
                } 
                #endregion

                #region OfferProducitivity
                OfferProducitivity offerProducitivity = this.ownerPage.CostCalculationRef.GetOfferProducitivityByOfferID(this.CurrentEntityMasterID);

                if (offerProducitivity == null)
                {
                    offerProducitivity = new OfferProducitivity();
                    offerProducitivity.idOffer = Int32.Parse(this.CurrentEntityMasterID);
                }



                KeyValue kvSelectPress, kvPackaging;
                List<KeyValue> listPress = this.ownerPage.GetAllKeyValueByKeyTypeIntCode("CostCenter").Where(p => p.DefaultValue1 == "Press").ToList();
                List<KeyValue> listCOMETAL = this.ownerPage.GetAllKeyValueByKeyTypeIntCode("CostCenter").Where(p => p.DefaultValue1 == "COMETAL").ToList();

                List<OfferDataExpenseGroupView> listOfferDataExpenseGroupView = this.ownerPage.CostCalculationRef.GetAllOfferDataExpenseGroupByOffer(offerProducitivity.idOffer);

                 kvPackaging = this.ownerPage.GetKeyValueByIntCode("CostCenter", "Packaging");

                if (listOfferDataExpenseGroupView.Count > 0)
                {

                    OfferDataExpenseGroupView odegvPress = (from e in listOfferDataExpenseGroupView
                                                            join p in listPress on e.idCostCenter equals p.idKeyValue
                                                            select e).FirstOrDefault();






                    offerProducitivity.idPress = odegvPress.idCostCenter;

                   
                    kvSelectPress = listPress.Where(p => p.idKeyValue == offerProducitivity.idPress).FirstOrDefault();


                    OfferDataExpenseGroupView odegvCOMETAL = (from e in listOfferDataExpenseGroupView
                                                              join p in listCOMETAL on e.idCostCenter equals p.idKeyValue
                                                              select e).FirstOrDefault();

                    if (odegvCOMETAL != null)
                    {
                        offerProducitivity.idCOMetal = odegvCOMETAL.idCostCenter;
                    }
                    else
                    {
                        offerProducitivity.idCOMetal = null;
                    }

                    if (productivityAndScrapDetail != null && productivityAndScrapDetail.ProductivityKGh.HasValue)
                    {
                        offerProducitivity.PressProducitivity_KG_MH = productivityAndScrapDetail.ProductivityKGh.Value;
                    }
                    else
                    {
                        offerProducitivity.PressProducitivity_KG_MH = Decimal.Zero;
                    }

                    



                    if (offerProducitivity.PressProducitivity_KG_MH > BaseHelper.ConvertToDecimalOrZero(kvSelectPress.DefaultValue3))
                    {
                        offerProducitivity.PressProducitivity_KG_MH = BaseHelper.ConvertToDecimalOrZero(kvSelectPress.DefaultValue3);
                    }


                    offerProducitivity.PressProducitivity_TON_MH = offerProducitivity.PressProducitivity_TON_MH_Computable;

                    offerProducitivity.COMetalProducitivity_KG_MH = offerProducitivity.PressProducitivity_KG_MH;//Productivity for QC and COMETAL is equal to productivity for press
                    offerProducitivity.COMetalProducitivity_TON_MH = offerProducitivity.COMetalProducitivity_TON_MH_Computable;

                    offerProducitivity.QCProducitivity_KG_MH = offerProducitivity.PressProducitivity_KG_MH;//Productivity for QC and COMETAL is equal to productivity for press
                    offerProducitivity.QCProducitivity_TON_MH = offerProducitivity.QCProducitivity_TON_MH_Computable;


                }


                if (NeedReCalculation)
                {


                    List<SAPDataQuantityDataView> listSAPDataQuantities = new List<SAPDataQuantityDataView>();


                    ICollection<AbstractSearch> searchCriteriaSAPDataQuantity = new List<AbstractSearch>();

                    searchCriteriaSAPDataQuantity.Add(
                      new NumericSearch
                      {
                          Comparator = NumericComparators.Equal,
                          Property = "idCostCenter",
                          SearchTerm = this.ownerPage.GetKeyValueByIntCode("CostCenter", "Packaging").idKeyValue
                      });


                    listSAPDataQuantities = base.CostCalculationRef.GetAllSAPDataQuantity(searchCriteriaSAPDataQuantity,
                                                                                          this.currentEntity.OfferDate,
                                                                                          base.GridViewSortExpression,
                                                                                          base.GridViewSortDirection);

                    KeyValue kvProductionQuantity = this.ownerPage.GetKeyValueByIntCode("QuantityType", "ProductionQuantity");
                    KeyValue kvMachineHours = this.ownerPage.GetKeyValueByIntCode("QuantityType", "MachineHours");

                    Decimal productionQuantity = listSAPDataQuantities.FirstOrDefault(q => q.idQuantityType == kvProductionQuantity.idKeyValue).ValueData;
                    Decimal machineHours = listSAPDataQuantities.FirstOrDefault(q => q.idQuantityType == kvMachineHours.idKeyValue).ValueData;



                    if (productionQuantity != Decimal.Zero && machineHours != Decimal.Zero)
                    {
                        offerProducitivity.PackagingProducitivity_KG_MH = productionQuantity / machineHours;

                        offerProducitivity.PackagingMachineHours = machineHours;
                        offerProducitivity.PackagingProductionQuantity = productionQuantity;
                    }
                    else
                    {
                        offerProducitivity.PackagingProducitivity_KG_MH = BaseHelper.ConvertToDecimalOrZero((BasicPage.GetSettingByCode(ETEMEnums.AppSettings.PackagingProducitivity_KG_MH).SettingValue));
                    }



                    if (offerProducitivity.PackagingProducitivity_KG_MH > BaseHelper.ConvertToDecimalOrZero(kvPackaging.DefaultValue3))
                    {
                        offerProducitivity.PackagingProducitivity_KG_MH = BaseHelper.ConvertToDecimalOrZero(kvPackaging.DefaultValue3);
                    }


                    offerProducitivity.PackagingProducitivity_TON_MH = offerProducitivity.PackagingProducitivity_TON_MH_Computable;


                    


                    this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.OfferProducitivitySave(offerProducitivity, this.ownerPage.CallContext);

                    ProducitivityData producitivityData = FindControlById(this.Page, "ProducitivityData") as ProducitivityData;

                    if (producitivityData != null)
                    {
                        producitivityData.CurrentEntityMasterID = this.CurrentEntityMasterID;
                        producitivityData.SetHdnField(this.CurrentEntityMasterID);
                        producitivityData.UserControlLoad();
                    }
                }

               
                
                #endregion

                ddlCommision_SelectedIndexChanged(null, null);
                ddlCalculationCommission_SelectedIndexChanged(null, null);

                this.currentEntity =  this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);

               

                this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.OfferSave(this.currentEntity, this.ownerPage.CallContext);
                
                this.currentEntity =  this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);

                
                this.currentEntity.LoadProductCostResult();
                this.currentEntity.LoadOfferOverviewResult();


                this.tbxSGAsAndFin_EUR_TON.Text = this.currentEntity.SGAsAndFin_EUR_TON_Computable.ToStringNotFormatted();
                this.tbxSGAsAndFin_EUR.Text = this.currentEntity.SGAsAndFin_EUR_Computable.ToStringNotFormatted();

                 this.tbxFinancialVariableExpenses.Text = this.currentEntity.Financial_variable_Computable.ToStringNotFormatted();
                this.currentEntity.FinancialVariableExpenses = this.currentEntity.Financial_variable_Computable;
                this.currentEntity.TotalSalesPrice = this.currentEntity.TotalSalesPrice_EUR_Computable;

                this.tbxExtrusion_EUR_TON.Text = currentEntity.Extrusion_EUR_TON_Computable.ToStringFormatted();
                this.tbxExtrusion_EUR.Text = currentEntity.Extrusion_EUR_Computable.ToStringFormatted();

                this.tbxPackaging_EUR_TON.Text = currentEntity.Packaging_EUR_TON_Computable.ToStringFormatted();
                this.tbxPackaging_EUR.Text = currentEntity.Packaging_EUR_Computable.ToStringFormatted();
                
                this.tbxTotalSalesPrice_EUR_TON.Text = this.currentEntity.TotalSalesPrice_EUR_TON_Computable.ToStringFormatted();
                this.tbxTotalSalesPrice_EUR.Text = this.currentEntity.TotalSalesPrice_EUR_Computable.ToStringFormatted();

                this.currentEntity.TotalSalesPrice = this.currentEntity.TotalSalesPrice_EUR_Computable;

                this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.OfferSave(this.currentEntity, this.ownerPage.CallContext);
                
                this.currentEntity =  this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);
                
                PresetData();


            }

           

            CheckIfResultIsSuccess();

            return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("InquiryData_Data"));
        }