Exemple #1
0
        /// <summary>
        /// Register Custom Variables to Use With Func Var and Assign it to GlobalFramework.FastReportCustomVars
        /// </summary>
        public static void RegisterCustomVars(string pAppName)
        {
            Dictionary <string, string> customVars = new Dictionary <string, string>();

            //App
            customVars.Add("APP_COMPANY", SettingsApp.AppCompanyName);
            customVars.Add("APP_NAME", pAppName);
            customVars.Add("APP_VERSION", FrameworkUtils.ProductVersion);
            customVars.Add("DATE", FrameworkUtils.CurrentDateTimeAtomic().ToString(SettingsApp.DateFormat));
            if (SettingsApp.ConfigurationSystemCurrency != null)
            {
                customVars.Add("SYSTEM_CURRENCY_LABEL", SettingsApp.ConfigurationSystemCurrency.Designation);
                customVars.Add("SYSTEM_CURRENCY_ACRONYM", SettingsApp.ConfigurationSystemCurrency.Acronym);
                customVars.Add("SYSTEM_CURRENCY_SYMBOL", SettingsApp.ConfigurationSystemCurrency.Symbol);
            }
            //Licence
            customVars.Add("LICENCE_NAME", GlobalFramework.LicenceName);
            customVars.Add("LICENCE_COMPANY", GlobalFramework.LicenceCompany);
            customVars.Add("LICENCE_NIF", GlobalFramework.LicenceNif);
            customVars.Add("LICENCE_ADDRESS", GlobalFramework.LicenceAddress);
            customVars.Add("LICENCE_EMAIL", GlobalFramework.LicenceEmail);
            customVars.Add("LICENCE_TELEPHONE", GlobalFramework.LicenceTelephone);
            //PreferencesParameters
            customVars.Add("COMPANY_NAME", Pref("COMPANY_NAME"));
            customVars.Add("COMPANY_BUSINESS_NAME", Pref("COMPANY_BUSINESS_NAME"));
            customVars.Add("COMPANY_ADDRESS", Pref("COMPANY_ADDRESS"));
            customVars.Add("COMPANY_CITY", Pref("COMPANY_CITY"));
            customVars.Add("COMPANY_POSTALCODE", Pref("COMPANY_POSTALCODE"));
            customVars.Add("COMPANY_REGION", Pref("COMPANY_REGION"));
            customVars.Add("COMPANY_COUNTRY", Pref("COMPANY_COUNTRY"));
            customVars.Add("COMPANY_COUNTRY_CODE2", Pref("COMPANY_COUNTRY_CODE2"));
            customVars.Add("COMPANY_TELEPHONE", Pref("COMPANY_TELEPHONE"));
            customVars.Add("COMPANY_MOBILEPHONE", Pref("COMPANY_MOBILEPHONE"));
            customVars.Add("COMPANY_FAX", Pref("COMPANY_FAX"));
            customVars.Add("COMPANY_EMAIL", Pref("COMPANY_EMAIL"));
            customVars.Add("COMPANY_WEBSITE", Pref("COMPANY_WEBSITE"));
            customVars.Add("COMPANY_FISCALNUMBER", Pref("COMPANY_FISCALNUMBER"));
            customVars.Add("COMPANY_CAE", Pref("COMPANY_CAE"));
            customVars.Add("COMPANY_STOCK_CAPITAL", Pref("COMPANY_STOCK_CAPITAL"));
            customVars.Add("COMPANY_CIVIL_REGISTRATION", Pref("COMPANY_CIVIL_REGISTRATION"));
            customVars.Add("COMPANY_CIVIL_REGISTRATION_ID", Pref("COMPANY_CIVIL_REGISTRATION_ID"));
            customVars.Add("COMPANY_TAX_ENTITY", Pref("COMPANY_TAX_ENTITY"));
            //Report
            customVars.Add("REPORT_FILENAME_LOGO", Pref("REPORT_FILENAME_LOGO"));
            customVars.Add("REPORT_FOOTER_LINE1", Pref("REPORT_FOOTER_LINE1"));
            customVars.Add("REPORT_FOOTER_LINE2", Pref("REPORT_FOOTER_LINE2"));
            //Ticket
            customVars.Add("TICKET_FILENAME_LOGO", Pref("TICKET_FILENAME_LOGO"));
            customVars.Add("TICKET_FOOTER_LINE1", Pref("TICKET_FOOTER_LINE1"));
            customVars.Add("TICKET_FOOTER_LINE2", Pref("TICKET_FOOTER_LINE2"));
            //Session
            customVars.Add("SESSION_LOGGED_USER", String.Empty);//Not Yet Assigned (BootStrap), This is Assigned on Report Constructor

            if (GlobalFramework.Settings["POS_CURRENTTERMINAL"] != null)
            {
                customVars.Add("SESSION_LOGGED_TERMINAL", GlobalFramework.Settings["POS_CURRENTTERMINAL"]);
            }

            GlobalFramework.FastReportCustomVars = customVars;
        }
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //ExportSaftPt

        public static string ExportSaft(Window pSourceWindow, ExportSaftPtMode pExportSaftPtMode)
        {
            string   result = string.Empty;
            DateTime dateCurrent = FrameworkUtils.CurrentDateTimeAtomic();
            DateTime dateStart, dateEnd;

            switch (pExportSaftPtMode)
            {
            case ExportSaftPtMode.WholeYear:
                dateStart = new DateTime(dateCurrent.Year, 1, 1);
                dateEnd   = new DateTime(dateCurrent.Year, 12, 31);
                result    = ExportSaft(pSourceWindow, dateStart, dateEnd);
                break;

            case ExportSaftPtMode.LastMonth:
                dateStart = dateCurrent.AddMonths(-1);
                dateStart = new DateTime(dateStart.Year, dateStart.Month, 1);
                dateEnd   = dateStart.AddMonths(1).AddDays(-1);
                result    = ExportSaft(pSourceWindow, dateStart, dateEnd);
                break;

            case ExportSaftPtMode.Custom:
                PosDatePickerStartEndDateDialog dialog = new PosDatePickerStartEndDateDialog(pSourceWindow, Gtk.DialogFlags.DestroyWithParent);
                ResponseType response = (ResponseType)dialog.Run();
                if (response == ResponseType.Ok)
                {
                    result = ExportSaft(pSourceWindow, dialog.DateStart, dialog.DateEnd);
                }
                dialog.Destroy();
                break;
            }

            return(result);
        }
Exemple #3
0
        //Start Application or Change User
        private void ProcessLogin(SYS_UserDetail pUserDetail)
        {
            GlobalFramework.LoggedUser            = pUserDetail;
            GlobalFramework.LoggedUserPermissions = FrameworkUtils.GetUserPermissions();
            FrameworkUtils.Audit("USER_LOGIN", string.Format(Resx.audit_message_user_login, pUserDetail.Name));

            //SessionApp Add LoggedUser
            if (!GlobalFramework.SessionApp.LoggedUsers.ContainsKey(GlobalFramework.LoggedUser.Oid))
            {
                GlobalFramework.SessionApp.LoggedUsers.Add(pUserDetail.Oid, FrameworkUtils.CurrentDateTimeAtomic());
            }
            else
            {
                GlobalFramework.SessionApp.LoggedUsers[GlobalFramework.LoggedUser.Oid] = FrameworkUtils.CurrentDateTimeAtomic();
            }
            GlobalFramework.SessionApp.Write();

            //Returns to default mode
            _mode = NumberPadPinMode.Password;
            UpdateStatusLabels();

            //Process Notifications After Login/Create First Time PosWindow
            //Disabled SystemNotification and ShowNotifications. Moved to Startup Window
            //FrameworkUtils.SystemNotification();
            //Utils.ShowNotifications(_sourceWindow, pUserDetail.Oid);
            Utils.ShowFrontOffice(_sourceWindow);
        }
Exemple #4
0
 public bool Write()
 {
     if (GlobalFramework.SessionApp != null && (GlobalFramework.SessionApp.OrdersMain.Count == 0 && GlobalFramework.SessionApp.LoggedUsers.Count == 0))
     {
         //Empty Session May Delete
         try
         {
             if (File.Exists(_file))
             {
                 File.Delete(_file);
             }
             return(true);
         }
         catch (Exception ex)
         {
             _log.Error(ex.Message, ex);
             return(false);
         }
     }
     else
     {
         //Write Session
         try
         {
             _sessionUpdatedAt = FrameworkUtils.CurrentDateTimeAtomic();
             JsonSerialization.WriteToJsonFile <GlobalFrameworkSession>(_file, this, false, _jsonIndented);
             return(true);
         }
         catch (Exception ex)
         {
             _log.Error(ex.Message, ex);
             return(false);
         }
     }
 }
        //Get DocumentFinanceYearSerieTerminal for Terminal
        public static fin_documentfinanceyearserieterminal GetDocumentFinanceYearSerieTerminal(Session pSession, Guid pDocumentType, Guid pLoggedTerminal)
        {
            DateTime currentDateTime = FrameworkUtils.CurrentDateTimeAtomic();
            fin_documentfinanceyearserieterminal documentFinanceYearSerieTerminal = null;
            fin_documentfinancetype documentFinanceType = (fin_documentfinancetype)FrameworkUtils.GetXPGuidObject(pSession, typeof(fin_documentfinancetype), pDocumentType);

            //If DocumentTypeInvoiceWayBill Replace/Override Helper Document Type InvoiceWayBill with InvoiceWay to get Invoice Serie,
            //this way we have Invoice Serie but DocumentMaster keeps DocumentFinanceType has DocumentFinanceTypeInvoiceWayBill
            //Usefull for Future Documents WayBill distinct code, ex have WayBill, ex Re-Print Documents in WayBillMode etc
            Guid documentFinanceTypeSerieGuid = (documentFinanceType.Oid == SettingsApp.XpoOidDocumentFinanceTypeInvoiceWayBill)
                ? SettingsApp.XpoOidDocumentFinanceTypeInvoice
                : documentFinanceType.Oid
            ;

            //Get Document Serie
            SortingCollection sortCollection = new SortingCollection();

            sortCollection.Add(new SortProperty("FiscalYear", DevExpress.Xpo.DB.SortingDirection.Ascending));
            CriteriaOperator criteria = CriteriaOperator.Parse(string.Format("(Disabled = 0 OR Disabled IS NULL) AND DocumentType == '{0}'", documentFinanceTypeSerieGuid.ToString()));
            ICollection      collectionDocumentFinanceSeries = pSession.GetObjects(pSession.GetClassInfo(typeof(fin_documentfinanceyearserieterminal)), criteria, sortCollection, int.MaxValue, false, true);

            foreach (fin_documentfinanceyearserieterminal item in collectionDocumentFinanceSeries)
            {
                if (currentDateTime.Year >= item.FiscalYear.FiscalYear)
                {
                    if (item.Terminal.Oid == pLoggedTerminal)
                    {
                        documentFinanceYearSerieTerminal = item;
                    }
                }
            }

            return(documentFinanceYearSerieTerminal);
        }
