예제 #1
0
        public override Tuple <CallContext, string> UserControlSave()
        {
            this.currentEntity = this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);

            if (this.currentEntity == null)
            {
                string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("UserMain_Data"));

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

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



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

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

            this.lbResultContext.Text = this.ownerPage.CallContext.Message;
            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID;
            }

            CheckIfResultIsSuccess();



            return(new Tuple <CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("OfferMain_Data")));
        }
예제 #2
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            if (this.currentEntity != null)
            {
                this.hdnRowMasterKey.Value = this.currentEntity.idOffer.ToString();

                LoadtbltblOfferDataExpenseGroup();
            }
            else
            {
                SetEmptyValues();
            }
        }
예제 #3
0
        public override void UserControlLoad()
        {
            base.ClearResultContext(this.lbResultContext);

            this.tblProductCosts.Rows.Clear();

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_ZERO_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

            this.currentOffer = this.ownerPage.CostCalculationRef.GetOfferByID(this.hdnRowMasterKey.Value);

            if (this.currentOffer == null)
            {
                this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error;

                base.AddMessage(this.lbResultContext, string.Format("Entity `Offer` not found by ID ({0})!", this.hdnRowMasterKey.Value));

                return;
            }

            ProductCostResult productCostResult = this.ownerPage.CostCalculationRef.LoadProductCostsInTableRowsByOfferId(this.hdnRowMasterKey.Value, this.ownerPage.CallContext);

            if (productCostResult.ResultContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                TableRow[] rows = productCostResult.TableRowsProductCosts;

                this.tblProductCosts.Rows.AddRange(rows);
            }
            else
            {
                base.AddErrorMessage(this.lbResultContext, productCostResult.ResultContext.Message);
            }
        }
예제 #4
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            InitLoadControls();

            SetEmptyValues();

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            if (this.currentEntity != null)
            {
                this.tbxCostOfDie.Text    = this.currentEntity.CostOfDie.ToStringNotFormatted();
                this.tbxLifespan.Text     = this.currentEntity.Lifespan.ToStringNotFormatted();
                this.tbxCostOfDieTon.Text = this.currentEntity.CostOfDieEUR_Per_TON_Computable.ToStringNotFormatted();


                this.hdnRowMasterKey.Value = this.currentEntity.idOffer.ToString();

                ClearResultContext();
            }
            else
            {
                SetEmptyValues();
            }
        }
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            if (this.currentEntity != null)
            {
                this.hdnRowMasterKey.Value = this.currentEntity.idOffer.ToString();

                LoadtbltblOfferDataExpenseGroup();

            }
            else
            {
                SetEmptyValues();
            }
            
        }
예제 #6
0
        public override Tuple <CallContext, string> UserControlSave()
        {
            if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING)
            {
                this.currentEntity = new Offer();
            }
            else
            {
                this.currentEntity = this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);

                if (this.currentEntity == null)
                {
                    string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("UserMain_Data"));

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

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


            if (!string.IsNullOrEmpty(this.tbxLifespan.Text))
            {
                Decimal tmpLifespan;
                if (Decimal.TryParse(this.tbxLifespan.Text, out tmpLifespan))
                {
                    this.currentEntity.Lifespan  = tmpLifespan;
                    this.currentEntity.CostOfDie = currentEntity.DiePrice;
                }
            }



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

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

            this.lbResultContext.Text = this.ownerPage.CallContext.Message;
            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID;
            }

            CheckIfResultIsSuccess();



            return(new Tuple <CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("OfferMain_Data")));
        }
