public override void UserControlLoad()
        {
            SetEmptyValues();
            base.ClearResultContext(this.lbResultContext);

            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_ZERO_STRING)
            {
                this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            }

            InitLoadControls();

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

            if (this.currentEntity != null)
            {
                this.SetHdnField(this.currentEntity.idDiePriceList.ToString());

                BaseHelper.CheckAndSetSelectedValue(this.ddlVendor.DropDownListCTRL, this.currentEntity.idVendor.ToString(), false);
                this.tbxDateFrom.SetTxbDateTimeValue(this.currentEntity.DateFrom);
                this.tbxDateTo.SetTxbDateTimeValue(this.currentEntity.DateTo);

                this.btnImportPriceListDetails.Enabled = true;

                if (this.currentEntity.DiePriceListDetails != null && this.currentEntity.DiePriceListDetails.Count > 0)
                {
                    this.ddlVendor.DropDownEnabled = false;
                    this.tbxDateFrom.ReadOnly = true;
                    this.btnImportPriceListDetails.Enabled = false;
                }

                base.ClearResultContext(this.lbResultContext);                
            }
            else
            {
                SetEmptyValues();
            }

            this.pnlFormData.Visible = true;
            this.pnlFormData.Focus();
        }
 /// <summary>
 /// Create a new DiePriceList object.
 /// </summary>
 /// <param name="idDiePriceList">Initial value of the idDiePriceList property.</param>
 /// <param name="idVendor">Initial value of the idVendor property.</param>
 /// <param name="dateFrom">Initial value of the DateFrom property.</param>
 public static DiePriceList CreateDiePriceList(global::System.Int32 idDiePriceList, global::System.Int32 idVendor, global::System.DateTime dateFrom)
 {
     DiePriceList diePriceList = new DiePriceList();
     diePriceList.idDiePriceList = idDiePriceList;
     diePriceList.idVendor = idVendor;
     diePriceList.DateFrom = dateFrom;
     return diePriceList;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the DiePriceLists EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDiePriceLists(DiePriceList diePriceList)
 {
     base.AddObject("DiePriceLists", diePriceList);
 }
        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();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.DiePriceListSave, false))
            {
                return;
            }

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

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

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

               
            }

            this.currentEntity.idVendor = this.ddlVendor.SelectedValueINT;
            this.currentEntity.DateFrom = this.tbxDateFrom.TextAsDateParseExactOrMinValue;
            this.currentEntity.DateTo = this.tbxDateTo.TextAsDateParseExact;

            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.DiePriceListSave(new List<DiePriceList>() { this.currentEntity }, this.ownerPage.CallContext);

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

                base.AddMessage(this.lbResultContext, this.ownerPage.CallContext.Message);

                this.btnImportPriceListDetails.Enabled = true;
            }
            else
            {
                if (!ShowErrors(new List<CallContext>() { this.ownerPage.CallContext }))
                {
                    return;
                }
            }

            if (this.ownerPage is DiePricesList)
            {
                ((DiePricesList)this.ownerPage).LoadFilteredList();
            }
        }