Exemple #6
0
        //ChangeTable - Change Order From Table to Table
        void _buttonKeyChangeTable_Clicked(object sender, EventArgs e)
        {
            PosTablesDialog dialog   = new PosTablesDialog(this.SourceWindow, DialogFlags.DestroyWithParent, TableFilterMode.OnlyFreeTables);
            ResponseType    response = (ResponseType)dialog.Run();

            if (response == ResponseType.Ok || response == ResponseType.Cancel || response == ResponseType.DeleteEvent)
            {
                if (response == ResponseType.Ok)
                {
                    OrderMain currentOrderMain            = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                    POS_ConfigurationPlaceTable xOldTable = (POS_ConfigurationPlaceTable)FrameworkUtils.GetXPGuidObject(typeof(POS_ConfigurationPlaceTable), currentOrderMain.Table.Oid);
                    POS_ConfigurationPlaceTable xNewTable = (POS_ConfigurationPlaceTable)FrameworkUtils.GetXPGuidObject(typeof(POS_ConfigurationPlaceTable), dialog.CurrentTableOid);
                    //Require to Prevent A first chance exception of type 'DevExpress.Xpo.DB.Exceptions.LockingException' occurred in DevExpress.Xpo.v13.2.dll when it is Changed in Diferent Session ex UnitOfWork
                    //TODO: Confirm working with Reload Commented
                    //xOldTable.Reload();
                    //xNewTable.Reload();

                    if (xNewTable.TableStatus != TableStatus.Free)
                    {
                        Utils.ShowMessageTouch(
                            GlobalApp.WindowPos, DialogFlags.Modal, MessageType.Warning, ButtonsType.Ok, Resx.global_error,
                            Resx.dialog_message_table_is_not_free
                            );
                    }
                    else
                    {
                        //Put Old table Status to Free
                        xOldTable.TableStatus = TableStatus.Free;
                        xOldTable.Save();
                        FrameworkUtils.Audit("TABLE_OPEN", string.Format(Resx.audit_message_table_open, xOldTable.Designation));

                        //Put New table Status to Open
                        xNewTable.TableStatus = TableStatus.Open;
                        xNewTable.Save();
                        FrameworkUtils.Audit("TABLE_CLOSE", string.Format(Resx.audit_message_table_close, xNewTable.Designation));

                        //Change DocumentOrderMain table, If OpenOrder Exists in That table
                        Guid documentOrderMainOid = currentOrderMain.GetOpenTableFieldValueGuid(xOldTable.Oid, "Oid");
                        FIN_DocumentOrderMain xDocumentOrderMain = (FIN_DocumentOrderMain)FrameworkUtils.GetXPGuidObject(typeof(FIN_DocumentOrderMain), documentOrderMainOid);
                        if (xDocumentOrderMain != null)
                        {
                            xDocumentOrderMain.PlaceTable = xNewTable;
                            xDocumentOrderMain.UpdatedAt  = FrameworkUtils.CurrentDateTimeAtomic();
                            xDocumentOrderMain.Save();
                        }
                        //Assign Session Data
                        currentOrderMain.Table.Oid       = xNewTable.Oid;
                        currentOrderMain.Table.Name      = xNewTable.Designation;
                        currentOrderMain.Table.PriceType = (PriceType)xNewTable.Place.PriceType.EnumValue;
                        currentOrderMain.OrderTickets[currentOrderMain.CurrentTicketId].PriceType = (PriceType)xNewTable.Place.PriceType.EnumValue;
                        currentOrderMain.Table.PlaceId = xNewTable.Place.Oid;
                        GlobalFramework.SessionApp.Write();
                        //Finally Update Status Bar, Table Name, Totals Etc
                        UpdateOrderStatusBar();
                    }
                }
                dialog.Destroy();
            }
            ;
        }
Exemple #7
0
 public OrderTicket(OrderMain pOrderMain, PriceType pPriceType)
 {
     //Reference to Parent OrderMain
     _orderMain    = pOrderMain;
     _priceType    = pPriceType;
     _dateStart    = FrameworkUtils.CurrentDateTimeAtomic();
     _orderDetails = new OrderDetail(this);
 }
Exemple #8
0
 //Constructor without Json.NET Load, With Defaults
 public OrderMain(Guid pOrderMainOid, Guid pTableOid)
 {
     _currentTicketId = 1;
     _persistentOid   = new Guid();
     _orderStatus     = OrderStatus.Null;
     _table           = new OrderMainTable(pOrderMainOid, pTableOid);
     _dateStart       = FrameworkUtils.CurrentDateTimeAtomic();
     _orderTickets    = new Dictionary <int, OrderTicket>();
 }
Exemple #9
0
        private void InitUI()
        {
            //Initial Values
            FIN_ConfigurationPaymentMethod initialValueConfigurationPaymentMethod = (FIN_ConfigurationPaymentMethod)FrameworkUtils.GetXPGuidObject(typeof(FIN_ConfigurationPaymentMethod), SettingsApp.XpoOidConfigurationPaymentMethodDefaultInvoicePaymentMethod);
            CFG_ConfigurationCurrency      intialValueConfigurationCurrency       = SettingsApp.ConfigurationSystemCurrency;
            string initialPaymentDate = FrameworkUtils.CurrentDateTimeAtomic().ToString(SettingsApp.DateTimeFormat);

            //ConfigurationPaymentMethod
            string           filterValidPaymentMethod = "(Token = 'CREDIT_CARD' OR Token = 'BANK_CHECK' OR Token = 'MONEY' OR Token = 'BANK_TRANSFER' OR Token = 'CASH_MACHINE' OR Token = 'VISA' OR Token = 'OTHER')";
            CriteriaOperator criteriaOperatorConfigurationPaymentMethod = CriteriaOperator.Parse(string.Format("(Disabled IS NULL OR Disabled  <> 1)  AND Oid <> '{0}' AND {1}", SettingsApp.XpoOidConfigurationPaymentMethodCurrentAccount.ToString(), filterValidPaymentMethod));

            _entryBoxSelectConfigurationPaymentMethod = new XPOEntryBoxSelectRecordValidation <FIN_ConfigurationPaymentMethod, TreeViewConfigurationPaymentMethod>(_sourceWindow, Resx.global_payment_method, "Designation", "Oid", initialValueConfigurationPaymentMethod, criteriaOperatorConfigurationPaymentMethod, SettingsApp.RegexGuid, true);
            _entryBoxSelectConfigurationPaymentMethod.EntryValidation.Changed   += delegate { Validate(); };
            _entryBoxSelectConfigurationPaymentMethod.EntryValidation.IsEditable = false;

            //ConfigurationCurrency
            CriteriaOperator criteriaOperatorConfigurationCurrency = CriteriaOperator.Parse(string.Format("(Disabled IS NULL OR Disabled  <> 1) AND (ExchangeRate IS NOT NULL OR Oid = '{0}')", SettingsApp.ConfigurationSystemCurrency.Oid.ToString()));

            _entryBoxSelectConfigurationCurrency = new XPOEntryBoxSelectRecordValidation <CFG_ConfigurationCurrency, TreeViewConfigurationCurrency>(_sourceWindow, Resx.global_currency, "Designation", "Oid", intialValueConfigurationCurrency, criteriaOperatorConfigurationCurrency, SettingsApp.RegexGuid, false);
            _entryBoxSelectConfigurationCurrency.EntryValidation.Changed   += _entryBoxSelectConfigurationCurrency_Changed;
            _entryBoxSelectConfigurationCurrency.EntryValidation.IsEditable = false;

            //PaymentAmount
            _entryPaymentAmount = new EntryBoxValidation(_sourceWindow, Resx.global_total_deliver, KeyboardMode.Numeric, SettingsApp.RegexDecimalGreaterEqualThanZero, true);
            _entryPaymentAmount.EntryValidation.Text = FrameworkUtils.DecimalToString(_paymentAmountTotal);
            _entryPaymentAmount.EntryValidation.Validate();
            _entryPaymentAmount.EntryValidation.Changed += delegate {
                Validate();
                UpdateTitleBar();
            };

            //PaymentDate
            _entryBoxPaymentDate = new EntryBoxValidation(_sourceWindow, Resx.global_date, KeyboardMode.Alfa, SettingsApp.RegexDateTime, true);
            _entryBoxPaymentDate.EntryValidation.Text = initialPaymentDate;
            _entryBoxPaymentDate.EntryValidation.Validate();
            _entryBoxPaymentDate.EntryValidation.Changed += delegate { Validate(); };

            //PaymentNotes
            _entryBoxDocumentPaymentNotes = new EntryBoxValidation(_sourceWindow, Resx.global_notes, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, false);
            _entryBoxDocumentPaymentNotes.EntryValidation.Changed += delegate { Validate(); };

            //Pack VBOX
            VBox vbox = new VBox(false, 0);

            vbox.PackStart(_entryBoxSelectConfigurationPaymentMethod, true, true, 0);
            vbox.PackStart(_entryBoxSelectConfigurationCurrency, false, false, 0);
            vbox.PackStart(_entryPaymentAmount, false, false, 0);
            vbox.PackStart(_entryBoxPaymentDate, false, false, 0);
            vbox.PackStart(_entryBoxDocumentPaymentNotes, false, false, 0);
            vbox.PackStart(_entryBoxDocumentPaymentNotes, false, false, 0);
            vbox.WidthRequest = _windowSize.Width - 14;

            //Put in FinishContent
            _fixedContent = new Fixed();
            _fixedContent.Put(vbox, 0, 0);
        }