예제 #7
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

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



            this.InquiryData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.InquiryData.SetHdnField(this.CurrentEntityMasterID);
            this.InquiryData.UserControlLoad();

            this.TabContainer.ActiveTab = this.tabInquiryData;

            this.DiesData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.DiesData.SetHdnField(this.CurrentEntityMasterID);
            this.DiesData.UserControlLoad();


            this.BilletScrap.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.BilletScrap.SetHdnField(this.CurrentEntityMasterID);
            this.BilletScrap.UserControlLoad();

            this.ProducitivityData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ProducitivityData.SetHdnField(this.CurrentEntityMasterID);
            this.ProducitivityData.UserControlLoad();

            this.ExpensesByCostCentersData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ExpensesByCostCentersData.SetHdnField(this.CurrentEntityMasterID);
            this.ExpensesByCostCentersData.UserControlLoad();

            this.ExpensesByCostCentersDataTon.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ExpensesByCostCentersDataTon.SetHdnField(this.CurrentEntityMasterID);
            this.ExpensesByCostCentersDataTon.UserControlLoad();

            this.ucProductCostData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ucProductCostData.SetHdnField(this.CurrentEntityMasterID);
            this.ucProductCostData.UserControlLoad();

            this.OfferOverviewData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.OfferOverviewData.SetHdnField(this.CurrentEntityMasterID);
            this.OfferOverviewData.UserControlLoad();

            if (this.currentEntity != null)
            {
                this.lbOfferData.Text =     " - Inquiry No " + this.currentEntity.InquiryNumber + "/ " + 
                                            this.currentEntity.OfferDate.ToString("dd.MM.yyyy") + ", " + 
                                            this.currentEntity.Customer;


                this.ucAttachments.CustomFolder = this.CurrentEntityMasterID + "_" + this.currentEntity.InquiryNumber;
                this.ucAttachments.UserControlLoad();
            }
            else
            {
                this.lbOfferData.Text = string.Empty;
                this.ucAttachments.ClearGrid();
            }

            this.pnlFormData.Visible = true;
        }
예제 #8
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            InitLoadControls();

            SetEmptyValues();

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            this.currentOfferProducitivity = this.ownerPage.CostCalculationRef.GetOfferProducitivityByOfferID(this.CurrentEntityMasterID);



            if (this.currentOffer != null)
            {
                this.hdnRowMasterKey.Value = this.currentOffer.idOffer.ToString();

                ClearResultContext();
            }


            if (this.currentOfferProducitivity != null)
            {
                KeyValue kvPress    = this.ownerPage.GetKeyValueByID(this.currentOfferProducitivity.idPress);

                if (kvPress != null)
                {
                    this.lbPress.Text = kvPress.Name;
                }


                if (this.currentOfferProducitivity.idCOMetal.HasValue)
                {
                    KeyValue kvCOMetal = this.ownerPage.GetKeyValueByID(this.currentOfferProducitivity.idCOMetal.Value);

                    if (kvCOMetal != null)
                    {
                        this.lbCoMetal.Text = kvCOMetal.Name;
                    }
                   

                    foreach(TableRow row in this.gvProducitivity.Rows)
                    {
                        row.Cells[3].Visible = true;
                    }
                }
                else
                {
                    foreach(TableRow row in this.gvProducitivity.Rows)
                    {
                        row.Cells[3].Visible = false;
                    }
                }



                this.tbxPressProducitivity_KG_MH.Text       = this.currentOfferProducitivity.PressProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxPressProducitivity_TON_MH.Text      = this.currentOfferProducitivity.PressProducitivity_TON_MH.ToStringFormatted4();
                this.tbxQCProducitivity_KG_MH.Text          = this.currentOfferProducitivity.QCProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxQCProducitivity_TON_MH.Text         = this.currentOfferProducitivity.QCProducitivity_TON_MH.ToStringFormatted4();
                this.tbxCOMetalProducitivity_KG_MH.Text     = this.currentOfferProducitivity.COMetalProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxCOMetalProducitivity_TON_MH.Text    = this.currentOfferProducitivity.COMetalProducitivity_TON_MH.ToStringFormatted4();
                this.tbxPackagingProducitivity_KG_MH.Text   = this.currentOfferProducitivity.PackagingProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxPackagingProducitivity_TON_MH.Text  = this.currentOfferProducitivity.PackagingProducitivity_TON_MH.ToStringFormatted4();
                
                ClearResultContext();
            }
            else
            {
                SetEmptyValues();
            }
            
        }
