Example #1
0
        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.GetSAPDataById(this.CurrentEntityMasterID);

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

                this.tbxDateFrom.SetTxbDateTimeValue(this.currentEntity.DateFrom);
                this.tbxDateTo.SetTxbDateTimeValue(this.currentEntity.DateTo);

                this.btnImport.Enabled = true;

                if ((this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0) ||
                    (this.currentEntity.SAPDataQuantities != null && this.currentEntity.SAPDataQuantities.Count > 0))
                {                    
                    this.tbxDateFrom.ReadOnly = true;
                    this.btnImport.Enabled = false;
                }

                if (this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0)
                {
                    LoadSAPDataExpensesAndQuantities();

                    this.divSAPDataExpensesAndQuantities.Visible = true;
                }
                else
                {
                    this.divSAPDataExpensesAndQuantities.Visible = false;
                }

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

            this.pnlFormData.Visible = true;
            this.pnlFormData.Focus();
        }
Example #2
0
 /// <summary>
 /// Create a new SAPData object.
 /// </summary>
 /// <param name="idSAPData">Initial value of the idSAPData property.</param>
 /// <param name="dateFrom">Initial value of the DateFrom property.</param>
 public static SAPData CreateSAPData(global::System.Int32 idSAPData, global::System.DateTime dateFrom)
 {
     SAPData sAPData = new SAPData();
     sAPData.idSAPData = idSAPData;
     sAPData.DateFrom = dateFrom;
     return sAPData;
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SAPDatas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSAPDatas(SAPData sAPData)
 {
     base.AddObject("SAPDatas", sAPData);
 }
Example #4
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.SAPDataImport, 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\\SAPData\\Import\\" + DateTime.Today.Year + "\\";

                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                fileFullName = folderPath + "\\Import_SAP_ExpensesAndQuantities_" +
                                               DateTime.Now.ToString(Constants.DATE_PATTERN_FOR_FILE_SUFFIX) +
                                               Constants.FILE_XLSX_EXTENSION;

                this.fuImport.PostedFile.SaveAs(fileFullName);

                this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ImportSAPDataExpensesAndQuantities(fileFullName, this.hdnRowMasterKey.Value, this.ownerPage.CallContext);

                if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
                {
                    base.AddMessage(this.lbResultContext, this.ownerPage.CallContext.Message);

                    this.CostCalculationRef.CalculateCostCentersTotal(this.hdnRowMasterKey.Value, this.ownerPage.CallContext);

                    this.currentEntity = this.ownerPage.CostCalculationRef.GetSAPDataById(this.hdnRowMasterKey.Value);

                    if (this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0)
                    {
                        LoadSAPDataExpensesAndQuantities();

                        this.divSAPDataExpensesAndQuantities.Visible = true;
                    }
                    else
                    {
                        this.divSAPDataExpensesAndQuantities.Visible = false;
                    }
                }
                else
                {
                    if (!ShowErrors(new List<CallContext>() { this.ownerPage.CallContext }))
                    {
                        return;
                    }
                }
            }
            else
            {
                this.ownerPage.ShowMSG("Please select file to import!", false);
            }
        }
Example #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.SAPDataSave, false))
            {
                return;
            }

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

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

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

                    return;
                }

                
            }

            this.currentEntity.DateFrom = this.tbxDateFrom.TextAsDateParseExactOrMinValue;
            this.currentEntity.DateTo = this.tbxDateTo.TextAsDateParseExact;

            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.SAPDataSave(new List<SAPData>() { 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;

                this.currentEntity = this.ownerPage.CostCalculationRef.GetSAPDataById(this.hdnRowMasterKey.Value);

                if (this.currentEntity != null && this.currentEntity.SAPDataExpenses != null && this.currentEntity.SAPDataExpenses.Count > 0)
                {
                    LoadSAPDataExpensesAndQuantities();

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

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