Exemple #10
0
 public DocumentFinanceDialogPagePad(Window pSourceWindow)
 {
     //Parameters
     _sourceWindow = pSourceWindow;
     //Init Private Vars
     _session = GlobalFramework.SessionXpo;
     //Init Other
     _dateTimeFormat = SettingsApp.DateTimeFormat;
     _initalDateTime = FrameworkUtils.CurrentDateTimeAtomic();
 }
Exemple #11
0
 public GlobalFrameworkSession(String pFile)
 {
     //Init Parameters
     _file = pFile;
     //Default
     _currentOrderMainOid = Guid.Empty;
     _sessionDateStart    = FrameworkUtils.CurrentDateTimeAtomic();
     _loggedUsers         = new Dictionary <Guid, DateTime>();
     _ordersMain          = new Dictionary <Guid, OrderMain>();
 }
Exemple #12
0
        protected override void OnAfterConstruction()
        {
            Ord  = FrameworkUtils.GetNextTableFieldID(nameof(fin_documentfinanceyears), "Ord");
            Code = FrameworkUtils.GetNextTableFieldID(nameof(fin_documentfinanceyears), "Code");
            int currentYear = FrameworkUtils.CurrentDateTimeAtomic().Year;

            FiscalYear  = currentYear;
            Acronym     = string.Format("{0}{1}{2}", FiscalYear, "A", Code / 10);
            Designation = string.Format("{0} {1} {2}{3}", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_fiscal_year"), FiscalYear, "A", Code / 10);
        }
        protected override void OnAfterConstruction()
        {
            Ord  = FrameworkUtils.GetNextTableFieldID(nameof(FIN_DocumentFinanceYears), "Ord");
            Code = FrameworkUtils.GetNextTableFieldID(nameof(FIN_DocumentFinanceYears), "Code");
            int currentYear = FrameworkUtils.CurrentDateTimeAtomic().Year;

            FiscalYear  = currentYear;
            Acronym     = string.Format("{0}{1}{2}", FiscalYear, "A", Code / 10);
            Designation = string.Format("{0} {1} {2}{3}", Resx.global_fiscal_year, FiscalYear, "A", Code / 10);
        }
        //5.3: FT: Cancel Invoice
        void buttonCancelInvoice_Clicked(object sender, EventArgs e)
        {
            string dateTimeFormatCombinedDateTime           = SettingsApp.DateTimeFormatCombinedDateTime;
            Guid   documentMasterGuid                       = new Guid("81fcf207-ff59-4971-90cb-80d2cbdb87dc");//Document To Cancel
            fin_documentfinancemaster documentFinanceMaster = (fin_documentfinancemaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentfinancemaster), documentMasterGuid);

            //Cancel Document
            documentFinanceMaster.DocumentStatusStatus = "A";
            documentFinanceMaster.DocumentStatusDate   = FrameworkUtils.CurrentDateTimeAtomic().ToString(dateTimeFormatCombinedDateTime);
            documentFinanceMaster.DocumentStatusReason = "Erro ao Inserir Artigos";
            documentFinanceMaster.Save();
        }
        //Overload : Default Dates Start: 1st Day of Month, End Last Day Of Month
        public PosDatePickerStartEndDateDialog(Window pSourceWindow, DialogFlags pDialogFlags)
            : base(pSourceWindow, pDialogFlags)
        {
            //pastMonths=0 to Work in Curent Month Range, pastMonths=1 Works in Past Month, pastMonths=2 Two months Ago etc
            int      pastMonths      = 1;
            DateTime workingDate     = FrameworkUtils.CurrentDateTimeAtomic().AddMonths(-pastMonths);
            DateTime firstDayOfMonth = new DateTime(workingDate.Year, workingDate.Month, 1);
            DateTime lastDayOfMonth  = firstDayOfMonth.AddMonths(1).AddDays(-1);
            DateTime dateTimeStart   = firstDayOfMonth;
            DateTime dateTimeEnd     = lastDayOfMonth.AddHours(23).AddMinutes(59).AddSeconds(59);

            InitUI(pDialogFlags, dateTimeStart, dateTimeEnd);
        }
Exemple #16
0
        private static string GetBackupFileName(string pFileExtension, uint pFileVersion)
        {
            //Settings
            string pathBackups        = GlobalFramework.Path["backups"].ToString();
            string fileDataBaseBackup = SettingsApp.FileFormatDataBaseBackup;
            string dateTimeFileFormat = SettingsApp.FileFormatDateTime;
            //Local Vars
            string dateTime = FrameworkUtils.CurrentDateTimeAtomic().ToString(dateTimeFileFormat);

            //Override Default pathBackups
            if (GlobalFramework.DatabaseType == DatabaseType.MSSqlServer)
            {
                pathBackups = string.Empty;
            }

            /*
             * OLD CODE, NOT USED ANYMORE
             #if MONOLINUX
             #else
             * //Override default LocalPath with MSSqlServer.BackupDirectory
             * if (GlobalFramework.DatabaseType == "MSSqlServer")
             * {
             * _backupConnectionString = string.Format(GlobalFramework.Settings["backupConnectionString"], GlobalFramework.DatabaseServer);
             * ServerConnection connection = new ServerConnection(_backupConnectionString);
             * Server server = new Server(connection);
             *
             * //SqlServer Edition
             * if (GlobalFramework.DatabaseServer.ToUpper() != @".\SQLEXPRESS".ToUpper())
             * {
             *  try
             *  {
             *    //Using SQL Server authentication
             *    server.ConnectionContext.LoginSecure = false;
             *    server.ConnectionContext.Login = GlobalFramework.DatabaseUser;
             *    server.ConnectionContext.Password = GlobalFramework.DatabasePassword;
             *  }
             *  catch (Exception ex)
             *  {
             *    _log.Error(ex.Message, ex);
             *  }
             * }
             *
             * pathBackups = string.Format(@"{0}\", server.BackupDirectory);
             * if (server.ConnectionContext.IsOpen) server.ConnectionContext.Disconnect();
             * }
             #endif
             */

            return(pathBackups + string.Format(fileDataBaseBackup, GlobalFramework.DatabaseType, GlobalFramework.DatabaseName, pFileVersion, dateTime, pFileExtension).ToLower());
        }