예제 #9
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            InitLoadControls();
            SetEmptyValues();

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            if (this.currentEntity != null)
            {

                //this.btnChoose.Enabled = false;

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


                if (this.currentEntity.idDiePriceListDetail.HasValue)
                {
                    this.diePriceListDetail = this.ownerPage.CostCalculationRef.GetDiePriceListDetailById(this.currentEntity.idDiePriceListDetail.Value.ToString());
                    this.diePriceList = this.ownerPage.CostCalculationRef.GetDiePriceListById(this.diePriceListDetail.idDiePriceList.ToString());
                    this.tbxVendor.Text = this.ownerPage.GetKeyValueByID(this.diePriceList.idVendor).Name;
                    this.tbxPriceListStr.Text = diePriceList.DateFromString + "-" + diePriceList.DateToString;
                }


                
                this.tbxInquiryNumber.Text = this.currentEntity.InquiryNumber;
                this.tbxOfferDate.SetTxbDateTimeValue(this.currentEntity.OfferDate);
                //this.tbxOfferDate.ReadOnly = true;
                this.tbxCustomer.Text = this.currentEntity.Customer;
              

                this.tbxValueForA.Text = this.currentEntity.ValueForA.ToStringFormatted();
                this.tbxValueForB.Text = this.currentEntity.ValueForB.ToStringFormatted();
                this.tbxValueForC.Text = this.currentEntity.ValueForC.ToStringFormatted();
                this.tbxValueForD.Text = this.currentEntity.ValueForD.ToStringFormatted();
                this.tbxValueForS.Text = this.currentEntity.ValueForS.ToStringFormatted();

                this.tbxPin.Text = this.currentEntity.ValueForPin.ToStringNotFormatted();
                this.tbxPout.Text = this.currentEntity.ValueForPout.ToStringNotFormatted();

                this.tbxLME.Text        = this.currentEntity.LME.ToStringNotFormatted();
                this.tbxPREMIUM.Text    = this.currentEntity.PREMIUM.ToStringNotFormatted();
                this.tbxMaterial.Text   = this.currentEntity.MaterialComputable.ToStringFormatted();
                this.tbxMaterial_EUR.Text = this.currentEntity.Material_EUR_Computable.ToStringFormatted();
                

                if (this.currentEntity.idMaterialPriceList.HasValue)
                {
                    MaterialPriceList material = this.ownerPage.CostCalculationRef.GetMaterialPriceListById(this.currentEntity.idMaterialPriceList.ToString());
                    this.tbxMaterialPriceList.Text = material.DateFromString + " - " + material.DateToString;
                    this.hdnIdMaterialPriceList.Value = material.idMaterialPriceList.ToString();
                }

                ReloadDimensionCTRLByProfileSettingID(this.currentEntity.idProfileSetting.ToString());
                  



                this.tbxDiameter.Text = this.currentEntity.Diameter.ToStringNotFormatted();
                this.tbxDieDiameter.Text = this.currentEntity.DieDiameter.ToStringNotFormatted();
                this.tbxDieDimensions.Text = this.currentEntity.DieDimensions.ToStringNotFormatted();


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


                //if(offerProducitivity != null)
                //{
                //    KeyValue kvPress = this.ownerPage.GetKeyValueByID(offerProducitivity.idPress);

                //    if(kvPress != null)
                //    {
                //        this.tbxPress.Text = kvPress.Name;
                //        this.ddlPress.SelectedValue = kvPress.idKeyValue.ToString();
                //    }
                //}
                
                this.tbxDiePrice.Text = this.currentEntity.DiePrice.ToStringNotFormatted();
                this.ddlPress.SelectedValue = this.currentEntity.idPress.ToString();

                this.tbxLengthOfFinalPC.Text = this.currentEntity.LengthOfFinalPC.ToStringNotFormatted();
                this.tbxWeightPerMeter.Text = this.currentEntity.WeightPerMeter.ToStringNotFormatted();
                this.tbxWeightPerPC.Text = this.currentEntity.WeightPerPC.ToStringNotFormatted();
                this.tbxDaysOfCredit.Text = this.currentEntity.DaysOfCredit.ToStringNotFormatted();
                this.tbxInterest.Text = this.currentEntity.Interest.ToStringNotFormatted();
                this.tbxGrossMargin.Text = this.currentEntity.GrossMargin.ToStringNotFormatted();
                this.tbxSavingsRate.Text = this.currentEntity.SavingsRate.ToStringNotFormatted();

                
                
                this.tbxPcsForTheWholeProject.Text = this.currentEntity.PcsForTheWholeProject.ToStringNotFormatted();


                this.ddlNumberOfCavities.SelectedValue = currentEntity.idNumberOfCavities.ToString();
                //this.ddlNumberOfCavities.DropDownEnabled = false;

                this.ddlAgent.SelectedValue = currentEntity.idAgent.ToString();
                this.ddlAging.SelectedValue = currentEntity.idAging.ToString();

                this.ddlHardness.SelectedValue = currentEntity.idHardness.ToString();
                this.ddlStandardPackaging.SelectedValue = currentEntity.idStandardPackaging.ToString();
                //this.ddlAging.DropDownEnabled = false;

                this.ddlCommision.SelectedValue = currentEntity.idCommision.ToString();
                this.ddlCalculationCommission.SelectedValue = currentEntity.idCalculationCommission.ToString();
                


                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.tbxTransportationCost.Text = this.currentEntity.TransportationCost.ToStringNotFormatted();
                this.tbxAdministrationExpenses.Text = this.currentEntity.AdministrationExpenses.ToStringNotFormatted();
                this.tbxSalesExpenses.Text = this.currentEntity.SalesExpenses.ToStringNotFormatted();
                this.tbxFinancialFixedExpenses.Text = this.currentEntity.FinancialFixedExpenses.ToStringNotFormatted();
                this.tbxFinancialVariableExpenses.Text = this.currentEntity.Financial_variable_Computable.ToStringNotFormatted();
                

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

                //

                this.tbxActualTotalSalesPriceToCustomer.Text = this.currentEntity.ActualTotalSalesPriceToCustomer.ToStringNotFormatted();

                this.tbxActualTotalSalesPriceToCustomerAll.Text = (this.currentEntity.ActualTotalSalesPriceToCustomer * this.currentEntity.Tonnage).ToStringFormatted();


                this.tbxTargetPrice.Text = this.currentEntity.TargetPrice_EUR_TON.ToStringNotFormatted();

                this.tbxTotalSalesPrice_EUR_TON.Text = this.currentEntity.TotalSalesPrice_EUR_TON_Computable.ToStringFormatted();

                this.tbxTotalSalesPrice_EUR.Text = this.currentEntity.TotalSalesPrice.ToStringFormatted();

                PresetData();

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

                this.hdnRowMasterKey.Value = this.currentEntity.idOffer.ToString();

                ClearResultContext();
            }
            else
            {
                SetEmptyValues();
            }
        }
