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.GetProductivityAndScrapById(this.CurrentEntityMasterID); if (this.currentEntity != null) { this.SetHdnField(this.currentEntity.idProductivityAndScrap.ToString()); this.tbxDateFrom.SetTxbDateTimeValue(this.currentEntity.DateFrom); this.tbxDateTo.SetTxbDateTimeValue(this.currentEntity.DateTo); this.btnImport.Enabled = true; if ((this.currentEntity.ProductivityAndScrapDetails != null && this.currentEntity.ProductivityAndScrapDetails.Count > 0)) { this.tbxDateFrom.ReadOnly = true; this.btnImport.Enabled = false; } base.ClearResultContext(this.lbResultContext); } else { SetEmptyValues(); } this.pnlFormData.Visible = true; this.pnlFormData.Focus(); }
/// <summary> /// Deprecated Method for adding a new object to the ProductivityAndScraps EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProductivityAndScraps(ProductivityAndScrap productivityAndScrap) { base.AddObject("ProductivityAndScraps", productivityAndScrap); }
/// <summary> /// Create a new ProductivityAndScrap object. /// </summary> /// <param name="idProductivityAndScrap">Initial value of the idProductivityAndScrap property.</param> /// <param name="dateFrom">Initial value of the DateFrom property.</param> public static ProductivityAndScrap CreateProductivityAndScrap(global::System.Int32 idProductivityAndScrap, global::System.DateTime dateFrom) { ProductivityAndScrap productivityAndScrap = new ProductivityAndScrap(); productivityAndScrap.idProductivityAndScrap = idProductivityAndScrap; productivityAndScrap.DateFrom = dateFrom; return productivityAndScrap; }
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 ProductivityAndScrap(); } else { this.currentEntity = this.ownerPage.CostCalculationRef.GetProductivityAndScrapById(this.hdnRowMasterKey.Value); if (this.currentEntity == null) { this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error; base.AddMessage(this.lbResultContext, string.Format("Entity `ProductivityAndScrap` not found by ID ({0})!", this.hdnRowMasterKey.Value)); return; } isNew = false; } this.currentEntity.DateFrom = this.tbxDateFrom.TextAsDateParseExactOrMinValue; this.currentEntity.DateTo = this.tbxDateTo.TextAsDateParseExact; this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ProductivityAndScrapSave(new List<ProductivityAndScrap>() { 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.btnImport.Enabled = true; } else { if (!ShowErrors(new List<CallContext>() { this.ownerPage.CallContext })) { return; } } if (this.ownerPage is ProductivityAndScrapList) { ((ProductivityAndScrapList)this.ownerPage).LoadFilteredList(); } }
protected void btnImport_Click(object sender, EventArgs e) { if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.ProductivityAndScrapImport, false)) { return; } base.RunJavaScriptModalWindow(); if (this.fuImport.HasFile) { string selectedFileMimeType = this.fuImport.PostedFile.ContentType; string excelMimeType = BaseHelper.GetMimeType(Constants.FILE_XLSX_EXTENSION); if (!string.Equals(selectedFileMimeType, excelMimeType, StringComparison.InvariantCultureIgnoreCase)) { this.ownerPage.ShowMSG("Selected file is in incorrect format, it must be Excel-2007 or newer version!", false); return; } string fileFullName = string.Empty; string folderPath = string.Empty; folderPath = GeneralPage.GetSettingByCode(ETEMModel.Helpers.ETEMEnums.AppSettings.ResourcesFolderName).SettingValue; folderPath += "\\CostCalculation\\ProductivityAndScrap\\Import\\" + DateTime.Today.Year + "\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } fileFullName = folderPath + "\\Import_ProductivityAndScrap_" + DateTime.Now.ToString(Constants.DATE_PATTERN_FOR_FILE_SUFFIX) + Constants.FILE_XLSX_EXTENSION; this.fuImport.PostedFile.SaveAs(fileFullName); this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ImportProductivityAndScrapCostData(fileFullName, this.hdnRowMasterKey.Value, this.ownerPage.CallContext); if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success) { base.AddMessage(this.lbResultContext, this.ownerPage.CallContext.Message); this.currentEntity = this.ownerPage.CostCalculationRef.GetProductivityAndScrapById(this.hdnRowMasterKey.Value); if (this.ownerPage is ProductivityAndScrapList) { ((ProductivityAndScrapList)this.ownerPage).LoadFilteredList(); } } else { if (!ShowErrors(new List<CallContext>() { this.ownerPage.CallContext })) { return; } } } else { this.ownerPage.ShowMSG("Please select file to import!", false); } }