Exemple #17
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Helper Methods

        private void ResetPassword()
        {
            try
            {
                //UserDetail userDetail = (this._crudWidgetList.GetFieldWidget("PasswordReset").DataSourceRow as UserDetail);
                _userDetail.AccessPin         = CryptographyUtils.SaltedString.GenerateSaltedString(SettingsApp.DefaultValueUserDetailAccessPin);
                _userDetail.PasswordReset     = false;
                _userDetail.PasswordResetDate = FrameworkUtils.CurrentDateTimeAtomic();
                //Force LogOut User
                GlobalApp.WindowStartup.LogOutUser(false, _userDetail);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Exemple #18
0
        public EntryBoxValidationDatePickerMultiDates(Window pSourceWindow, string pLabelText, string pWindowTitle, List <DateTime> pInitialDatesList)
        {
            string initialDate = FrameworkUtils.CurrentDateTimeAtomic().ToString(SettingsApp.DateFormat);

            //Parameters
            _sourceWindow = pSourceWindow;

            //Init Dates List
            _datesList = pInitialDatesList;
            //Init Dates VBox
            _vbox = new VBox(false, 0);

            //Init DateEntry
            _entryBoxAddDate = new EntryBoxValidationDatePickerDialog(pSourceWindow, pLabelText, pWindowTitle, SettingsApp.RegexDate, false);
            _entryBoxAddDate.EntryValidation.Text = initialDate;
            _entryBoxAddDate.EntryValidation.Validate();
            _entryBoxAddDate.ClosePopup += _entryBoxAddDate_ClosePopup;

            VBox vboxOuter = new VBox(false, 0);

            ScrolledWindow scrolledWindow = new ScrolledWindow();

            scrolledWindow.SetPolicy(PolicyType.Never, PolicyType.Always);
            scrolledWindow.ResizeMode = ResizeMode.Parent;
            Viewport viewport = new Viewport()
            {
                ShadowType = ShadowType.None
            };

            viewport.Add(_vbox);
            scrolledWindow.Add(viewport);

            //Initial Values
            if (_datesList.Count > 0)
            {
                for (int i = 0; i < _datesList.Count; i++)
                {
                    //Assign current fileName to _entryBoxAddFile, the last added is the Visible One
                    _entryBoxAddDate.EntryValidation.Text = _datesList[i].ToString(SettingsApp.DateFormat);
                    AddDateTimeEntry(_datesList[i], false);
                }
            }

            vboxOuter.PackStart(_entryBoxAddDate, false, false, 0);
            vboxOuter.PackStart(scrolledWindow, true, true, 0);
            Add(vboxOuter);
        }
Exemple #19
0
        public ProcessFinanceDocumentParameter(Guid pDocumentType, ArticleBag pArticleBag)
        {
            //Init Default Values
            _documentDateTime = FrameworkUtils.CurrentDateTimeAtomic();
            _sourceMode       = PersistFinanceDocumentSourceMode.CurrentOrderMain;
            _totalDelivery    = 0.0m;
            _totalChange      = 0.0m;
            _currency         = SettingsApp.ConfigurationSystemCurrency.Oid;
            //_discount = 0.0m;
            _exchangeRate = 1.0m;

            //Init Parameters
            _documentType = pDocumentType;
            _articleBag   = pArticleBag;

            //Validate();
        }
Exemple #20
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //ExportSaftPt

        public static string ExportSaftPt(Window pSourceWindow, ExportSaftPtMode pExportSaftPtMode)
        {
            string   result = string.Empty;
            DateTime dateCurrent = FrameworkUtils.CurrentDateTimeAtomic();
            DateTime dateStart, dateEnd;

            // Plugin Errors Messages
            if (GlobalFramework.PluginSoftwareVendor == null || !GlobalFramework.PluginSoftwareVendor.IsValidSecretKey(SettingsApp.SecretKey))
            {
                /* IN009034 */
                GlobalApp.DialogThreadNotify.WakeupMain();

                _log.Debug(String.Format("void Init() :: Wrong key detected [{0}]. Use a valid LogicposFinantialLibrary with same key as SoftwareVendorPlugin", SettingsApp.SecretKey));
                Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(650, 380), MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_plugin_softwarevendor_not_registered"));
            }
            else
            {
                switch (pExportSaftPtMode)
                {
                case ExportSaftPtMode.WholeYear:
                    dateStart = new DateTime(dateCurrent.Year, 1, 1);
                    dateEnd   = new DateTime(dateCurrent.Year, 12, 31);
                    result    = ExportSaftPt(pSourceWindow, dateStart, dateEnd);
                    break;

                case ExportSaftPtMode.LastMonth:
                    dateStart = dateCurrent.AddMonths(-1);
                    dateStart = new DateTime(dateStart.Year, dateStart.Month, 1);
                    dateEnd   = dateStart.AddMonths(1).AddDays(-1);
                    result    = ExportSaftPt(pSourceWindow, dateStart, dateEnd);
                    break;

                case ExportSaftPtMode.Custom:
                    PosDatePickerStartEndDateDialog dialog = new PosDatePickerStartEndDateDialog(pSourceWindow, Gtk.DialogFlags.DestroyWithParent);
                    ResponseType response = (ResponseType)dialog.Run();
                    if (response == ResponseType.Ok)
                    {
                        result = ExportSaftPt(pSourceWindow, dialog.DateStart, dialog.DateEnd);
                    }
                    dialog.Destroy();
                    break;
                }
            }

            return(result);
        }
Exemple #21
0
        protected void PrintFooter()
        {
            try
            {
                //Align Center
                _thermalPrinterGeneric.SetAlignCenter();

                //Set Font Size: Small
                _thermalPrinterGeneric.SetFont(1);

                //User : Terminal
                _thermalPrinterGeneric.WriteLine(string.Format("{0} - {1}", GlobalFramework.LoggedUser.Name, GlobalFramework.LoggedTerminal.Designation));
                _thermalPrinterGeneric.LineFeed();

                //Printed On | Company|App|Version
                _thermalPrinterGeneric.WriteLine(string.Format("{1}: {2}{0}{3}: {4} {5}"
                                                               , Environment.NewLine
                                                               , CustomFunctions.Res("global_printed_on_date")
                                                               , FrameworkUtils.CurrentDateTimeAtomic().ToString(SettingsApp.DateTimeFormat)
                                                               , _customVars["APP_COMPANY"]
                                                               , _customVars["APP_NAME"]
                                                               , _customVars["APP_VERSION"]
                                                               )
                                                 ); /* IN009211 */

                //Reset Font Size: Normal
                _thermalPrinterGeneric.SetFont(0);

                //Line Feed
                _thermalPrinterGeneric.LineFeed();

                //Reset to Left
                _thermalPrinterGeneric.SetAlignLeft();

                //Finish With Cut and Print Buffer
                //TK016249 - Impressoras - Diferenciação entre Tipos
                _thermalPrinterGeneric.Cut(true, GlobalFramework.LoggedTerminal.ThermalPrinter.ThermalCutCommand);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #22
0
        public static bool SessionPeriodOpen(WorkSessionPeriodType pWorkSessionPeriodType, string pDescription = "")
        {
            try
            {
                string periodType  = (pWorkSessionPeriodType == WorkSessionPeriodType.Day) ? "Day" : "Terminal";
                string description = (pDescription != String.Empty) ? string.Format(" - {0}", pDescription) : String.Empty;
                POS_ConfigurationPlaceTerminal terminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_ConfigurationPlaceTerminal>(GlobalFramework.LoggedTerminal.Oid);
                DateTime dateTime = FrameworkUtils.CurrentDateTimeAtomic();

                POS_WorkSessionPeriod workSessionPeriod = new POS_WorkSessionPeriod(GlobalFramework.SessionXpo)
                {
                    PeriodType    = pWorkSessionPeriodType,
                    SessionStatus = WorkSessionPeriodStatus.Open,
                    Designation   = string.Format("{0} - {1}{2}", periodType, dateTime.ToString(SettingsApp.DateTimeFormat), description),
                    DateStart     = dateTime,
                    Terminal      = terminal
                };
                //Assign Parent
                if (pWorkSessionPeriodType == WorkSessionPeriodType.Terminal)
                {
                    workSessionPeriod.Parent = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(GlobalFramework.WorkSessionPeriodDay.Oid);
                }
                //Persist
                workSessionPeriod.Save();

                if (pWorkSessionPeriodType == WorkSessionPeriodType.Day)
                {
                    GlobalFramework.WorkSessionPeriodDay = workSessionPeriod;
                }
                else
                {
                    GlobalFramework.WorkSessionPeriodTerminal = workSessionPeriod;
                }
                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
Exemple #23
0
        private bool UpdateBackupTimer()
        {
            _log.Debug("bool UpdateBackupTimer()");
            bool debug = false;

            DateTime currentDateTime           = FrameworkUtils.CurrentDateTimeAtomic();
            DateTime currentDateTimeLastBackup = DataBaseBackup.GetLastBackupDate();
            TimeSpan timeSpanDiference         = currentDateTime - currentDateTimeLastBackup;

            //Check if is in Start end Range
            if (currentDateTime.TimeOfDay > _databaseBackupTimeSpanRangeStart && currentDateTime.TimeOfDay < _databaseBackupTimeSpanRangeEnd)
            {
                if (timeSpanDiference >= _backupDatabaseTimeSpan)
                {
                    /* ERR201810#15 - Database backup issues */
                    DataBaseBackup.Backup(null);
                    //DataBaseBackup.Backup();
                }
                else
                {
                    if (debug)
                    {
                        _log.Debug(string.Format("Inside of TimeRange: currentDateTime:[{0}], backupLastDateTime:[{1}], timeSpanDiference:[{2}], backupDatabaseTimeSpan:[{3}] ", currentDateTime, currentDateTimeLastBackup, timeSpanDiference, _backupDatabaseTimeSpan));
                    }
                }
            }
            else
            {
                if (debug)
                {
                    _log.Debug(string.Format("Outside of TimeRange: [{0}] > [{1}] && [{2}] < [{3}]", currentDateTime.TimeOfDay, _databaseBackupTimeSpanRangeStart, currentDateTime.TimeOfDay, _databaseBackupTimeSpanRangeEnd));
                }
            }

            // Returning true means that the timeout routine should be invoked
            // again after the timeout period expires. Returning false would
            // terminate the timeout.
            return(true);
        }
        //Events
        protected void PopupDialog()
        {
            try
            {
                PosDatePickerDialog dialog = null;
                if (_windowTitle == string.Empty)
                {
                    dialog = new PosDatePickerDialog(_sourceWindow, DialogFlags.DestroyWithParent, _dateTime);
                }
                else
                {
                    dialog = new PosDatePickerDialog(_sourceWindow, DialogFlags.DestroyWithParent, _windowTitle, _dateTime);
                }

                ResponseType response = (ResponseType)dialog.Run();
                if (response == ResponseType.Ok)
                {
                    DateTime now = FrameworkUtils.CurrentDateTimeAtomic();
                    //Get Date from Calendar Widget
                    DateTime date = dialog.Calendar.Date;
                    //Transform Date to DateTime, Date + Current Hour
                    _dateTime = new DateTime(date.Year, date.Month, date.Day, now.Hour, now.Minute, now.Second);
                    //Apply with custom DateFormat, can assign any Format YYYYMMDD, YYYYMMDD HH:MM:SS etc
                    _entryValidation.Text = _dateTime.ToString(_dateFormat);
                    _entryValidation.Validate();
                    //Call Custom Validate for Data Ranges (Min/Max)
                    Validate();

                    //Call Custom Event, Only if OK, if Cancel Dont Trigger Event
                    OnClosePopup();
                }
                dialog.Destroy();
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Exemple #25
0
        /// <summary>
        /// Close WorkSessionPeriod, work in all PeriodTypes Day and Terminal
        /// </summary>
        /// <param name="pWorkSessionPeriod"></param>
        public static bool SessionPeriodClose(POS_WorkSessionPeriod pWorkSessionPeriod)
        {
            bool result = false;

            //Store Totals first, with a UOF, Error return without close session, we process error outside
            bool resultPersistTotals = ProcessWorkSessionPeriod.PersistWorkSessionTotals(pWorkSessionPeriod);

            if (resultPersistTotals)
            {
                try
                {
                    POS_WorkSessionPeriod workSessionPeriod = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(pWorkSessionPeriod.Oid);
                    DateTime dateTime = FrameworkUtils.CurrentDateTimeAtomic();
                    workSessionPeriod.DateEnd       = dateTime;
                    workSessionPeriod.SessionStatus = WorkSessionPeriodStatus.Close;
                    workSessionPeriod.Save();

                    //Assign to Singleton
                    if (workSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
                    {
                        GlobalFramework.WorkSessionPeriodDay = workSessionPeriod;
                    }
                    else
                    {
                        GlobalFramework.WorkSessionPeriodTerminal = workSessionPeriod;
                    }

                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }
            return(result);
        }
Exemple #26
0
        public fin_documentorderticket FinishOrder(Session pSession, bool pPrintTicket, bool pTicketDrecrease)
        {
            //Local Vars
            DateTime currentDateTime = DateTime.Now;
            fin_documentordermain xOrderMain;
            Session _sessionXpo = pSession;
            bool    isInUOW     = (_sessionXpo.GetType() == typeof(UnitOfWork));
            //Result
            fin_documentorderticket xOrderTicket = null;

            //Get current Working Order from SessionApp
            OrderMain   currentOrderMain   = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
            OrderTicket currentOrderTicket = currentOrderMain.OrderTickets[currentOrderMain.CurrentTicketId];

            //Get Place Object to extract TaxSellType Normal|TakeWay
            pos_configurationplace configurationPlace = (pos_configurationplace)GlobalFramework.SessionXpo.GetObjectByKey(typeof(pos_configurationplace), currentOrderMain.Table.PlaceId);
            //Use VatDirectSelling if in Retail or in TakeWay mode
            TaxSellType taxSellType = (configurationPlace.MovementType.VatDirectSelling || SettingsApp.AppMode == AppOperationMode.Retail) ? TaxSellType.TakeAway : TaxSellType.Normal;

            //Open Table on First Finish OrderTicket
            pos_configurationplacetable xTable = (pos_configurationplacetable)FrameworkUtils.GetXPGuidObject(_sessionXpo, typeof(pos_configurationplacetable), _table.Oid);

            xTable.Reload();
            if (xTable.TableStatus != TableStatus.Open)
            {
                xTable.TableStatus = TableStatus.Open;
                FrameworkUtils.Audit("TABLE_OPEN", string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_table_open"), xTable.Designation));
                xTable.DateTableOpen = FrameworkUtils.CurrentDateTimeAtomic();
                if (!isInUOW)
                {
                    xTable.Save();
                }
            }

            //Get Current _persistentOid and _from Database
            _persistentOid = GetOpenTableFieldValueGuid(_table.Oid, "Oid");
            _orderStatus   = (OrderStatus)GetOpenTableFieldValue(_table.Oid, "OrderStatus");
            _updatedAt     = FrameworkUtils.CurrentDateTimeAtomic();
            Guid orderTicketOid = Guid.Empty;

            //Insert
            if (_persistentOid == Guid.Empty)
            {
                //OrderMain
                xOrderMain = new fin_documentordermain(_sessionXpo)
                {
                    //Always assign New date to Persistent Date
                    DateStart   = currentDateTime,//currentOrderMain.DateStart,
                    OrderStatus = OrderStatus.Open,
                    PlaceTable  = xTable,
                    UpdatedAt   = FrameworkUtils.CurrentDateTimeAtomic()
                };
                if (!isInUOW)
                {
                    xOrderMain.Save();
                }
                //After Save, Get Oid
                _persistentOid = xOrderMain.Oid;
                //Change to Open Status
                _orderStatus = OrderStatus.Open;
            }
            //Update
            else
            {
                xOrderMain = (fin_documentordermain)FrameworkUtils.GetXPGuidObject(_sessionXpo, typeof(fin_documentordermain), _persistentOid);
                if (xOrderMain.PlaceTable != xTable)
                {
                    xOrderMain.PlaceTable = xTable;
                }
                //Force Changes in Record, else UpdatedAt dont Update
                xOrderMain.UpdatedAt = FrameworkUtils.CurrentDateTimeAtomic();
                //TODO: Check if User was Automatically Updated
                //if (xOrderMain.UpdatedBy != GlobalFramework.LoggedUser) xOrderMain.UpdatedBy = GlobalFramework.LoggedUser;
                if (!isInUOW)
                {
                    xOrderMain.Save();
                }
            }

            //Create OrderTicket
            //if (pTicketDrecrease)
            //{
            //var sql = string.Format(@"SELECT * FROM fin_documentorderticket WHERE TicketId = '{0}' AND OrderMain = '{1}';", currentOrderMain.CurrentTicketId, currentOrderMain.PersistentOid);
            //_log.Debug(string.Format("sql: [{0}]", sql));
            string sql = string.Format(@"SELECT Oid FROM fin_documentorderticket WHERE OrderMain = '{0}' AND TicketId = '{1}';", currentOrderMain.PersistentOid, currentOrderMain.CurrentTicketId);

            //_log.Debug(string.Format("sql: [{0}]", sql));
            orderTicketOid = FrameworkUtils.GetGuidFromQuery(sql);
            xOrderTicket   = (fin_documentorderticket)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentorderticket), orderTicketOid);

            //xOrderTicket = (fin_documentorderticket)FrameworkUtils.GetXPGuidObject(_sessionXpo, typeof(fin_documentorderticket), currentOrderMain._persistentOid);
            if (xOrderTicket != null)
            {
                xOrderTicket.TicketId   = currentOrderMain.CurrentTicketId;
                xOrderTicket.DateStart  = currentOrderTicket.DateStart;
                xOrderTicket.PriceType  = currentOrderTicket.PriceType;
                xOrderTicket.Discount   = xTable.Discount;
                xOrderTicket.OrderMain  = xOrderMain;
                xOrderTicket.PlaceTable = xTable;
                xOrderTicket.UpdatedAt  = FrameworkUtils.CurrentDateTimeAtomic();
                if (!isInUOW)
                {
                    xOrderTicket.Save();
                }
            }

            //}
            else
            {
                xOrderTicket = new fin_documentorderticket(_sessionXpo)
                {
                    TicketId   = currentOrderMain.CurrentTicketId,
                    DateStart  = currentOrderTicket.DateStart,
                    PriceType  = currentOrderTicket.PriceType,
                    Discount   = xTable.Discount,
                    OrderMain  = xOrderMain,
                    PlaceTable = xTable
                };
                if (!isInUOW)
                {
                    xOrderTicket.Save();
                }
            }


            //Create OrderDetail
            fin_documentorderdetail xOrderDetailLine;
            fin_article             xArticle;
            uint    itemOrd  = 0;
            decimal priceTax = 0;

            foreach (OrderDetailLine line in currentOrderTicket.OrderDetails.Lines)
            {
                //Use Order in print tickets etc
                itemOrd++;
                xArticle = (fin_article)FrameworkUtils.GetXPGuidObject(_sessionXpo, typeof(fin_article), line.ArticleOid);
                //Get PriceTax from TaxSellType
                priceTax = (taxSellType == TaxSellType.Normal) ? xArticle.VatOnTable.Value : xArticle.VatDirectSelling.Value;
                //Edit/cancel orders lindote 10/07/2020
                //Get order ticket Oid from DB
                string sql3 = string.Format(@"SELECT Oid FROM fin_documentorderticket WHERE OrderMain = '{0}' AND TicketId = '{1}';", currentOrderMain.PersistentOid, currentOrderMain.CurrentTicketId);
                orderTicketOid = FrameworkUtils.GetGuidFromQuery(sql3);

                //Get order detail Oid from DB
                string sql4 = string.Format(@"SELECT Oid FROM fin_documentorderdetail WHERE OrderTicket = '{0}' AND Article = '{1}' AND Price = '{2}'  AND TotalDiscount = '{3}'  AND Vat = '{4}';",
                                            orderTicketOid, line.ArticleOid, line.Properties.PriceNet.ToString().Replace(",", "."),
                                            line.Properties.TotalDiscount.ToString().Replace(",", "."),
                                            line.Properties.Vat.ToString().Replace(",", "."));
                Guid orderDetailOid = FrameworkUtils.GetGuidFromQuery(sql4);

                string pToken2 = "";
                if (pTicketDrecrease)
                {
                    pToken2 = "decreased";
                }

                if (orderDetailOid == Guid.Empty)
                {
                    xOrderDetailLine = new fin_documentorderdetail(_sessionXpo)
                    {
                        //Values
                        Ord           = itemOrd,
                        Code          = xArticle.Code,
                        Designation   = line.Designation,
                        Quantity      = line.Properties.Quantity,
                        UnitMeasure   = xArticle.UnitMeasure.Acronym,
                        Price         = line.Properties.PriceNet,
                        Discount      = (xArticle.Discount > 0) ? xArticle.Discount : 0.0m,
                        TotalGross    = line.Properties.TotalGross,
                        TotalDiscount = line.Properties.TotalDiscount,
                        TotalTax      = line.Properties.TotalTax,
                        TotalFinal    = line.Properties.TotalFinal,
                        Token2        = pToken2,
                        //Use PriceTax Normal|TakeAway
                        Vat = priceTax,
                        //XPGuidObjects
                        Article     = xArticle,
                        OrderTicket = xOrderTicket
                    };

                    //Detect VatExemptionReason
                    if (line.Properties.VatExemptionReason != Guid.Empty)
                    {
                        xOrderDetailLine.VatExemptionReason = line.Properties.VatExemptionReason;
                    }
                    if (!isInUOW)
                    {
                        xOrderDetailLine.Save();
                    }
                }
                else
                {
                    xOrderDetailLine = (fin_documentorderdetail)FrameworkUtils.GetXPGuidObject(_sessionXpo, typeof(fin_documentorderdetail), orderDetailOid);

                    if (xOrderDetailLine.Token2 != "decreased" && !pTicketDrecrease)
                    {
                        xOrderDetailLine.Ord           = itemOrd;
                        xOrderDetailLine.Code          = xArticle.Code;
                        xOrderDetailLine.Designation   = line.Designation;
                        xOrderDetailLine.Quantity     += line.Properties.Quantity;
                        xOrderDetailLine.UnitMeasure   = xArticle.UnitMeasure.Acronym;
                        xOrderDetailLine.Price         = line.Properties.PriceNet;
                        xOrderDetailLine.Discount      = (xArticle.Discount > 0) ? xArticle.Discount : 0.0m;
                        xOrderDetailLine.TotalGross    = line.Properties.TotalGross;
                        xOrderDetailLine.TotalDiscount = line.Properties.TotalDiscount;
                        xOrderDetailLine.TotalTax      = line.Properties.TotalTax;
                        xOrderDetailLine.TotalFinal    = line.Properties.TotalFinal;
                        xOrderDetailLine.Token2        = pToken2;
                        //Use PriceTax Normal|TakeAway
                        xOrderDetailLine.Vat = priceTax;
                        //XPGuidObjects
                        xOrderDetailLine.Article     = xArticle;
                        xOrderDetailLine.OrderTicket = xOrderTicket;

                        if (!isInUOW)
                        {
                            xOrderDetailLine.Save();
                        }
                    }
                    else
                    if (xOrderDetailLine.Token2 == "decreased" && pTicketDrecrease)
                    {
                        xOrderDetailLine.Ord           = itemOrd;
                        xOrderDetailLine.Code          = xArticle.Code;
                        xOrderDetailLine.Designation   = line.Designation;
                        xOrderDetailLine.Quantity     += line.Properties.Quantity;
                        xOrderDetailLine.UnitMeasure   = xArticle.UnitMeasure.Acronym;
                        xOrderDetailLine.Price         = line.Properties.PriceNet;
                        xOrderDetailLine.Discount      = (xArticle.Discount > 0) ? xArticle.Discount : 0.0m;
                        xOrderDetailLine.TotalGross    = line.Properties.TotalGross;
                        xOrderDetailLine.TotalDiscount = line.Properties.TotalDiscount;
                        xOrderDetailLine.TotalTax      = line.Properties.TotalTax;
                        xOrderDetailLine.TotalFinal    = line.Properties.TotalFinal;
                        xOrderDetailLine.Token2        = pToken2;
                        //Use PriceTax Normal|TakeAway
                        xOrderDetailLine.Vat = priceTax;
                        //XPGuidObjects
                        xOrderDetailLine.Article     = xArticle;
                        xOrderDetailLine.OrderTicket = xOrderTicket;

                        if (!isInUOW)
                        {
                            xOrderDetailLine.Save();
                        }
                    }
                    else
                    if (xOrderDetailLine.Token2 == "decreased" && !pTicketDrecrease)
                    {
                        xOrderDetailLine.Ord           = itemOrd;
                        xOrderDetailLine.Code          = xArticle.Code;
                        xOrderDetailLine.Designation   = line.Designation;
                        xOrderDetailLine.Quantity      = xOrderDetailLine.Quantity;
                        xOrderDetailLine.UnitMeasure   = xArticle.UnitMeasure.Acronym;
                        xOrderDetailLine.Price         = line.Properties.PriceNet;
                        xOrderDetailLine.Discount      = (xArticle.Discount > 0) ? xArticle.Discount : 0.0m;
                        xOrderDetailLine.TotalGross    = line.Properties.TotalGross;
                        xOrderDetailLine.TotalDiscount = line.Properties.TotalDiscount;
                        xOrderDetailLine.TotalTax      = line.Properties.TotalTax;
                        xOrderDetailLine.TotalFinal    = line.Properties.TotalFinal;
                        xOrderDetailLine.Token2        = pToken2;
                        //Use PriceTax Normal|TakeAway
                        xOrderDetailLine.Vat = priceTax;
                        //XPGuidObjects
                        xOrderDetailLine.Article     = xArticle;
                        xOrderDetailLine.OrderTicket = xOrderTicket;

                        if (!isInUOW)
                        {
                            xOrderDetailLine.Save();
                        }
                    }
                }


                //}
            }
            ;

            //Clean Details and Open a New Blank Ticket in Session
            //Increment Terminal SessionApp CurrentTicketId
            //Only increase in new ticket, else stays the same
            if (!pTicketDrecrease)
            {
                _currentTicketId += 1;
                currentOrderMain.OrderTickets = new Dictionary <int, OrderTicket>();
                currentOrderMain.OrderTickets.Add(currentOrderMain.CurrentTicketId, new OrderTicket(this, _table.PriceType));
            }


            //Finish Writing Session
            GlobalFramework.SessionApp.Write();

            return(xOrderTicket);

            //Debug
            //_log.Debug(string.Format("FinishOrder(): xOrderMain.Oid [{0}]", xOrderMain.Oid));
            //_log.Debug(string.Format("FinishOrder(): _table.OrderMainId [{0}], _currentTicketId [{1}], _table.Name [{2}]", _table.OrderMainId, _currentTicketId, _table.Name));
        }
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Helper for Create DocumentFinanceSeries & DocumentFinanceYearSerieTerminal
        //Used to generate Series Preview, or to Process Series in Database

        public static FrameworkCallsResult CreateDocumentFinanceYearSeriesTerminal(fin_documentfinanceyears pDocumentFinanceYears, DataTable pTerminals, string pAcronym, bool pPreviewMode)
        {
            FrameworkCallsResult result = new FrameworkCallsResult();
            uint   ordAndCode = 10;
            uint   ordAndCodeInc = 10;
            int    terminalInc = 1;
            string acronymPrefix = String.Empty, acronym, designation, output = String.Empty, acronymAudit;
            Dictionary <string, string> acronymPrefixCreatedSeries = new Dictionary <string, string>();
            fin_documentfinanceseries   documentFinanceSeries = null;
            //Used to add DocumentFinanceYearSerieTerminal to list to delete outside of Loop
            List <fin_documentfinanceyearserieterminal> listDeleteSerieTerminal = new List <fin_documentfinanceyearserieterminal>();

            //Start UnitOfWork
            using (UnitOfWork uowSession = new UnitOfWork())
            {
                try
                {
                    //Get Object in UOW Session
                    fin_documentfinanceyears documentFinanceYears = (fin_documentfinanceyears)FrameworkUtils.GetXPGuidObject(uowSession, typeof(fin_documentfinanceyears), pDocumentFinanceYears.Oid);

                    //Initialize DocumentFinanceType Collection : Criteria/XPCollection/Model : Use Default Filter
                    CriteriaOperator criteria = CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)");
                    //Configure SortProperty
                    SortProperty sortProperty = new SortProperty("Ord", DevExpress.Xpo.DB.SortingDirection.Ascending);
                    //Init Collection
                    XPCollection xpDocumentFinanceType = new XPCollection(uowSession, typeof(fin_documentfinancetype), criteria, sortProperty);

                    //Loop Terminals
                    foreach (DataRow terminal in pTerminals.Rows)
                    {
                        //Disable Series and Delete SerieTerminal for selected Terminal
                        if (!pPreviewMode)
                        {
                            //Initialize DocumentFinanceYearSerieTerminal Collection : Criteria/XPCollection/Model : Use Default Filter + Terminal
                            criteria = CriteriaOperator.Parse(string.Format("(Disabled = 0 OR Disabled IS NULL) AND (Terminal = '{0}')", terminal["Oid"]));
                            //Init Collection
                            XPCollection xpDocumentFinanceYearSerieTerminal = new XPCollection(uowSession, typeof(fin_documentfinanceyearserieterminal), criteria);

                            //Loop DocumentFinanceYearSerieTerminal and Parent DocumentFinanceYearSerie and Delete
                            foreach (fin_documentfinanceyearserieterminal documentFinanceYearSerieTerminal in xpDocumentFinanceYearSerieTerminal)
                            {
                                if (_debug)
                                {
                                    _log.Debug(string.Format("Disabled documentFinanceYearSerie: [{0}]", documentFinanceYearSerieTerminal.Serie.Designation));
                                }
                                documentFinanceYearSerieTerminal.Serie.Disabled = true;
                                //documentFinanceYearSerieTerminal.Disabled = true;
                                //Add to Post Loop Deletion
                                listDeleteSerieTerminal.Add(documentFinanceYearSerieTerminal);
                            }

                            //Now we can delete, Outside of Loop
                            foreach (fin_documentfinanceyearserieterminal deleteSerieTerminal in listDeleteSerieTerminal)
                            {
                                if (_debug)
                                {
                                    _log.Debug(string.Format("Deleted documentFinanceYearSerieTerminal: [{0}]", deleteSerieTerminal.Designation));
                                }
                                deleteSerieTerminal.Delete();
                            }
                        }

                        //Add to Output
                        if (pPreviewMode)
                        {
                            output += string.Format("{0}{1}", terminal["Designation"], Environment.NewLine);
                        }

                        //Get Current Terminal Object
                        pos_configurationplaceterminal configurationPlaceTerminal = (pos_configurationplaceterminal)uowSession.GetObjectByKey(typeof(pos_configurationplaceterminal), new Guid(terminal["Oid"].ToString()));

                        //Create DocumentFinanceSeries Acronym From Date
                        DateTime now = FrameworkUtils.CurrentDateTimeAtomic();

                        //AcronymPrefix ex FT[QN3T1U401]2016S001, works with Random and AcronymLastSerie modes
                        if (SettingsApp.DocumentFinanceSeriesGenerationFactoryUseRandomAcronymPrefix)
                        {
                            acronymPrefix = DateToAcronymPrefix(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second));
                        }
                        //AcronymPrefix ex Fatura FT[0001]2016S001
                        else
                        {
                            //Get acronymPrefix in first DocumentFinanceType, not in every Document, this way we have uniform series
                            acronymPrefix = (xpDocumentFinanceType[0] as fin_documentfinancetype).AcronymLastSerie.ToString(SettingsApp.DocumentFinanceSeriesGenerationFactoryAcronymLastSerieFormat);
                        }

                        //Add to Created List
                        acronymPrefixCreatedSeries.Add(acronymPrefix, configurationPlaceTerminal.Designation);

                        foreach (fin_documentfinancetype documentFinanceType in xpDocumentFinanceType)
                        {
                            //Ignored DocumentTypes (DocumentFinanceTypeInvoiceWayBill, this DocumentType use DocumentFinanceTypeInvoice Serie)
                            if (documentFinanceType.Oid != SettingsApp.XpoOidDocumentFinanceTypeInvoiceWayBill)
                            {
                                //2018-05-08 : Old Format : [FT005012018S1] : Search GenDocumentNumber in ProcessFinanceDocument
                                //acronym = string.Format("{0}{1}{2}{3}", documentFinanceType.Acronym, acronymPrefix, terminalInc.ToString("00"), pAcronym);
                                //2018-05-08 : New Format
                                //acronym = string.Format("{0} {1}{2}{3}", documentFinanceType.Acronym, pAcronym, acronymPrefix, terminalInc);
                                acronym     = string.Format("{0} {1}{2}", documentFinanceType.Acronym, pAcronym, acronymPrefix);
                                designation = string.Format("{0} {1}", documentFinanceType.Designation, acronym);
                                if (!pPreviewMode)
                                {
                                    documentFinanceSeries = new fin_documentfinanceseries(uowSession)
                                    {
                                        Ord                      = ordAndCode,
                                        Code                     = ordAndCode,
                                        FiscalYear               = documentFinanceYears,
                                        DocumentType             = documentFinanceType,
                                        NextDocumentNumber       = 1,
                                        DocumentNumberRangeBegin = 1,
                                        DocumentNumberRangeEnd   = int.MaxValue,
                                        Acronym                  = acronym,
                                        Designation              = designation
                                    };
                                }
                                //Add to Output
                                if (pPreviewMode)
                                {
                                    output += string.Format("  {0} {1} - {2}{3}", documentFinanceType.Acronym, acronym, documentFinanceType.Designation, Environment.NewLine);
                                }
                                if (_debug)
                                {
                                    _log.Debug(string.Format("DocumentFinanceSeries: [{0}], Designation: [{1}], Acronym: [{2}]", ordAndCode, designation, acronym));
                                }

                                //Create DocumentFinanceYearSerieTerminal
                                designation = string.Format("{0} {1}", designation, configurationPlaceTerminal.Designation);
                                if (!pPreviewMode)
                                {
                                    fin_documentfinanceyearserieterminal documentFinanceYearSerieTerminal = new fin_documentfinanceyearserieterminal(uowSession)
                                    {
                                        Ord          = ordAndCode,
                                        Code         = ordAndCode,
                                        FiscalYear   = documentFinanceYears,
                                        DocumentType = documentFinanceSeries.DocumentType,
                                        Serie        = documentFinanceSeries,
                                        Terminal     = configurationPlaceTerminal,
                                        Printer      = configurationPlaceTerminal.Printer,
                                        Template     = documentFinanceSeries.DocumentType.Template,
                                        Designation  = string.Format("{0} {1}", documentFinanceSeries.Designation, configurationPlaceTerminal.Designation)
                                    };
                                }
                                if (_debug)
                                {
                                    _log.Debug(string.Format("DocumentFinanceYearSerieTerminal: [{0}], Terminal: [{1}], Serie: [{2}]", ordAndCode, terminal["Designation"], designation));
                                }

                                //Increment AcronymLastSerie and ordAndCodeInc
                                documentFinanceType.AcronymLastSerie++;
                                ordAndCode = ordAndCode + ordAndCodeInc;
                            }
                        }
                        //Add Blank Line to Split Series/Terminal
                        if (pPreviewMode && pTerminals.Rows.Count > terminalInc)
                        {
                            output += Environment.NewLine;
                        }
                        //Increment Terminal
                        terminalInc++;
                    }

                    //Finnaly Commit Changes
                    if (!pPreviewMode)
                    {
                        uowSession.CommitChanges();
                    }

                    result.Result = true;

                    if (pPreviewMode)
                    {
                        result.Output = output;
                    }
                    else
                    {
                        foreach (var item in acronymPrefixCreatedSeries)
                        {
                            //Audit FINANCE_SERIES_CREATED
                            acronymAudit = string.Format("{0}{1}{2}{3}", "xx", item.Key, 0.ToString("00"), pAcronym);
                            FrameworkUtils.Audit("FINANCE_SERIES_CREATED", string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_finance_series_created"), acronymAudit, item.Value, GlobalFramework.LoggedUser.Name));
                        }
                    }
                }
                catch (Exception ex)
                {
                    uowSession.RollbackTransaction();
                    result.Exception = ex;
                    _log.Error(ex.Message, ex);
                }
            }
            return(result);
        }
Exemple #28
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Event: touchButtonPosToolbarShowChangeUser

        void touchButtonPosToolbarShowChangeUserDialog_Clicked(object sender, EventArgs e)
        {
            PosChangeUserDialog dialogChangeUser = new PosChangeUserDialog(this, Gtk.DialogFlags.DestroyWithParent);

            try
            {
                string terminalInfo = string.Empty;

                int responseChangeUser = dialogChangeUser.Run();
                if (responseChangeUser == (int)ResponseType.Ok)
                {
                    //Already logged
                    if (GlobalFramework.SessionApp.LoggedUsers.ContainsKey(dialogChangeUser.UserDetail.Oid))
                    {
                        GlobalFramework.LoggedUser            = (SYS_UserDetail)FrameworkUtils.GetXPGuidObject(typeof(SYS_UserDetail), dialogChangeUser.UserDetail.Oid);
                        GlobalFramework.LoggedUserPermissions = FrameworkUtils.GetUserPermissions();
                        _ticketList.UpdateTicketListButtons();
                        FrameworkUtils.Audit("USER_CHANGE", string.Format(Resx.audit_message_user_change, GlobalFramework.LoggedUser.Name));
                        terminalInfo = string.Format("{0} : {1}", GlobalFramework.LoggedTerminal.Designation, GlobalFramework.LoggedUser.Name);
                        if (_labelTerminalInfo.Text != terminalInfo)
                        {
                            _labelTerminalInfo.Text = terminalInfo;
                        }
                    }
                    //Not Logged, Request Pin Login
                    else
                    {
                        PosPinPadDialog dialogPinPad   = new PosPinPadDialog(dialogChangeUser, Gtk.DialogFlags.DestroyWithParent, dialogChangeUser.UserDetail);
                        int             responsePinPad = dialogPinPad.Run();
                        if (responsePinPad == (int)ResponseType.Ok)
                        {
                            if (!GlobalFramework.SessionApp.LoggedUsers.ContainsKey(dialogChangeUser.UserDetail.Oid))
                            {
                                GlobalFramework.SessionApp.LoggedUsers.Add(dialogChangeUser.UserDetail.Oid, FrameworkUtils.CurrentDateTimeAtomic());
                                GlobalFramework.SessionApp.Write();
                                GlobalFramework.LoggedUser            = (SYS_UserDetail)FrameworkUtils.GetXPGuidObject(typeof(SYS_UserDetail), dialogChangeUser.UserDetail.Oid);
                                GlobalFramework.LoggedUserPermissions = FrameworkUtils.GetUserPermissions();
                                _ticketList.UpdateTicketListButtons();
                                FrameworkUtils.Audit("USER_LOGIN", string.Format(Resx.audit_message_user_login, GlobalFramework.LoggedUser.Name));
                                terminalInfo = string.Format("{0} : {1}", GlobalFramework.LoggedTerminal.Designation, GlobalFramework.LoggedUser.Name);
                                if (_labelTerminalInfo.Text != terminalInfo)
                                {
                                    _labelTerminalInfo.Text = terminalInfo;
                                }
                                //After First time Login ShowNotifications
                                Utils.ShowNotifications(dialogPinPad);
                            }
                        }
                        ;

                        dialogPinPad.Destroy();
                    }
                }
                ;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            finally
            {
                dialogChangeUser.Destroy();
            }
        }
Exemple #29
0
        public DocumentFinanceDialogPage5(Window pSourceWindow, String pPageName, String pPageIcon, Widget pWidget, bool pEnabled = true)
            : base(pSourceWindow, pPageName, pPageIcon, pWidget, pEnabled)
        {
            //Init private vars
            _pagePad = (_sourceWindow as PosDocumentFinanceDialog).PagePad;
            _session = (_pagePad as DocumentFinanceDialogPagePad).Session;

            //Initials Values
            _intialValueConfigurationCountry = SettingsApp.ConfigurationSystemCountry;

            //ShipFrom Address
            _entryBoxShipFromAddressDetail = new EntryBoxValidation(_sourceWindow, Resx.global_address, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, true);
            _entryBoxShipFromAddressDetail.EntryValidation.Changed += delegate { Validate(); };

            //ShipFrom Region
            _entryBoxShipFromRegion = new EntryBoxValidation(_sourceWindow, Resx.global_region, KeyboardMode.Alfa, SettingsApp.RegexAlfa, false);
            _entryBoxShipFromRegion.EntryValidation.Changed += delegate { Validate(); };

            //ShipFrom PostalCode
            _entryBoxShipFromPostalCode = new EntryBoxValidation(_sourceWindow, Resx.global_zipcode, KeyboardMode.Alfa, SettingsApp.ConfigurationSystemCountry.RegExZipCode, true);
            _entryBoxShipFromPostalCode.EntryValidation.Changed += delegate { Validate(); };

            //ShipFrom City
            _entryBoxShipFromCity = new EntryBoxValidation(_sourceWindow, Resx.global_city, KeyboardMode.Alfa, SettingsApp.RegexAlfa, true);
            _entryBoxShipFromCity.EntryValidation.Changed += delegate { Validate(); };

            //ShipFrom Country
            CriteriaOperator criteriaOperatorCustomerCountry = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1)");

            _entryBoxSelectShipFromCountry = new XPOEntryBoxSelectRecordValidation <CFG_ConfigurationCountry, TreeViewConfigurationCountry>(_sourceWindow, Resx.global_country, "Designation", "Oid", _intialValueConfigurationCountry, criteriaOperatorCustomerCountry, SettingsApp.RegexGuid, true);
            _entryBoxSelectShipFromCountry.EntryValidation.IsEditable = false;
            _entryBoxSelectShipFromCountry.EntryValidation.Changed   += delegate { Validate(); };
            _entryBoxSelectShipFromCountry.ClosePopup += delegate
            {
                //Require to Update RegExZipCode
                _entryBoxShipFromPostalCode.EntryValidation.Rule = _entryBoxSelectShipFromCountry.Value.RegExZipCode;
                _entryBoxShipFromPostalCode.EntryValidation.Validate();
            };

            //ShipFromDeliveryDate
            _entryBoxShipFromDeliveryDate = new EntryBoxValidationDatePickerDialog(_sourceWindow, Resx.global_ship_from_delivery_date, _pagePad.DateTimeFormat, _pagePad.InitalDateTime, KeyboardMode.AlfaNumeric, SettingsApp.RegexDateTime, true, _pagePad.DateTimeFormat);
            _entryBoxShipFromDeliveryDate.EntryValidation.Sensitive = true;
            _entryBoxShipFromDeliveryDate.EntryValidation.Text      = FrameworkUtils.DateTimeToString(FrameworkUtils.CurrentDateTimeAtomic()).ToString();
            _entryBoxShipFromDeliveryDate.EntryValidation.Validate();
            //Assign Min Date to Validation
            _entryBoxShipFromDeliveryDate.DateTimeMin              = FrameworkUtils.CurrentDateTimeAtomic();
            _entryBoxShipFromDeliveryDate.EntryValidation.Changed += _entryBoxShipFromDeliveryDate_ClosePopup;
            _entryBoxShipFromDeliveryDate.ClosePopup += _entryBoxShipFromDeliveryDate_ClosePopup;

            //ShipFromDeliveryID
            _entryBoxShipFromDeliveryID = new EntryBoxValidation(_sourceWindow, Resx.global_ship_from_delivery_id, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, false);
            _entryBoxShipFromDeliveryID.EntryValidation.Changed += delegate { Validate(); };

            //ShipFromWarehouseID
            _entryBoxShipFromWarehouseID = new EntryBoxValidation(_sourceWindow, Resx.global_ship_from_warehouse_id, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, false);
            _entryBoxShipFromWarehouseID.EntryValidation.MaxLength = 50;
            _entryBoxShipFromWarehouseID.EntryValidation.Changed  += delegate { Validate(); };

            //ShipFromLocationID
            _entryBoxShipFromLocationID = new EntryBoxValidation(_sourceWindow, Resx.global_ship_from_location_id, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, false);
            _entryBoxShipFromLocationID.EntryValidation.MaxLength = 30;
            _entryBoxShipFromLocationID.EntryValidation.Changed  += delegate { Validate(); };

            //HBox hboxDeliveryDate+DeliveryID
            HBox hboxDeliveryDateAndDeliveryID = new HBox(true, 0);

            hboxDeliveryDateAndDeliveryID.PackStart(_entryBoxShipFromDeliveryDate, true, true, 0);
            hboxDeliveryDateAndDeliveryID.PackStart(_entryBoxShipFromDeliveryID, true, true, 0);

            //HBox ZipCode+City+Country
            HBox hboxZipCodeAndCityAndCountry = new HBox(true, 0);

            hboxZipCodeAndCityAndCountry.PackStart(_entryBoxShipFromPostalCode, true, true, 0);
            hboxZipCodeAndCityAndCountry.PackStart(_entryBoxShipFromCity, true, true, 0);
            hboxZipCodeAndCityAndCountry.PackStart(_entryBoxSelectShipFromCountry, true, true, 0);

            //HBox hboxWarehouseID+LocationID
            HBox hboxhboxWarehouseIDAndLocationID = new HBox(true, 0);

            hboxhboxWarehouseIDAndLocationID.PackStart(_entryBoxShipFromWarehouseID, true, true, 0);
            hboxhboxWarehouseIDAndLocationID.PackStart(_entryBoxShipFromLocationID, true, true, 0);

            //Pack VBOX
            VBox vbox = new VBox(false, 2);

            vbox.PackStart(_entryBoxShipFromAddressDetail, false, false, 0);
            vbox.PackStart(_entryBoxShipFromRegion, false, false, 0);
            vbox.PackStart(hboxZipCodeAndCityAndCountry, false, false, 0);
            vbox.PackStart(hboxDeliveryDateAndDeliveryID, false, false, 0);
            vbox.PackStart(hboxhboxWarehouseIDAndLocationID, false, false, 0);
            PackStart(vbox);
        }
Exemple #30
0
        public string Process(CustomReportDisplayMode pViewMode, string pDestinationFileName = "")
        {
            string result = String.Empty;

            //Prepare Modes
            switch (pViewMode)
            {
            case CustomReportDisplayMode.Preview:
            case CustomReportDisplayMode.Print:
            case CustomReportDisplayMode.ExportPDF:
            case CustomReportDisplayMode.ExportPDFSilent:
                //Get Object Reference to Change CopyName
                TextObject textCopyName = (TextObject)this.FindObject("TextCopyName");
                //Get Object Reference to Change SecondPrint Label for DocumentFinanceDocuments
                TextObject textSecondPrint = (TextObject)this.FindObject("TextSecondPrint");

                //Loop Copies and Change CopyName
                for (int i = 0; i < this.PrintSettings.CopyNames.Length; i++)
                {
                    if (textCopyName != null)
                    {
                        textCopyName.Text = this.PrintSettings.CopyNames[i];
                    }
                    if (textSecondPrint != null)
                    {
                        textSecondPrint.Text = (_secondCopy && i < 1) ? Resx.global_print_second_print : String.Empty;
                    }
                    //Store PreparedFiles in Custom SystemVariable, Required to PageNo in Reports ex "[ToInt32([PreparedPages]) + [Page]]"
                    //Else Page start aways in 1, when we call prepare, and we cannot have a usefull Page Counter working with .Prepare
                    this.Dictionary.SystemVariables.FindByName("PreparedPages").Value = (this.PreparedPages != null) ? this.PreparedPages.Count : 0;
                    //Call Report Prepare
                    this.Prepare(true);
                }
                break;
            }

            //NOT USED ANYMORE : Now we can Reset Copies to 1
            //this.PrintSettings.Copies = 1;

            //Send to ViewMode
            switch (pViewMode)
            {
            case CustomReportDisplayMode.Preview:
                this.ShowPrepared();
                break;

            case CustomReportDisplayMode.Print:
                this.PrintPrepared();
                break;

            case CustomReportDisplayMode.Design:
                this.Design();
                break;

            case CustomReportDisplayMode.ExportPDF:
            case CustomReportDisplayMode.ExportPDFSilent:
                //Prepare FileName
                string fileName = String.Empty;
                if (pDestinationFileName != String.Empty)
                {
                    fileName = pDestinationFileName;
                }
                //Default Filename
                else
                {
                    string dateTimeFileFormat = SettingsApp.FileFormatDateTime;
                    string dateTime           = FrameworkUtils.CurrentDateTimeAtomic().ToString(dateTimeFileFormat);
                    string reportName         = (this.ReportInfo.Name != String.Empty) ? string.Format("_{0}", this.ReportInfo.Name) : String.Empty;
                    fileName = string.Format("print_{0}{1}{2}", dateTime, reportName, ".pdf");
                    fileName = fileName.Replace('/', '-').Replace(' ', '_');
                    //2015-06-12 apmuga
                    fileName = FrameworkUtils.OSSlash(string.Format(@"{0}{1}", GlobalFramework.Path["temp"], fileName));
                    //Mario
                    //fileName = (GlobalFramework.Settings["AppEnvironment"].ToUpper() == "web".ToUpper())
                    //    ? FrameworkUtils.OSSlash(string.Format(@"{0}{1}", GlobalFramework.Path["temp"], fileName))
                    //    : FrameworkUtils.OSSlash(string.Format(@"{0}\{1}{2}", Environment.CurrentDirectory, GlobalFramework.Path["temp"], fileName))
                    //;
                }
                FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
                //if (export.ShowDialog()) report.Export(export, fileName);
                try
                {
                    this.Export(export, fileName);
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }

                //Show Pdf
                if (pViewMode == CustomReportDisplayMode.ExportPDF && File.Exists(fileName))
                {
                    if (GlobalFramework.CanOpenFiles)
                    {
                        //Use full Path, keep untoutched fileName for result
                        System.Diagnostics.Process.Start(FrameworkUtils.OSSlash(string.Format(@"{0}\{1}", Environment.CurrentDirectory, fileName)));
                    }
                }
                result = fileName;
                break;

            default:
                break;
            }

            return(result);
        }