예제 #10
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            InitLoadControls();

            SetEmptyValues();

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            if (this.currentEntity != null)
            {
                this.tbxLME.Text = this.currentEntity.LME.ToStringNotFormatted();
                this.tbxPREMIUM.Text = this.currentEntity.PREMIUM.ToStringNotFormatted();
                this.tbxMaterial.Text = this.currentEntity.MaterialComputable.ToStringNotFormatted();
                this.tbxConsumptionRatio.Text = this.currentEntity.ConsumptionRatio.ToStringNotFormatted();
                this.tbxScrapValuePercent.Text = this.currentEntity.ScrapValuePercent.ToStringNotFormatted();
                this.tbxConsumption.Text = this.currentEntity.Consumption_EUR_TON_Computable.ToStringNotFormatted();
                this.tbxScrapValue.Text = this.currentEntity.ScrapValue_EUR_TON_Computable.ToStringNotFormatted();
                this.tbxNetConsumption.Text = this.currentEntity.NetConsumptionComputable.ToStringNotFormatted();
                this.tbxCostOfScrap.Text = this.currentEntity.CostOfScrap.ToStringNotFormatted();

                


                this.hdnRowMasterKey.Value = this.currentEntity.idOffer.ToString();

                ClearResultContext();
            }
            else
            {
                SetEmptyValues();
            }
        }
