Esempio n. 1
0
        private bool SaveData()
        {
            /*string message = "";
             * if (textBoxReportName.Text == "")
             *  message = "Please fill report name";
             * if (message != "")
             * {
             *  MessageBox.Show(message, new TermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             *  return false;
             * }
             */
            if (currentBiWeeklyReport.ShortName != textBoxShortName.Text)
            {
                currentBiWeeklyReport.ShortName = textBoxShortName.Text;
                UpdateFormName();
            }
            if (currentBiWeeklyReport.FullName != textBoxDescription.Text)
            {
                currentBiWeeklyReport.FullName = textBoxDescription.Text;
            }
            try
            {
                if (mode == ScreenMode.Edit)
                {
                    currentBiWeeklyReport.Save();
                }
                else
                {
                    BiWeekliesCollection.Instance.Add(currentBiWeeklyReport);
                    UpdateFormName();
                    mode = ScreenMode.Edit;
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while saving data", ex);
                return(false);
            }

            if (Saved != null)
            {
                Saved(this, EventArgs.Empty);
            }
            return(true);
        }
Esempio n. 2
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);
        }