Esempio n. 1
0
        private void reportViewItem_DisplayerRequested(object sender, ReferenceEventArgs e)
        {
            if (tempReport.Report != null && tempFilePath != "")
            {
                if (!File.Exists(tempFilePath))
                {
                    tempReport.SaveReportToFile(out tempFilePath);
                }
                tempProcess = new Process();
                tempProcess.StartInfo.FileName = tempReport.RealName;
#if RELEASE
                try
                {
#endif
                tempProcess.Start();
#if RELEASE
            }
            catch (Exception ex)
            {
                CASMessage.Show(MessageType.LoadMessage, new object[] { ex.Message });
                processStartSuccessfully = false;
            }
#endif
            }
            e.Cancel = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Обновляет информацию в данном элементе управления
        /// </summary>
        /// <param name="reloadReport">Синхронизировать ли с базой данных</param>
        private void UpdateInformation(bool reloadReport)
        {
            if (reloadReport)
            {
#if RELEASE
                try
                {
#endif
                report.Reload();
                RemoveTempFile();
#if RELEASE
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading data" + Environment.NewLine + ex.Message, (string)new StaticProjectTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
#endif
            }
            textBoxShortName.Text   = report.ShortName;
            textBoxReportName.Text  = report.RealName;
            textBoxDescription.Text = report.FullName;
            if (mode == ScreenMode.Edit)
            {
                labelDownloadDateValue.Text = UsefulMethods.NormalizeDate(report.RecievedDate);
            }
            else
            {
                labelDownloadDateValue.Text = UsefulMethods.NormalizeDate(DateTime.Now);
            }



            tempReport = new BiWeekly(report.RealName, report.Report);
            if (tempReport.Report != null)
            {
                tempReport.SaveReportToFile(out tempFilePath);
            }

            bool permission = report.HasPermission(Users.CurrentUser, DataEvent.Update);



            if (mode == ScreenMode.Edit)
            {
                headerControl.ButtonEdit.Enabled = permission;
            }
            buttonLoad.Enabled          = permission;
            buttonSaveToFile.Enabled    = !(tempReport.Report == null);
            textBoxShortName.ReadOnly   = !permission;
            textBoxReportName.ReadOnly  = !permission;
            textBoxDescription.ReadOnly = !permission;

            buttonDeleteReport.Visible = (mode == ScreenMode.Edit);
            buttonDeleteReport.Enabled = report.HasPermission(Users.CurrentUser, DataEvent.Remove);
        }
Esempio n. 3
0
        private void OpenReport(object parameter)
        {
            BiWeekly biWeeklyReport  = (BiWeekly)parameter;
            string   path            = TermsProvider.GetTempFolderPath() + "\\" + biWeeklyReport.RealName;
            bool     successCreating = true;

            if (!File.Exists(path))
            {
                successCreating = biWeeklyReport.SaveReportToFile(path);
            }
            if (!successCreating)
            {
                return;
            }
            Process tempProcess = new Process();

            tempProcess.StartInfo = new ProcessStartInfo(path);
            try
            {
                tempProcess.Start();
                tempProcess.WaitForExit();
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading data", ex);
            }

            try
            {
                TryDeleteFile(path);
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while deleting data", ex);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Сохраняет данные текущего BiWeekly отчета
        /// </summary>
        /// <returns>Было ли успешным сохранение</returns>
        protected bool SaveData()
        {
            string message = "";

            if (tempReport.Report == null)
            {
                message = "Please load PDF report";
            }
            if (textBoxReportName.Text == "" && message == "")
            {
                message = "Please fill report name";
            }
            if (message != "")
            {
                MessageBox.Show(message, new TermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            if (report.ShortName != textBoxShortName.Text)
            {
                report.ShortName = textBoxShortName.Text;
            }
            if (report.RealName != textBoxReportName.Text)
            {
                if (mode == ScreenMode.Add)
                {
                    report.RealName = textBoxReportName.Text;
                }
                else
                {
                    RemoveTempFile();
                    report.RealName = textBoxReportName.Text;
                    report.SaveReportToFile(out tempFilePath);
                }
            }
            if (report.FullName != textBoxDescription.Text)
            {
                report.FullName = textBoxDescription.Text;
            }
            if (report.Report != tempReport.Report)
            {
                report.Report = tempReport.Report;
            }
#if RELEASE
            try
            {
#endif
            if (mode == ScreenMode.Edit)
            {
                report.Save();
            }
            else
            {
                BiWeekliesCollection.Instance.Add(report);
            }
#if RELEASE
        }

        catch (Exception ex)
        {
            MessageBox.Show("Error while saving data" + Environment.NewLine + ex.Message, (string)new StaticProjectTermsProvider()["SystemName"],
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(false);
        }
#endif
            return(true);
        }