예제 #11
0
 public List<string> GetPressIntCodeListByDimension(Offer offer)
 {
     return new ExpenseCalculationBL().GetPressIntCodeListByDimension(offer);
 }
예제 #12
0
 /// <summary>
 /// Create a new Offer object.
 /// </summary>
 /// <param name="idOffer">Initial value of the idOffer property.</param>
 /// <param name="inquiryNumber">Initial value of the InquiryNumber property.</param>
 /// <param name="offerDate">Initial value of the OfferDate property.</param>
 /// <param name="customer">Initial value of the Customer property.</param>
 /// <param name="idAging">Initial value of the idAging property.</param>
 public static Offer CreateOffer(global::System.Int32 idOffer, global::System.String inquiryNumber, global::System.DateTime offerDate, global::System.String customer, global::System.Int32 idAging)
 {
     Offer offer = new Offer();
     offer.idOffer = idOffer;
     offer.InquiryNumber = inquiryNumber;
     offer.OfferDate = offerDate;
     offer.Customer = customer;
     offer.idAging = idAging;
     return offer;
 }
예제 #13
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Offers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOffers(Offer offer)
 {
     base.AddObject("Offers", offer);
 }
예제 #14
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

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



            this.InquiryData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.InquiryData.SetHdnField(this.CurrentEntityMasterID);
            this.InquiryData.UserControlLoad();

            this.TabContainer.ActiveTab = this.tabInquiryData;

            this.DiesData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.DiesData.SetHdnField(this.CurrentEntityMasterID);
            this.DiesData.UserControlLoad();


            this.BilletScrap.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.BilletScrap.SetHdnField(this.CurrentEntityMasterID);
            this.BilletScrap.UserControlLoad();

            this.ProducitivityData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ProducitivityData.SetHdnField(this.CurrentEntityMasterID);
            this.ProducitivityData.UserControlLoad();

            this.ExpensesByCostCentersData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ExpensesByCostCentersData.SetHdnField(this.CurrentEntityMasterID);
            this.ExpensesByCostCentersData.UserControlLoad();

            this.ExpensesByCostCentersDataTon.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ExpensesByCostCentersDataTon.SetHdnField(this.CurrentEntityMasterID);
            this.ExpensesByCostCentersDataTon.UserControlLoad();

            this.ucProductCostData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.ucProductCostData.SetHdnField(this.CurrentEntityMasterID);
            this.ucProductCostData.UserControlLoad();

            this.OfferOverviewData.CurrentEntityMasterID = this.CurrentEntityMasterID;
            this.OfferOverviewData.SetHdnField(this.CurrentEntityMasterID);
            this.OfferOverviewData.UserControlLoad();

            if (this.currentEntity != null)
            {
                this.lbOfferData.Text = " - Inquiry No " + this.currentEntity.InquiryNumber + "/ " +
                                        this.currentEntity.OfferDate.ToString("dd.MM.yyyy") + ", " +
                                        this.currentEntity.Customer;


                this.ucAttachments.CustomFolder = this.CurrentEntityMasterID + "_" + this.currentEntity.InquiryNumber;
                this.ucAttachments.UserControlLoad();
            }
            else
            {
                this.lbOfferData.Text = string.Empty;
                this.ucAttachments.ClearGrid();
            }

            this.pnlFormData.Visible = true;
        }
