Exemplo n.º 1
0
        /// <summary>
        /// Constructor for the date picker main window
        /// </summary>
        public WindowDatePicker(GeneralClasses.Handlers _GlobalHandler, string _FirstDateExplanation, string _EndDateExplanation)
        {
            try
            {
                //Initialization of all the components
                InitializeComponent();

                //Setting the variables
                m_Global_Handler = _GlobalHandler;

                //No need of a define content function here
                this.Title = m_Global_Handler.Resources_Handler.Get_Resources("PickDate");
                Lbl_FirstDateExplanation.Content = _FirstDateExplanation;
                Lbl_EndDateExplanation.Content   = _EndDateExplanation;
            }
            catch (Exception exception)
            {
                m_Global_Handler.Log_Handler.WriteException(MethodBase.GetCurrentMethod().Name, exception);
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generate the bill
        /// <param name="_Global_Handler">Global handler to get the ressources</param>
        /// <param name="_CreditNote">Credit note to generate</param>
        /// <param name="_Is_Visible">Word visible during generation or not</param>
        /// <param name="_FinalFilename">PDF output file name</param>
        /// <returns>0 if everything went well, 1 otherwise</returns>
        /// </summary>
        public int Generate_CreditNote(Handlers _Global_Handler, Mission _CreditNote, bool _Is_Visible, string _FinalFilename)
        {
            try
            {
                //Initialize
                m_GeneratedBillFileName = _FinalFilename;
                m_Global_Handler        = _Global_Handler;
                m_Mission = _CreditNote;

                //Connection to word
                m_AppWord = new Microsoft.Office.Interop.Word.Application();
                if (m_AppWord == null)
                {
                    System.Windows.MessageBox.Show(m_Global_Handler.Resources_Handler.Get_Resources("MicrosoftWordNotFound"),
                                                   m_Global_Handler.Resources_Handler.Get_Resources("MicrosoftWordNotFoundCaption"),
                                                   MessageBoxButton.OK, MessageBoxImage.Error);
                    return(-1);
                }
                m_AppWord.Visible = _Is_Visible;

                //Choose template
                m_AppDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                string fullFilePath = Path.Combine(m_AppDir, "Template\\TemplateCreditNote.docx");
                object templateName = fullFilePath;

                //Create document
                m_NewWordDoc = m_AppWord.Documents.Add(ref templateName, ref m_Missing, ref m_Missing, ref m_Missing);

                //Logo
                bool resLogo = Generate_Logo();
                if (resLogo == false)
                {
                    return(-1);
                }

                //Replace fields
                bool resFields = Replace_Fields();
                if (resFields == false)
                {
                    return(-1);
                }

                //Finalization
                bool resFinalization = Finalize();
                if (resFinalization == false)
                {
                    return(-1);
                }

                return(1);
            }
            catch (Exception error)
            {
                m_Global_Handler.Log_Handler.WriteMessage(System.Reflection.MethodBase.GetCurrentMethod().Name, error.StackTrace);
                System.Windows.MessageBox.Show(error.Message,
                                               m_Global_Handler.Resources_Handler.Get_Resources("Error"),
                                               MessageBoxButton.OK, MessageBoxImage.Error);

                //Close document and word
                if (m_NewWordDoc != null)
                {
                    ((_Document)m_NewWordDoc).Close();
                }
                if (m_AppWord != null)
                {
                    ((_Application)m_AppWord).Quit();
                }

                return(-1);
            }
        }