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.GetProductivityAndScrapDetailById(this.CurrentEntityMasterID);

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

                this.tbxDateFrom.SetTxbDateTimeValue(this.currentEntity.ProductivityAndScrap.DateFrom);
                this.tbxDateTo.SetTxbDateTimeValue(this.currentEntity.ProductivityAndScrap.DateTo);
                this.tbxStatus.Text = this.currentEntity.ProductivityAndScrap.Status;

                BaseHelper.CheckAndSetSelectedValue(this.ddlCostCenter.DropDownListCTRL, this.currentEntity.idCostCenter.ToString(), false);
                BaseHelper.CheckAndSetSelectedValue(this.ddlProfileSetting.DropDownListCTRL, this.currentEntity.idProfileSetting.ToString(), false);

                this.tbxSumOfHours.Text = this.currentEntity.SumOfHours_RoundString;
                this.tbxSumOfConsumption.Text = this.currentEntity.SumOfConsumption_RoundString;
                this.tbxSumOfProduction.Text = this.currentEntity.SumOfProduction_RoundString;

                this.tbxProductivityKGh.Text = this.currentEntity.ProductivityKGh_RoundString;
                this.tbxScrapRate.Text = this.currentEntity.ScrapRatePercent_RoundString;
                
                base.ClearResultContext(this.lbResultContext);
            }
            else
            {
                SetEmptyValues();
            }

            this.pnlFormData.Visible = true;
            this.pnlFormData.Focus();
        }
Пример #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProductivityAndScrapDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProductivityAndScrapDetails(ProductivityAndScrapDetail productivityAndScrapDetail)
 {
     base.AddObject("ProductivityAndScrapDetails", productivityAndScrapDetail);
 }
Пример #3
0
 /// <summary>
 /// Create a new ProductivityAndScrapDetail object.
 /// </summary>
 /// <param name="idProductivityAndScrapDetail">Initial value of the idProductivityAndScrapDetail property.</param>
 /// <param name="idProductivityAndScrap">Initial value of the idProductivityAndScrap property.</param>
 /// <param name="idCostCenter">Initial value of the idCostCenter property.</param>
 public static ProductivityAndScrapDetail CreateProductivityAndScrapDetail(global::System.Int32 idProductivityAndScrapDetail, global::System.Int32 idProductivityAndScrap, global::System.Int32 idCostCenter)
 {
     ProductivityAndScrapDetail productivityAndScrapDetail = new ProductivityAndScrapDetail();
     productivityAndScrapDetail.idProductivityAndScrapDetail = idProductivityAndScrapDetail;
     productivityAndScrapDetail.idProductivityAndScrap = idProductivityAndScrap;
     productivityAndScrapDetail.idCostCenter = idCostCenter;
     return productivityAndScrapDetail;
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.ProductivityAndScrapSave, false))
            {
                return;
            }

            bool isNew = true;
            if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING)
            {
                this.currentEntity = new ProductivityAndScrapDetail();
            }
            else
            {
                this.currentEntity = this.ownerPage.CostCalculationRef.GetProductivityAndScrapDetailById(this.hdnRowMasterKey.Value);

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

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

                    return;
                }

                isNew = false;
            }

            this.currentEntity.idCostCenter = this.ddlCostCenter.SelectedValueINT;
            this.currentEntity.idProfileSetting = this.ddlProfileSetting.SelectedValueINT;
            this.currentEntity.SumOfHours = BaseHelper.ConvertToDecimalOrMinValue(this.tbxSumOfHours.Text.Trim());
            this.currentEntity.SumOfConsumption = BaseHelper.ConvertToDecimalOrMinValue(this.tbxSumOfConsumption.Text.Trim());
            this.currentEntity.SumOfProduction = BaseHelper.ConvertToDecimalOrMinValue(this.tbxSumOfProduction.Text.Trim());

            decimal productivityKGh = decimal.Zero;
            decimal scrapRate = decimal.Zero;

            if (this.currentEntity.SumOfHours.HasValue && this.currentEntity.SumOfHours.Value != 0 &&
                this.currentEntity.SumOfProduction.HasValue)
            {
                productivityKGh = Math.Round((this.currentEntity.SumOfProduction.Value / this.currentEntity.SumOfHours.Value), 9, MidpointRounding.AwayFromZero);

                this.currentEntity.ProductivityKGh = productivityKGh;

                this.tbxProductivityKGh.Text = this.currentEntity.ProductivityKGh_RoundString;
            }
            if (this.currentEntity.SumOfConsumption.HasValue && this.currentEntity.SumOfConsumption.Value != 0 &&
                this.currentEntity.SumOfProduction.HasValue)
            {
                scrapRate = Math.Round(((this.currentEntity.SumOfConsumption.Value - this.currentEntity.SumOfProduction.Value) / this.currentEntity.SumOfConsumption.Value), 9, MidpointRounding.AwayFromZero);

                this.currentEntity.ScrapRate = scrapRate;

                this.tbxScrapRate.Text = this.currentEntity.ScrapRate_RoundString;
            }

            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ProductivityAndScrapDetailSave(new List<ProductivityAndScrapDetail>() { 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);
            }
            else
            {
                if (!ShowErrors(new List<CallContext>() { this.ownerPage.CallContext }))
                {
                    return;
                }
            }

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