예제 #15
0
        public override Tuple<CallContext, string> UserControlSave()
        {
            

            if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING)
            {
                this.currentEntity = new Offer();
            }
            else
            {
                this.currentEntity =  this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);

                if (this.currentEntity == null)
                {
                    string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("UserMain_Data"));

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

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

                
            }


            if (!string.IsNullOrEmpty(this.tbxLifespan.Text)) 
            {
                Decimal tmpLifespan;
                if(Decimal.TryParse(this.tbxLifespan.Text, out tmpLifespan))
                { 
                    this.currentEntity.Lifespan = tmpLifespan;
                    this.currentEntity.CostOfDie = currentEntity.DiePrice;

                }
            }


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

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

            this.lbResultContext.Text = this.ownerPage.CallContext.Message;
            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID;
            }

            CheckIfResultIsSuccess();



            return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("OfferMain_Data"));
        }
예제 #16
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"));
        }
예제 #17
0
        public CallContext OfferSave(Offer entity, CallContext callContext)
        {
            callContext.securitySettings = ETEMEnums.SecuritySettings.OfferSave;

            //CallContext resContext = new OfferBL().EntitySave<Offer>(entity, callContext);
            
            CallContext resContext = new OfferBL().OfferSave(entity, callContext);

            return resContext;
        }
예제 #18
0
  public List<Expense> GetListGroupExpense(Offer offer, CallContext callContext)
 {
     return  new ExpenseCalculationBL().GetListGroupExpense(offer, callContext);
 }
예제 #19
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            InitLoadControls();

            SetEmptyValues();

            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

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

            this.currentOfferProducitivity = this.ownerPage.CostCalculationRef.GetOfferProducitivityByOfferID(this.CurrentEntityMasterID);



            if (this.currentOffer != null)
            {
                this.hdnRowMasterKey.Value = this.currentOffer.idOffer.ToString();

                ClearResultContext();
            }


            if (this.currentOfferProducitivity != null)
            {
                KeyValue kvPress = this.ownerPage.GetKeyValueByID(this.currentOfferProducitivity.idPress);

                if (kvPress != null)
                {
                    this.lbPress.Text = kvPress.Name;
                }


                if (this.currentOfferProducitivity.idCOMetal.HasValue)
                {
                    KeyValue kvCOMetal = this.ownerPage.GetKeyValueByID(this.currentOfferProducitivity.idCOMetal.Value);

                    if (kvCOMetal != null)
                    {
                        this.lbCoMetal.Text = kvCOMetal.Name;
                    }


                    foreach (TableRow row in this.gvProducitivity.Rows)
                    {
                        row.Cells[3].Visible = true;
                    }
                }
                else
                {
                    foreach (TableRow row in this.gvProducitivity.Rows)
                    {
                        row.Cells[3].Visible = false;
                    }
                }



                this.tbxPressProducitivity_KG_MH.Text      = this.currentOfferProducitivity.PressProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxPressProducitivity_TON_MH.Text     = this.currentOfferProducitivity.PressProducitivity_TON_MH.ToStringFormatted4();
                this.tbxQCProducitivity_KG_MH.Text         = this.currentOfferProducitivity.QCProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxQCProducitivity_TON_MH.Text        = this.currentOfferProducitivity.QCProducitivity_TON_MH.ToStringFormatted4();
                this.tbxCOMetalProducitivity_KG_MH.Text    = this.currentOfferProducitivity.COMetalProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxCOMetalProducitivity_TON_MH.Text   = this.currentOfferProducitivity.COMetalProducitivity_TON_MH.ToStringFormatted4();
                this.tbxPackagingProducitivity_KG_MH.Text  = this.currentOfferProducitivity.PackagingProducitivity_KG_MH.ToStringNotFormatted();
                this.tbxPackagingProducitivity_TON_MH.Text = this.currentOfferProducitivity.PackagingProducitivity_TON_MH.ToStringFormatted4();

                ClearResultContext();
            }
            else
            {
                SetEmptyValues();
            }
        }
