示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.DiePriceListDetailsSave, false))
            {
                return;
            }


            if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING)
            {
                this.currentEntity = new DiePriceListDetail();

                this.currentEntity.idDiePriceList = this.ddlVendor.SelectedValueINT;
            }
            else
            {
                this.currentEntity = this.ownerPage.CostCalculationRef.GetDiePriceListDetailById(this.hdnRowMasterKey.Value);

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

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

                    return;
                }
            }

            this.currentEntity.idNumberOfCavities  = this.ddlNumberOfCavities.SelectedValueINT;
            this.currentEntity.idProfileCategory   = this.ddlProfileCategory.SelectedValueINT;
            this.currentEntity.idProfileComplexity = this.ddlProfileComplexity.SelectedValueINT;
            this.currentEntity.DimensionA          = BaseHelper.ConvertToIntOrMinValue(this.tbxDimensionA.Text.Trim());
            this.currentEntity.DimensionB          = BaseHelper.ConvertToIntOrMinValue(this.tbxDimensionB.Text.Trim());
            this.currentEntity.Price    = BaseHelper.ConvertToDecimalOrMinValue(this.tbxDiePrice.Text.Trim());
            this.currentEntity.Lifespan = BaseHelper.ConvertToDecimalOrMinValue(this.tbxLifespan.Text.Trim());

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

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

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

                base.AddMessage(this.lbResultContext, this.ownerPage.CallContext.Message);
            }
            else
            {
                if (!ShowErrors(new List <CallContext>()
                {
                    this.ownerPage.CallContext
                }))
                {
                    return;
                }
            }

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