Esempio n. 1
0
        void buttonTableConsult_Clicked(object sender, EventArgs e)
        {
            try
            {
                //Get Current OrderMain
                OrderMain currentOrderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                //Initialize ArticleBag to Send to ProcessFinanceDocuments or Compare
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(currentOrderMain);

                //Get Latest DocumentConference Document without Recreate it if Diference, compare it in Above Line
                FIN_DocumentFinanceMaster lastDocument = FrameworkUtils.GetOrderMainLastDocumentConference(false);

                //Reprint Existing Document After compare with current ArticleBag
                if (
                    lastDocument != null && articleBag != null &&
                    lastDocument.TotalFinal.Equals(articleBag.TotalFinal) && lastDocument.DocumentDetail.Count.Equals(articleBag.Count)
                    )
                {
                    FrameworkCalls.PrintFinanceDocument(this, lastDocument);
                }
                //Else Create new DocumentConference recalling FrameworkUtils.GetOrderMainLastDocumentConference with true to Create New One
                else
                {
                    try
                    {
                        //Call Recreate New Document
                        FIN_DocumentFinanceMaster newDocument = FrameworkUtils.GetOrderMainLastDocumentConference(true);

                        //Call Print New Document
                        FrameworkCalls.PrintFinanceDocument(this, newDocument);
                    }
                    catch (Exception ex)
                    {
                        string errorMessage = string.Empty;

                        switch (ex.Message)
                        {
                        case "ERROR_MISSING_SERIE":
                            errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_missing_series);
                            break;

                        case "ERROR_COMMIT_FINANCE_DOCUMENT_PAYMENT":
                        default:
                            errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, ex.Message);
                            break;
                        }
                        Utils.ShowMessageTouch(
                            _sourceWindow,
                            DialogFlags.Modal,
                            new Size(600, 400),
                            MessageType.Error,
                            ButtonsType.Close,
                            Resx.global_error,
                            errorMessage
                            );

                        this.Run();
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            finally
            {
                this.Destroy();
            }
        }