예제 #20
0
        public override Tuple<CallContext, string> UserControlSave()
        {
            this.currentEntity =  this.ownerPage.CostCalculationRef.GetOfferByID(this.CurrentEntityMasterID);

            if (this.currentEntity == null)
            {
                string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("UserMain_Data"));

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

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


           

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

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

            this.lbResultContext.Text = this.ownerPage.CallContext.Message;
            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID;
            }

            CheckIfResultIsSuccess();



            return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("OfferMain_Data"));
        }
예제 #21
0
        internal List<Expense> GetListGroupExpense(Offer offer, CallContext callContext)
        {
            List<Expense> result = new List<Expense>();
            List<string> keyValueIntCodeCostCenter = new List<string>();

            SAPData sapData = new SAPDataBL().GetSAPDataByDateActiveTo(offer.OfferDate);
            if (sapData == null)
            {
                return result;
            }


            keyValueIntCodeCostCenter = GetPressIntCodeListByDimension(offer);
            List<KeyValue> listKeyValueCostCenter = new KeyValueBL().GetAllKeyValueByKeyTypeIntCode("CostCenter");
           

            result = LoadExpenseGroupByIdSAPData(sapData.idSAPData).Where(c=>keyValueIntCodeCostCenter.Contains( c.CostCenter.KeyValueIntCode)).ToList();////PRESS



            Decimal totalExpence = Decimal.Zero;
            string pressNameKeyValue = string.Empty;



            if (offer.idPress.HasValue)
            {
                //ТОВА Е СЛУЧАЙ, пресата на базата на тежестта на Weight per meter (gr/m)
                
                KeyValue kvSelectedPress = listKeyValueCostCenter.Where(k => k.idKeyValue == offer.idPress).FirstOrDefault();

                if (kvSelectedPress == null || !keyValueIntCodeCostCenter.Contains(kvSelectedPress.KeyValueIntCode))
                {
                    return null;
                }

                pressNameKeyValue = listKeyValueCostCenter.Where(k => k.idKeyValue == offer.idPress).FirstOrDefault().KeyValueIntCode;

                
            }
            else
            {
                return null;
                ////ТОВА Е СЛУЧАЙ, пресата се избира на базата на раходите 
                //foreach (string pressName in keyValueIntCodeCostCenter)
                //{
                //    Decimal tmpExpence = result.Where(s => s.CostCenter.KeyValueIntCode == pressName).Sum(s => s.ExpenseValue_MH);
                //    if (totalExpence < tmpExpence)
                //    {
                //        totalExpence = tmpExpence;
                //        pressNameKeyValue = pressName;
                //    }
                //}
            }


            bool includeAging = offer.idAging == new KeyValueBL().GetKeyValueIdByIntCode("YES_NO", "Yes");



            keyValueIntCodeCostCenter.Clear();
            
            listKeyValueCostCenter = listKeyValueCostCenter.Where(k => 
                                    (includeAging? k.DefaultValue2 == pressNameKeyValue : k.KeyValueIntCode == pressNameKeyValue) || 
                                    k.DefaultValue1 == "QualityControl" ||
                                    k.DefaultValue1 == "DIES" ||
                                    k.DefaultValue1 == "Packaging" 
                                    ).ToList();


            foreach (var cc in listKeyValueCostCenter)
            {
                keyValueIntCodeCostCenter.Add(cc.KeyValueIntCode); 
            }
            


            result = LoadExpenseGroupByIdSAPData(sapData.idSAPData).Where(c=>keyValueIntCodeCostCenter.Contains( c.CostCenter.KeyValueIntCode)).ToList();

            return result;


        }
예제 #22
0
        internal List<string> GetPressIntCodeListByDimension(Offer offer)
        {
             DiePriceListDetail diePriceListDetail = new DiePriceListDetailBL().GetEntityById(offer.idDiePriceListDetail.Value);
            string dimensions = diePriceListDetail.DimensionA_String.Trim() + "x" + diePriceListDetail.DimensionB_String.Trim();

            List<KeyValue> listDieDimensions = new KeyValueBL().GetAllKeyValueByKeyTypeIntCode("DieDimensions")
                                                               .Where(k=>k.KeyValueIntCode == dimensions).ToList();

            List<string> keyValueIntCodeCostCenter = new List<string>();

            foreach (KeyValue keyvalue in listDieDimensions)
            {
                keyValueIntCodeCostCenter.AddRange(keyvalue.DefaultValue1.Split(','));//RETURN KEY VALUES OF PROPER PRESS
            }

            keyValueIntCodeCostCenter = keyValueIntCodeCostCenter.Distinct().ToList();//List of press

            return keyValueIntCodeCostCenter;
        }
예제 #23
0
       /// <summary>
       /// 	Number of cavities and choice of press:
       /// •	W>750gr/m -1 cavity;
       ///       -750gr/m≤W≤2085gr/m- Breda press;
       ///       -2085gr/m≤W≤2639gr/m- SMS2 press;
       ///       -W>2639gr/m-SMS 1;
       ///•    375gr/m≤ W≤750gr/m - 2cavities -only Breda press;
       ///•	   W<375gr/m  - 4cavities- only Breda press.
        /// </summary>
        /// <param name="offer"></param>
        private void SetOfferDataDependOnWeightPerMeter(Offer offer)
        {
            if (offer.WeightPerMeter.HasValue && offer.OfferDate != DateTime.MinValue)
            {

                AverageOutturnOverTimeDataView aoot = this.ownerPage.CostCalculationRef.GetActiveAverageOutturnOverTime(offer.OfferDate);



                if (offer.WeightPerMeter < 375)
                {
                    offer.idNumberOfCavities = this.ownerPage.GetKeyValueByIntCode("NumberOfCavities","FourCavities").idKeyValue;
                    offer.idPress = this.ownerPage.GetKeyValueByIntCode("CostCenter","Breda").idKeyValue;
                    offer.AverageOutturnOverTime = aoot.ValueOfPressBREDA;
                }
                else if(offer.WeightPerMeter >= 375 && offer.WeightPerMeter <= 750 )
                {
                    offer.idNumberOfCavities = this.ownerPage.GetKeyValueByIntCode("NumberOfCavities","TwoCavities").idKeyValue;
                    offer.idPress = this.ownerPage.GetKeyValueByIntCode("CostCenter","Breda").idKeyValue;
                    offer.AverageOutturnOverTime = aoot.ValueOfPressBREDA;
                }
                else if(offer.WeightPerMeter >= 750 && offer.WeightPerMeter <= 2085)
                {
                    offer.idNumberOfCavities = this.ownerPage.GetKeyValueByIntCode("NumberOfCavities","OneCavity").idKeyValue;
                    offer.idPress = this.ownerPage.GetKeyValueByIntCode("CostCenter","Breda").idKeyValue;
                    offer.AverageOutturnOverTime = aoot.ValueOfPressBREDA;
                }
                else if(offer.WeightPerMeter >= 2085 && offer.WeightPerMeter <= 2639)
                {
                    offer.idNumberOfCavities = this.ownerPage.GetKeyValueByIntCode("NumberOfCavities","OneCavity").idKeyValue;
                    offer.idPress = this.ownerPage.GetKeyValueByIntCode("CostCenter","SMS2").idKeyValue;
                    offer.AverageOutturnOverTime = aoot.ValueOfPressSMS2;
                }
                else if(offer.WeightPerMeter > 2639 )
                {
                    offer.idNumberOfCavities = this.ownerPage.GetKeyValueByIntCode("NumberOfCavities","OneCavity").idKeyValue;
                    offer.idPress = this.ownerPage.GetKeyValueByIntCode("CostCenter","SMS1").idKeyValue;
                    offer.AverageOutturnOverTime = aoot.ValueOfPressSMS1;
                }

                if (offer.idNumberOfCavities.HasValue)
                {
                    this.ddlNumberOfCavities.SelectedValue = offer.idNumberOfCavities.ToString();
                }

               
            }
            else
            {
                offer.idPress = null;
                offer.idNumberOfCavities = null;


            }
        }