예제 #1
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Timer Service

        public static Dictionary <FIN_DocumentFinanceMaster, ServicesATSoapResult> ServiceSendPendentDocuments()
        {
            Dictionary <FIN_DocumentFinanceMaster, ServicesATSoapResult> result = new Dictionary <FIN_DocumentFinanceMaster, ServicesATSoapResult>();
            Guid key = Guid.Empty;
            FIN_DocumentFinanceMaster documentMaster = null;
            ServicesATSoapResult      soapResult     = new ServicesATSoapResult();

            try
            {
                //Invoice Documents
                if (SettingsApp.ServiceATSendDocuments)
                {
                    string sqlDocuments = GetDocumentsQuery(false);
                    //_log.Debug(String.Format("sqlDocuments: [{0}]", FrameworkUtils.RemoveCarriageReturnAndExtraWhiteSpaces(sqlDocuments)));

                    XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sqlDocuments);
                    foreach (SelectStatementResultRow row in xPSelectData.Data)
                    {
                        key            = new Guid(row.Values[xPSelectData.GetFieldIndex("Oid")].ToString());
                        documentMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), key);
                        //SendDocument
                        soapResult = SendDocument(documentMaster);

                        //Helper to Detect Documents
                        //Detect if Document is Already in AT System / -3 = "Já foi registado um documento idêntico."
                        //200 = Detect The operation has timed out | The remote name could not be resolved: 'servicos.portaldasfinancas.gov.pt'
                        //if (soapResult.ReturnCode.Equals("-3"))
                        //{
                        //    _log.Debug("BREAK");
                        //}

                        result.Add(documentMaster, soapResult);
                    }
                }

                //WayBill Documents
                if (SettingsApp.ServiceATSendDocumentsWayBill)
                {
                    string sqlDocumentsWayBill = GetDocumentsQuery(true);
                    //_log.Debug(String.Format("sqlDocumentsWayBill: [{0}]", FrameworkUtils.RemoveCarriageReturnAndExtraWhiteSpaces(sqlDocumentsWayBill)));

                    XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sqlDocumentsWayBill);
                    foreach (SelectStatementResultRow row in xPSelectData.Data)
                    {
                        key            = new Guid(row.Values[xPSelectData.GetFieldIndex("Oid")].ToString());
                        documentMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), key);
                        //SendDocument
                        soapResult = SendDocument(documentMaster);
                        result.Add(documentMaster, soapResult);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                Console.Write($"Error: [{ex.Message}]");
            }

            return(result);
        }
예제 #2
0
        public static XPSelectData GetAllNameTable()
        {
            string       SQLDatabase;
            XPSelectData database;
            String       sql = String.Empty;
            string       nameDatabase;

            if (GlobalFramework.SessionXpo.Connection.GetType().Name.Equals("SqlConnection"))
            {
                SQLDatabase = "SELECT getdate() AS Now;";
                database    = FrameworkUtils.GetSelectedDataFromQuery(GlobalFramework.SessionXpo, SQLDatabase);
                foreach (SelectStatementResultRow name in database.Data)
                {
                    nameDatabase = name.Values[0].ToString();
                    sql          = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
                }
            }
            else if (GlobalFramework.SessionXpo.Connection.GetType().Name.Equals("MySqlConnection"))
            {
                SQLDatabase = "SELECT DATABASE()";

                database = FrameworkUtils.GetSelectedDataFromQuery(GlobalFramework.SessionXpo, SQLDatabase);
                foreach (SelectStatementResultRow name in database.Data)
                {
                    nameDatabase = name.Values[0].ToString();
                    sql          = string.Format("Select TABLE_NAME from information_schema.tables WHERE TABLE_SCHEMA = '{0}' ORDER BY TABLE_NAME", nameDatabase);
                }
            }
            else
            {
                sql = string.Format("select tbl_name as TABLE_NAME from sqlite_master group by tbl_name");
            }
            return(FrameworkUtils.GetSelectedDataFromQuery(GlobalFramework.SessionXpo, sql));
        }
예제 #3
0
 /// <summary>
 /// Get total number of Opened Orders
 /// </summary>
 public static XPSelectData GetOpenOrderTables()
 {
     try
     {
         string       sql          = string.Format(@"SELECT PlaceTable FROM fin_documentordermain WHERE OrderStatus = 1;");
         XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sql);
         return(xPSelectData);
     }
     catch (Exception ex)
     {
         _log.Error(ex.Message, ex);
         return(null);
     }
 }
예제 #4
0
 /// <summary>
 /// Get total number of Opened Terminal Period Sessions
 /// </summary>
 public static XPSelectData GetSessionPeriodOpenTerminalSessions()
 {
     try
     {
         //string sql = string.Format(@"SELECT Count(*) as Count FROM pos_worksessionperiod WHERE Parent = '{0}' AND SessionStatus = 0;", GlobalFramework.WorkSessionPeriodDay.Oid.ToString());
         string       sql          = string.Format(@"SELECT Oid, Designation, DateStart, Terminal FROM pos_worksessionperiod WHERE PeriodType = 1 AND Parent = '{0}' AND SessionStatus = 0;", GlobalFramework.WorkSessionPeriodDay.Oid.ToString());
         XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sql);
         return(xPSelectData);
     }
     catch (Exception ex)
     {
         _log.Error(ex.Message, ex);
         return(null);
     }
 }
예제 #5
0
        //Load Data from GetDataTableFromQuery
        private void Load(string pSql)
        {
            //Get SelectedData
            XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(_session, pSql);
            //Add Columns
            string fieldName;
            string fieldType;
            string fieldValue;

            foreach (SelectStatementResultRow column in xPSelectData.Meta)
            {
                fieldName = column.Values[0].ToString();
                fieldType = column.Values[2].ToString();
                this.Columns.Add(fieldName, typeof(string));
            }

            //Add Rows
            foreach (SelectStatementResultRow rowData in xPSelectData.Data)
            {
                //Init a new DataRow
                Object[] dataRow = new String[xPSelectData.Meta.Length];

                foreach (SelectStatementResultRow rowMeta in xPSelectData.Meta)
                {
                    fieldName = rowMeta.Values[0].ToString();
                    fieldType = rowMeta.Values[2].ToString();
                    //Check if is Not Null
                    if (rowData.Values[xPSelectData.GetFieldIndex(fieldName)] != null)
                    {
                        fieldValue = FrameworkUtils.FormatDataTableFieldFromType(rowData.Values[xPSelectData.GetFieldIndex(fieldName)].ToString(), fieldType);
                    }
                    else
                    {
                        fieldValue = string.Empty;
                    }
                    dataRow[xPSelectData.GetFieldIndex(fieldName)] = fieldValue;
                }
                this.Rows.Add(dataRow);
            }
        }
        public bool PrintWorkSessionMovement(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod, SplitCurrentAccountMode pSplitCurrentAccountMode)
        {
            bool result = false;

            if (pPrinter != null)
            {
                sys_configurationprinters          printer  = pPrinter;
                sys_configurationprinterstemplates template = (sys_configurationprinterstemplates)FrameworkUtils.GetXPGuidObject(typeof(sys_configurationprinterstemplates), SettingsApp.XpoOidConfigurationPrintersTemplateWorkSessionMovement);
                string splitCurrentAccountFilter            = string.Empty;
                string fileTicket = template.FileTemplate;

                switch (pSplitCurrentAccountMode)
                {
                case SplitCurrentAccountMode.All:
                    break;

                case SplitCurrentAccountMode.NonCurrentAcount:
                    //Diferent from DocumentType CC
                    splitCurrentAccountFilter = string.Format("AND DocumentType <> '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    break;

                case SplitCurrentAccountMode.CurrentAcount:
                    //Only DocumentType CC
                    splitCurrentAccountFilter = string.Format("AND DocumentType = '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    break;
                }

                try
                {
                    //Shared Where for details and totals Queries
                    string sqlWhere = string.Empty;

                    if (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
                    {
                        sqlWhere = string.Format("PeriodParent = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter);
                    }
                    else
                    {
                        sqlWhere = string.Format("Period = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter);
                    }

                    //Shared for Both Modes
                    if (sqlWhere != string.Empty)
                    {
                        sqlWhere = string.Format(" AND {0}", sqlWhere);
                    }

                    //Format to Display Vars
                    string dateCloseDisplay = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_in_progress") : pWorkSessionPeriod.DateEnd.ToString(SettingsApp.DateTimeFormat);

                    //Get Session Period Details
                    Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod);

                    //Print Header Summary
                    DataRow   dataRow   = null;
                    DataTable dataTable = new DataTable();
                    dataTable.Columns.Add(new DataColumn("Label", typeof(string)));
                    dataTable.Columns.Add(new DataColumn("Value", typeof(string)));
                    //Open DateTime
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_datetime"));
                    dataRow[1] = pWorkSessionPeriod.DateStart.ToString(SettingsApp.DateTimeFormat);
                    dataTable.Rows.Add(dataRow);
                    //Close DataTime
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_datetime"));
                    dataRow[1] = dateCloseDisplay;
                    dataTable.Rows.Add(dataRow);
                    //Open Total CashDrawer
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_total_cashdrawer"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]);
                    dataTable.Rows.Add(dataRow);
                    //Close Total CashDrawer
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_total_cashdrawer"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]);
                    dataTable.Rows.Add(dataRow);
                    //Total Money In
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_in"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]);
                    dataTable.Rows.Add(dataRow);
                    //Total Money Out
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_out"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]);
                    dataTable.Rows.Add(dataRow);
                    //Configure Ticket Column Properties
                    List <TicketColumn> columns = new List <TicketColumn>();
                    columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right));
                    columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left));
                    TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold);
                    //Print Ticket Table
                    ticketTable.Print(_thermalPrinterGeneric);
                    //Line Feed
                    _thermalPrinterGeneric.LineFeed();

                    //Get Final Rendered DataTable Groups
                    Dictionary <DataTableGroupPropertiesType, DataTableGroupProperties> dictGroupProperties = GenDataTableWorkSessionMovementResume(pWorkSessionPeriod.PeriodType, pSplitCurrentAccountMode, sqlWhere);

                    //Prepare Local vars for Group Loop
                    XPSelectData xPSelectData = null;
                    string       designation  = string.Empty;
                    decimal      quantity     = 0.0m;
                    decimal      total        = 0.0m;
                    string       unitMeasure  = string.Empty;
                    //Store Final Totals
                    decimal summaryTotalQuantity = 0.0m;
                    decimal summaryTotal         = 0.0m;
                    //Used to Custom Print Table Ticket Rows
                    List <string> tableCustomPrint = new List <string>();

                    //Start to process Group
                    int groupPosition = -1;
                    //Assign Position to Print Payment Group Split Title
                    int groupPositionTitlePayments = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ? 9 : 8;
                    //If CurrentAccount Mode decrease 1, it dont have PaymentMethods
                    if (pSplitCurrentAccountMode == SplitCurrentAccountMode.CurrentAcount)
                    {
                        groupPositionTitlePayments--;
                    }


                    foreach (KeyValuePair <DataTableGroupPropertiesType, DataTableGroupProperties> item in dictGroupProperties)
                    //foreach (DataTableGroupProperties item in dictGroupProperties.Values)
                    {
                        if (item.Value.Enabled)
                        {
                            //Increment Group Position
                            groupPosition++;

                            //Print Group Titles (FinanceDocuments|Payments)
                            if (groupPosition == 0)
                            {
                                _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents"), WriteLineTextMode.Big);
                                _thermalPrinterGeneric.LineFeed();
                            }
                            else if (groupPosition == groupPositionTitlePayments)
                            {
                                //When finish FinanceDocuemnts groups, print Last Row, the Summary Totals Row
                                _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight);
                                _thermalPrinterGeneric.LineFeed();

                                _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_paymens_documents"), WriteLineTextMode.Big);
                                _thermalPrinterGeneric.LineFeed();
                            }

                            //Reset Totals
                            summaryTotalQuantity = 0.0m;
                            summaryTotal         = 0.0m;

                            //Get Group Data from group Query
                            xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(item.Value.Sql);

                            //Generate Columns
                            columns = new List <TicketColumn>();
                            columns.Add(new TicketColumn("GroupTitle", item.Value.Title, 0, TicketColumnsAlign.Left));
                            columns.Add(new TicketColumn("Quantity", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quantity_acronym"), 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));
                            //columns.Add(new TicketColumn("UnitMeasure", string.Empty, 3));
                            columns.Add(new TicketColumn("Total", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalfinal_acronym"), 10, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));

                            //Init DataTable
                            dataTable = new DataTable();
                            dataTable.Columns.Add(new DataColumn("GroupDesignation", typeof(string)));
                            dataTable.Columns.Add(new DataColumn("Quantity", typeof(decimal)));
                            //dataTable.Columns.Add(new DataColumn("UnitMeasure", typeof(string)));
                            dataTable.Columns.Add(new DataColumn("Total", typeof(decimal)));

                            //If Has data
                            if (xPSelectData.Data.Length > 0)
                            {
                                foreach (SelectStatementResultRow row in xPSelectData.Data)
                                {
                                    designation = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("Designation")]);
                                    quantity    = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Quantity")]);
                                    unitMeasure = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("UnitMeasure")]);
                                    total       = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Total")]);
                                    // Override Encrypted values
                                    if (GlobalFramework.PluginSoftwareVendor != null && item.Key.Equals(DataTableGroupPropertiesType.DocumentsUser) || item.Key.Equals(DataTableGroupPropertiesType.PaymentsUser))
                                    {
                                        designation = GlobalFramework.PluginSoftwareVendor.Decrypt(designation);
                                    }
                                    //Sum Summary Totals
                                    summaryTotalQuantity += quantity;
                                    summaryTotal         += total;
                                    //_log.Debug(string.Format("Designation: [{0}], quantity: [{1}], unitMeasure: [{2}], total: [{3}]", designation, quantity, unitMeasure, total));
                                    //Create Row
                                    dataRow    = dataTable.NewRow();
                                    dataRow[0] = designation;
                                    dataRow[1] = quantity;
                                    //dataRow[2] = unitMeasure;
                                    dataRow[2] = total;
                                    dataTable.Rows.Add(dataRow);
                                }
                            }
                            else
                            {
                                //Create Row
                                dataRow    = dataTable.NewRow();
                                dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_without_movements");
                                dataRow[1] = 0.0m;
                                //dataRow[2] = string.Empty;//UnitMeasure
                                dataRow[2] = 0.0m;
                                dataTable.Rows.Add(dataRow);
                            }

                            //Add Final Summary Row
                            dataRow    = dataTable.NewRow();
                            dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total");
                            dataRow[1] = summaryTotalQuantity;
                            //dataRow[2] = string.Empty;
                            dataRow[2] = summaryTotal;
                            dataTable.Rows.Add(dataRow);

                            //Prepare TicketTable
                            ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal);

                            //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (Title and Total)
                            tableCustomPrint = ticketTable.GetTable();
                            WriteLineTextMode rowTextMode;

                            //Dynamic Print All except Last One (Totals), Double Height in Titles
                            for (int i = 0; i < tableCustomPrint.Count - 1; i++)
                            {
                                //Prepare TextMode Based on Row
                                rowTextMode = (i == 0) ? WriteLineTextMode.DoubleHeight : WriteLineTextMode.Normal;
                                //Print Row
                                _thermalPrinterGeneric.WriteLine(tableCustomPrint[i], rowTextMode);
                            }

                            //Line Feed
                            _thermalPrinterGeneric.LineFeed();
                        }
                    }

                    //When finish all groups, print Last Row, the Summary Totals Row, Ommited in Custom Print Loop
                    _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight);

                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    throw new Exception(ex.Message);
                }
            }

            return(result);
        }
예제 #7
0
        public FRBOGenericCollection(string pFilter, string pGroup, string pOrder, string pFields, int pLimit)
        {
            //Assign Attributes Defined
            _objectHaveAttributes = ((typeof(T).GetCustomAttribute(typeof(FRBOAttribute)) as FRBOAttribute) != null) ? true : false;

            //Attributes: Sql
            string sqlQuery = (_objectHaveAttributes && (typeof(T).GetCustomAttribute(typeof(FRBOAttribute)) as FRBOAttribute).Sql != null)
                ? (typeof(T).GetCustomAttribute(typeof(FRBOAttribute)) as FRBOAttribute).Sql
                              //If not SqlQuery Defined from Attributes, Create it From Reflection and FRBO Object Attributes
                : GenQueryFromFRBOObject(pFilter, pGroup, pOrder, pFields);

            //Atributes: Limit
            int sqlLimit = 0;

            //Get Order From Parameters
            if (pLimit > 0)
            {
                sqlLimit = pLimit;
            }
            //Limit: Get Order From LimitAttribute else Bypass it With 0
            else if (_objectHaveAttributes && (typeof(T).GetCustomAttribute(typeof(FRBOAttribute)) as FRBOAttribute).Limit > 0)
            {
                sqlLimit = (typeof(T).GetCustomAttribute(typeof(FRBOAttribute)) as FRBOAttribute).Limit;
            }

            try
            {
                //Start Process Collection

                //Temporary GenericTypeObject to Add to Collection
                T            genericTypeObject;
                XPSelectData xPSelectData;

                xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sqlQuery);

                PropertyInfo propertyInfo;
                //Fields Props
                string fieldName   = String.Empty;
                string fieldType   = String.Empty;
                string fieldTypeDB = String.Empty;
                Object fieldValue;
                int    fieldIndex;

                int i = 0;
                foreach (SelectStatementResultRow rowData in xPSelectData.Data)
                {
                    i++;
                    //If sqlLimit Defined and is Greater Break Loop
                    if (sqlLimit > 0 && i > sqlLimit)
                    {
                        break;
                    }

                    //Create a new Fresh T Object to Insert into Collection
                    //Cannot create an instance of the variable type 'T' because it does not have the new() constraint
                    //Require Constrain new()
                    genericTypeObject = new T();
                    foreach (SelectStatementResultRow rowMeta in xPSelectData.Meta)
                    {
                        fieldName   = rowMeta.Values[0].ToString();
                        fieldTypeDB = rowMeta.Values[1].ToString();;
                        fieldType   = rowMeta.Values[2].ToString();;
                        fieldIndex  = xPSelectData.GetFieldIndex(fieldName);

                        //Convert DB Types, Else working on Diferent DBs occur Conversion Exceptions
                        switch (fieldType)
                        {
                        case "Int64":
                        case "UInt32":
                            //case "UInt64":
                            fieldValue = Convert.ToInt32(rowData.Values[fieldIndex]);
                            break;

                        case "UInt64":
                            fieldValue = Convert.ToBoolean(rowData.Values[fieldIndex]);
                            break;

                        case "Boolean":
                            fieldValue = Convert.ToBoolean(rowData.Values[fieldIndex]);
                            break;

                        case "Guid":
                            fieldValue = Convert.ToString(rowData.Values[fieldIndex]);
                            break;

                        case "Decimal":    //Added to fix MsSql Errors
                        case "Double":
                            fieldValue = Convert.ToDecimal(rowData.Values[fieldIndex]);
                            break;

                        default:
                            fieldValue = rowData.Values[fieldIndex];
                            break;
                        }

                        try
                        {
                            //If Property Exist in genericTypeObject Assign it from Data
                            propertyInfo = typeof(T).GetProperty(fieldName);

                            //if (fieldName.Equals("SourceOrderMain") && string.IsNullOrEmpty(fieldValue.ToString()))
                            //{
                            //    _log.Debug(String.Format("fieldName: [{0}], fieldValue: [{1}]", fieldName, fieldValue));
                            //}

                            //Fix for MSSqlServer that detects UInt32 has Decimal, this way we convert it into UInt32 before above SetValue
                            if (propertyInfo.PropertyType == typeof(UInt32))
                            {
                                fieldValue = Convert.ToUInt32(rowData.Values[fieldIndex]);
                            }
                            //Fix for SQLite that detects UInt64 has Decimal, this way we convert it into Decimal before above SetValue
                            else if (propertyInfo.PropertyType == typeof(decimal))
                            {
                                fieldValue = Convert.ToDecimal(rowData.Values[fieldIndex]);
                            }
                            // Fix FRBO Object Field od type Guid
                            else if (propertyInfo.PropertyType == typeof(Guid))
                            {
                                fieldValue = new Guid(rowData.Values[fieldIndex].ToString());
                            }
                            // Check id is a Subclass of XPGuidObject and Get its value
                            else if (propertyInfo.PropertyType.IsSubclassOf(typeof(XPGuidObject)))
                            {
                                // Protection to prevent assign string value to Guid/unique identifier
                                if (fieldValue != null && string.IsNullOrEmpty(fieldValue.ToString()))
                                {
                                    fieldValue = null;
                                }
                                else
                                {
                                    fieldValue = FrameworkUtils.GetXPGuidObjectFromCriteria(propertyInfo.PropertyType, string.Format("Oid = '{0}'", fieldValue));
                                }
                                // Debug purpose helper
                                //if(propertyInfo.PropertyType == typeof(sys_userdetail) || propertyInfo.PropertyType == typeof(pos_configurationplaceterminal))
                                //{
                                //    _log.Debug(String.Format("fieldName: [{0}], fieldValue: [{1}]", fieldName, fieldValue));
                                //}
                            }

                            // Try to Setvalue
                            if (propertyInfo != null)
                            {
                                propertyInfo.SetValue(genericTypeObject, fieldValue);
                            }
                        }
                        catch (Exception)
                        {
                            // Intentionnaly Commented ex
                            // Prevent Showing Conversion Error, Only Occur in Sales Per Day(Detailled/Group) Report, Minor problem, it Show Good Values
                            //_log.Error(string.Format("fieldName: [{0}], fieldType: [{1}], fieldTypeDB: [{2}], fieldValue: [{3}]", fieldName, fieldType, fieldTypeDB, fieldValue));
                            //_log.Error(ex.Message, ex);
                        }
                    }
                    //Add genericTypeObject to Collection :)
                    Add(genericTypeObject);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                _log.Error(string.Format("Error sqlQuery: [{0}]", sqlQuery));
            }
        }
예제 #8
0
        public PosCashDrawerDialog(Window pSourceWindow, DialogFlags pDialogFlags)
        //Disable WindowTitleCloseButton
            : base(pSourceWindow, pDialogFlags, true, false)
        {
            try
            {
                //Parameters
                _sourceWindow = pSourceWindow;

                //If has a valid open session
                if (GlobalFramework.WorkSessionPeriodTerminal != null)
                {
                    //Get From MoneyInCashDrawer, Includes CASHDRAWER_START and Money Movements
                    _totalAmountInCashDrawer = ProcessWorkSessionPeriod.GetSessionPeriodMovementTotal(GlobalFramework.WorkSessionPeriodTerminal, MovementTypeTotal.MoneyInCashDrawer);
                }
                //Dont have Open Terminal Session YET, use from last Closed CashDrawer
                else
                {
                    //Default Last Closed Cash Value
                    _totalAmountInCashDrawer = ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount("CASHDRAWER_CLOSE");
                }

                //Init Local Vars
                String windowTitle           = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_cashdrawer"), FrameworkUtils.DecimalToStringCurrency(_totalAmountInCashDrawer));
                Size   windowSize            = new Size(462, 310);//400 With Other Payments
                String fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_cash_drawer.png");
                String fileActionPrint       = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Dialogs\icon_pos_dialog_action_print.png");

                //Get SeletedData from WorkSessionMovementType Buttons
                string       executeSql   = @"SELECT Oid, Token, ResourceString, ButtonIcon, Disabled FROM pos_worksessionmovementtype WHERE (Token LIKE 'CASHDRAWER_%') AND (Disabled IS NULL or Disabled  <> 1) ORDER BY Ord;";
                XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(executeSql);
                //Init Dictionary
                string buttonBagKey;
                bool   buttonDisabled;
                Dictionary <string, TouchButtonIconWithText> buttonBag = new Dictionary <string, TouchButtonIconWithText>();
                TouchButtonIconWithText touchButtonIconWithText;
                HBox hboxCashDrawerButtons = new HBox(true, 5);
                bool buttonOkSensitive;

                //Generate Buttons
                foreach (SelectStatementResultRow row in xPSelectData.Data)
                {
                    buttonBagKey   = row.Values[xPSelectData.GetFieldIndex("Token")].ToString();
                    buttonDisabled = Convert.ToBoolean(row.Values[xPSelectData.GetFieldIndex("Disabled")]);

                    touchButtonIconWithText = new TouchButtonIconWithText(
                        string.Format("touchButton{0}_Green", buttonBagKey),
                        Color.Transparent /*_colorBaseDialogDefaultButtonBackground*/,
                        resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], row.Values[xPSelectData.GetFieldIndex("ResourceString")].ToString()),
                        _fontBaseDialogButton,
                        _colorBaseDialogDefaultButtonFont,
                        FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], row.Values[xPSelectData.GetFieldIndex("ButtonIcon")].ToString())),
                        _sizeBaseDialogDefaultButtonIcon,
                        _sizeBaseDialogDefaultButton.Width,
                        _sizeBaseDialogDefaultButton.Height
                        )
                    {
                        CurrentButtonOid = new Guid(row.Values[xPSelectData.GetFieldIndex("Oid")].ToString()),
                        Sensitive        = !buttonDisabled
                    };
                    //Add to Dictionary
                    buttonBag.Add(buttonBagKey, touchButtonIconWithText);
                    //pack to VBhox
                    hboxCashDrawerButtons.PackStart(touchButtonIconWithText, true, true, 0);
                    //Events
                    buttonBag[buttonBagKey].Clicked += PosCashDrawerDialog_Clicked;
                }

                //Initial Button Status, Based on Open/Close Terminal Session
                string initialButtonToken;
                if (GlobalFramework.WorkSessionPeriodTerminal != null && GlobalFramework.WorkSessionPeriodTerminal.SessionStatus == WorkSessionPeriodStatus.Open)
                {
                    buttonBag["CASHDRAWER_OPEN"].Sensitive  = false;
                    buttonBag["CASHDRAWER_CLOSE"].Sensitive = true;
                    buttonBag["CASHDRAWER_IN"].Sensitive    = true;
                    buttonBag["CASHDRAWER_OUT"].Sensitive   = true;
                    initialButtonToken = "CASHDRAWER_CLOSE";
                    buttonOkSensitive  = true;
                }
                else
                {
                    buttonBag["CASHDRAWER_OPEN"].Sensitive  = true;
                    buttonBag["CASHDRAWER_CLOSE"].Sensitive = false;
                    buttonBag["CASHDRAWER_IN"].Sensitive    = false;
                    buttonBag["CASHDRAWER_OUT"].Sensitive   = false;
                    initialButtonToken = "CASHDRAWER_OPEN";
                    buttonOkSensitive  = false;
                }
                //Initial Dialog Values
                _selectedCashDrawerButton = buttonBag[initialButtonToken];
                _selectedCashDrawerButton.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(Utils.Lighten(_colorBaseDialogDefaultButtonBackground, 0.50f)));
                _selectedMovementType       = (pos_worksessionmovementtype)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(pos_worksessionmovementtype), _selectedCashDrawerButton.CurrentButtonOid);
                _selectedMovementType.Token = initialButtonToken;

                //EntryAmountMoney
                _entryBoxMovementAmountMoney = new EntryBoxValidation(this, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_money"), KeyboardMode.Money, SettingsApp.RegexDecimalGreaterEqualThanZero, true);
                _entryBoxMovementAmountMoney.EntryValidation.Changed += delegate { ValidateDialog(); };

                //TODO: Enable Other Payments
                //EntryAmountOtherPayments
                //_entryBoxMovementAmountOtherPayments = new EntryBox(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_other_payments, KeyboardModes.Money, regexDecimalGreaterThanZero, false);
                //_entryBoxMovementAmountOtherPayments.EntryValidation.Changed += delegate { ValidateDialog(); };

                //EntryDescription
                _entryBoxMovementDescription = new EntryBoxValidation(this, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_description"), KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, false);
                _entryBoxMovementDescription.EntryValidation.Changed += delegate { ValidateDialog(); };

                //VBox
                VBox vbox = new VBox(false, 0);
                vbox.PackStart(hboxCashDrawerButtons, false, false, 0);
                vbox.PackStart(_entryBoxMovementAmountMoney, false, false, 0);
                //vbox.PackStart(_entryBoxMovementAmountOtherPayments, false, false, 0);
                vbox.PackStart(_entryBoxMovementDescription, false, false, 0);

                //Init Content
                Fixed fixedContent = new Fixed();
                fixedContent.Put(vbox, 0, 0);

                //ActionArea Buttons
                _buttonOk              = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok);
                _buttonCancel          = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel);
                _buttonPrint           = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Print);
                _buttonOk.Sensitive    = false;
                _buttonPrint.Sensitive = buttonOkSensitive;

                //ActionArea
                ActionAreaButtons actionAreaButtons = new ActionAreaButtons();
                actionAreaButtons.Add(new ActionAreaButton(_buttonPrint, _responseTypePrint));
                actionAreaButtons.Add(new ActionAreaButton(_buttonOk, ResponseType.Ok));
                actionAreaButtons.Add(new ActionAreaButton(_buttonCancel, ResponseType.Cancel));

                //Call Activate Button Helper Method
                ActivateButton(buttonBag[initialButtonToken]);

                //Init Object
                this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, fixedContent, actionAreaButtons);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
예제 #9
0
        private void InitDefinition(string pTableParent, string pTableChild, string pTableChildWhereField)
        {
            bool debug = false;

            //Init Definition
            _accordionDefinition = new Dictionary <string, AccordionNode>();

            //Generate Base Queries
            string sqlTableParent = string.Format(@"SELECT Oid AS id, Designation AS label, ResourceString AS resource FROM {0} WHERE (Disabled IS NULL or Disabled  <> 1) ORDER BY Ord;", pTableParent);
            string sqlTableChild  = string.Format(@"SELECT Oid AS id, Designation AS label, ResourceString AS resource FROM {0} WHERE (Disabled IS NULL or Disabled  <> 1) AND ({1} = '{2}') ORDER BY Ord;", pTableChild, pTableChildWhereField, "{0}");

            if (debug)
            {
                _log.Debug(string.Format("InitDefinition(): sqlTableParent: [{0}]", sqlTableParent));
                _log.Debug(string.Format("InitDefinition(): sqlTableChild: [{0}]", sqlTableChild));
            }

            //Get XPSelectData for Parent and Child
            XPSelectData xPSelectDataParent = FrameworkUtils.GetSelectedDataFromQuery(sqlTableParent);
            XPSelectData xPSelectDataChild;
            //Initialize Vars
            string parentId = string.Empty, parentLabel = string.Empty, parentResource = string.Empty;
            string childId = string.Empty, childLabel = string.Empty, childResource = string.Empty;
            Dictionary <string, AccordionNode> _accordionChilds = new Dictionary <string, AccordionNode>();

            //Start Render Accordion Parent Nodes
            foreach (SelectStatementResultRow parentRow in xPSelectDataParent.Data)
            {
                parentId    = parentRow.Values[xPSelectDataParent.GetFieldIndex("id")].ToString();
                parentLabel = parentRow.Values[xPSelectDataParent.GetFieldIndex("label")].ToString();
                if (parentRow.Values[xPSelectDataParent.GetFieldIndex("resource")] != null)
                {
                    parentResource = parentRow.Values[xPSelectDataParent.GetFieldIndex("resource")].ToString();
                    //Bypass default db label with Resources Localization Label
                    if (Resx
                        .ResourceManager.GetString(parentResource) != null)
                    {
                        parentLabel = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], parentResource);
                    }
                }

                //Get Child Data
                xPSelectDataChild = FrameworkUtils.GetSelectedDataFromQuery(string.Format(sqlTableChild, parentId));
                //Init Childs
                _accordionChilds = new Dictionary <string, AccordionNode>();

                //Start Render Accordion Parent Childs
                foreach (SelectStatementResultRow childRow in xPSelectDataChild.Data)
                {
                    childId    = childRow.Values[xPSelectDataChild.GetFieldIndex("id")].ToString();
                    childLabel = childRow.Values[xPSelectDataChild.GetFieldIndex("label")].ToString();
                    if (childRow.Values[xPSelectDataChild.GetFieldIndex("resource")] != null)
                    {
                        childResource = childRow.Values[xPSelectDataChild.GetFieldIndex("resource")].ToString();
                        //Bypass default db label with Resources Localization Label
                        if (resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], childResource) != null)
                        {
                            childLabel = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], childResource);
                        }
                    }
                    _accordionChilds.Add(string.Format("childId_{0}", childId), new AccordionNode(childLabel)
                    {
                        Content = new Button(childLabel)
                    });
                }
                _accordionDefinition.Add(string.Format("parentId_{0}", parentId), new AccordionNode(parentLabel)
                {
                    Childs = _accordionChilds
                });
            }
        }
예제 #10
0
        public static bool PersistWorkSessionTotals(POS_WorkSessionPeriod pWorkSessionPeriod)
        {
            try
            {
                //Start UnitOfWork
                using (UnitOfWork uowSession = new UnitOfWork())
                {
                    uint                           paymentMethodOrd   = 0;
                    string                         paymentMethodToken = String.Empty;
                    MovementTypeTotal              movementTypeTotal  = MovementTypeTotal.None;
                    POS_WorkSessionPeriod          workSessionPeriod;
                    FIN_ConfigurationPaymentMethod configurationPaymentMethod;
                    POS_WorkSessionPeriodTotal     workSessionPeriodTotal;
                    //Can filter by Day or Terminal type
                    string wherePeriodField = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Terminal) ? "wspPeriod" : "wspPeriodParent";

                    string sql = string.Format(@"
                        SELECT 
                              DISTINCT(cpmPaymentMethodToken) as Token,
                              cpmPaymentMethodOrd as Ord
                        FROM 
                            view_worksessionmovement 
                        WHERE 
                            cpmPaymentMethodToken IS NOT NULL AND {0} = '{1}'
                        ORDER 
                            BY cpmPaymentMethodOrd
                        ;"
                                               , wherePeriodField
                                               , pWorkSessionPeriod.Oid
                                               );

                    XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(uowSession, sql);
                    foreach (SelectStatementResultRow row in xPSelectData.Data)
                    {
                        paymentMethodOrd   = Convert.ToUInt16(row.Values[xPSelectData.GetFieldIndex("Ord")]);
                        paymentMethodToken = row.Values[xPSelectData.GetFieldIndex("Token")].ToString();

                        switch (paymentMethodToken)
                        {
                        case "MONEY":
                            movementTypeTotal = MovementTypeTotal.Money;
                            break;

                        case "BANK_CHECK":
                            movementTypeTotal = MovementTypeTotal.BankCheck;
                            break;

                        case "CASH_MACHINE":
                            movementTypeTotal = MovementTypeTotal.CashMachine;
                            break;

                        case "CREDIT_CARD":
                            movementTypeTotal = MovementTypeTotal.Credit;
                            break;

                        case "VISA":
                            movementTypeTotal = MovementTypeTotal.Visa;
                            break;

                        case "CURRENT_ACCOUNT":
                            movementTypeTotal = MovementTypeTotal.CurrentAccount;
                            break;
                        }

                        if (movementTypeTotal != MovementTypeTotal.None)
                        {
                            //Get XPObjects
                            workSessionPeriod          = uowSession.GetObjectByKey <POS_WorkSessionPeriod>(pWorkSessionPeriod.Oid);
                            configurationPaymentMethod = (FIN_ConfigurationPaymentMethod)FrameworkUtils.GetXPGuidObjectFromField(uowSession, typeof(FIN_ConfigurationPaymentMethod), "Token", paymentMethodToken);

                            //Persist WorkSessionPeriodTotal
                            workSessionPeriodTotal = new POS_WorkSessionPeriodTotal(uowSession)
                            {
                                Ord           = paymentMethodOrd,
                                PaymentMethod = configurationPaymentMethod,
                                Total         = GetSessionPeriodMovementTotal(workSessionPeriod, movementTypeTotal),
                                Period        = workSessionPeriod
                            };
                        }
                    }
                    ;

                    try
                    {
                        //Commit UOW Changes
                        uowSession.CommitChanges();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        //Rollback
                        uowSession.RollbackTransaction();
                        _log.Error(ex.Message, ex);
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
예제 #11
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Static Methods

        //Create ArticleBag From OrderMain.OrderTicket, and Discount PartialPayments for Working OrderMain
        public static ArticleBag TicketOrderToArticleBag(OrderMain pOrderMain)
        {
            //Log4Net
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            bool debug = false;

            //OrderMain
            OrderMain orderMain = pOrderMain;
            //ArticleBag
            ArticleBag           articleBag = new ArticleBag();
            ArticleBagKey        articleBagKey;
            ArticleBagProperties articleBagProps;

            //Removed, gives problems, Avoid used DropIdentityMap
            //GlobalFramework.SessionXpo.DropIdentityMap();

            try
            {
                if (orderMain.PersistentOid != Guid.Empty)
                {
                    string sqlOrders = string.Format(@"
                        SELECT 
                            dmOid AS DocumentOrderMain, ddArticle AS Article, ddDesignation AS Designation,ddPrice AS Price,ddDiscount AS Discount,ddVat AS Vat,ddVatExemptionReason AS VatExemptionReason,
                            cpOid AS ConfigurationPlace, ctOid AS ConfigurationPlaceTable, dtPriceType AS PriceType, ddCode AS Code, ddQuantity AS Quantity, ddUnitMeasure AS UnitMeasure,
                            ddToken1 as Token1, ddToken2 as Token2
                        FROM 
                            view_orders 
                        WHERE 
                            dmOid = '{0}'
                        ORDER BY 
                            dtTicketId
                        ;"
                                                     , orderMain.PersistentOid
                                                     );
                    XPSelectData selectedDataOrders = FrameworkUtils.GetSelectedDataFromQuery(sqlOrders);

                    //Process Tickets and Add to ArticleBag
                    if (selectedDataOrders.Data.Length > 0)
                    {
                        foreach (SelectStatementResultRow row in selectedDataOrders.Data)
                        {
                            //Generate Key/Props
                            articleBagKey = new ArticleBagKey(
                                new Guid(row.Values[selectedDataOrders.GetFieldIndex("Article")].ToString()),                                   //ticketLine.Article.Oid
                                Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("Designation")]),                                  //ticketLine.Designation
                                Convert.ToDecimal(row.Values[selectedDataOrders.GetFieldIndex("Price")]),                                       //ticketLine.Price
                                Convert.ToDecimal(row.Values[selectedDataOrders.GetFieldIndex("Discount")]),                                    //ticketLine.Discount
                                Convert.ToDecimal(row.Values[selectedDataOrders.GetFieldIndex("Vat")])                                          //ticketLine.Vat
                                );

                            articleBagProps = new ArticleBagProperties(
                                new Guid(row.Values[selectedDataOrders.GetFieldIndex("ConfigurationPlace")].ToString()),                        //ticket.PlaceTable.Place.Oid
                                new Guid(row.Values[selectedDataOrders.GetFieldIndex("ConfigurationPlaceTable")].ToString()),                   //ticket.PlaceTable.Oid
                                (PriceType)Enum.Parse(typeof(PriceType), row.Values[selectedDataOrders.GetFieldIndex("PriceType")].ToString()), //ticket.PriceType
                                Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("Code")]),                                         //ticketLine.Code
                                Convert.ToDecimal(row.Values[selectedDataOrders.GetFieldIndex("Quantity")]),                                    //ticketLine.Quantity
                                Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("UnitMeasure")])                                   //ticketLine.UnitMeasure
                                );

                            //Detect and Assign VatExemptionReason
                            if (row.Values[selectedDataOrders.GetFieldIndex("VatExemptionReason")] != null &&
                                Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("VatExemptionReason")]) != Guid.Empty.ToString()
                                )
                            {
                                //Add VatException Reason to Key
                                articleBagKey.VatExemptionReasonOid = new Guid(Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("VatExemptionReason")]));
                            }

                            //Tokens
                            articleBagProps.Token1 = Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("Token1")]); //ticketLine.Token1
                            articleBagProps.Token2 = Convert.ToString(row.Values[selectedDataOrders.GetFieldIndex("Token2")]); //ticketLine.Token2

                            //Send to Bag
                            if (articleBagProps.Quantity > 0)
                            {
                                articleBag.Add(articleBagKey, articleBagProps);
                            }

                            //if (debug) log.Debug(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}", ticket.PlaceTable.Place.Oid, ticket.PlaceTable.Designation, ticket.PriceType, ticketLine.Article.Oid, ticketLine.Code, ticketLine.Designation, ticketLine.Price, ticketLine.Quantity, ticketLine.UnitMeasure, ticketLine.Discount, ticketLine.Vat));
                        }
                    }

                    //Process PartialPayed Items and Remove From ArticleBag
                    string sqlDocuments = string.Format(@"
                        SELECT 
                            ftOid AS DocumentType,fdArticle AS Article,fdDesignation AS Designation,fdPrice AS Price,fdQuantity AS Quantity, fdDiscount AS Discount, fdVat AS Vat, fdVatExemptionReason AS VatExemptionReason
                        FROM 
                            view_documentfinance 
                        WHERE 
                            fmSourceOrderMain = '{0}'
                        ORDER BY 
                            ftOid,fmOid
                        ;"
                                                        , orderMain.PersistentOid
                                                        );

                    XPSelectData selectedDataDocuments = FrameworkUtils.GetSelectedDataFromQuery(sqlDocuments);
                    if (selectedDataDocuments.Data.Length > 0)
                    {
                        foreach (SelectStatementResultRow row in selectedDataDocuments.Data)
                        {
                            // If Not ConferenceDocument or TableConsult
                            if (row.Values[selectedDataDocuments.GetFieldIndex("DocumentType")].ToString() != SettingsApp.XpoOidDocumentFinanceTypeConferenceDocument.ToString())
                            {
                                //Generate Key/Props
                                articleBagKey = new ArticleBagKey(
                                    new Guid(row.Values[selectedDataDocuments.GetFieldIndex("Article")].ToString()),
                                    Convert.ToString(row.Values[selectedDataDocuments.GetFieldIndex("Designation")]),
                                    Convert.ToDecimal(row.Values[selectedDataDocuments.GetFieldIndex("Price")]),
                                    Convert.ToDecimal(row.Values[selectedDataDocuments.GetFieldIndex("Discount")]),
                                    Convert.ToDecimal(row.Values[selectedDataDocuments.GetFieldIndex("Vat")])
                                    );
                                //Detect and Assign VatExemptionReason
                                if (row.Values[selectedDataDocuments.GetFieldIndex("VatExemptionReason")] != null &&
                                    Convert.ToString(row.Values[selectedDataDocuments.GetFieldIndex("VatExemptionReason")]) != Guid.Empty.ToString()
                                    )
                                {
                                    //Add VatException Reason to Key
                                    articleBagKey.VatExemptionReasonOid = new Guid(Convert.ToString(row.Values[selectedDataDocuments.GetFieldIndex("VatExemptionReason")]));
                                }
                                if (articleBag.ContainsKey(articleBagKey))
                                {
                                    //Remove PartialPayed Item Quantity from ArticleBag
                                    articleBag.Remove(articleBagKey, Convert.ToDecimal(row.Values[selectedDataDocuments.GetFieldIndex("Quantity")]));
                                }
                                else
                                {
                                    if (debug)
                                    {
                                        log.Debug(string.Format("articleBagKey: [{0}]", articleBagKey));
                                    }
                                }
                            }
                        }
                    }
                    if (debug)
                    {
                        articleBag.ShowInLog();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }

            return(articleBag);
        }
예제 #12
0
        public PosPaymentsDialog(Window pSourceWindow, DialogFlags pDialogFlags, ArticleBag pArticleBag, bool pEnablePartialPaymentButtons, bool pEnableCurrentAccountButton, bool pSkipPersistFinanceDocument, ProcessFinanceDocumentParameter pProcessFinanceDocumentParameter, string pSelectedPaymentMethodButtonName)
            : base(pSourceWindow, pDialogFlags, false)
        {
            try
            {
                //Init Local Vars
                _sourceWindow = pSourceWindow;
                string windowTitle = Resx.window_title_dialog_payments;
                //TODO:THEME
                Size   windowSize            = new Size(598, 620);
                string fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_payments.png");

                //Parameters
                _articleBagFullPayment           = pArticleBag;
                _skipPersistFinanceDocument      = pSkipPersistFinanceDocument;
                _processFinanceDocumentParameter = pProcessFinanceDocumentParameter;
                bool enablePartialPaymentButtons = pEnablePartialPaymentButtons;
                bool enableCurrentAccountButton  = pEnableCurrentAccountButton;
                if (enablePartialPaymentButtons)
                {
                    enablePartialPaymentButtons = (_articleBagFullPayment.TotalQuantity > 1) ? true : false;
                }
                //Files
                string fileIconClearCustomer  = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_nav_delete.png");
                string fileIconFullPayment    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_payment_full.png");
                string fileIconPartialPayment = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_payment_partial.png");
                //Colors
                Color colorPosPaymentsDialogTotalPannelBackground = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorPosPaymentsDialogTotalPannelBackground"]);
                //Objects
                _intialValueConfigurationCountry = SettingsApp.ConfigurationSystemCountry;

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
                //Payment Buttons
                //Get Custom Select Data
                string       executeSql   = @"SELECT Oid, Token, ResourceString FROM fin_configurationpaymentmethod ORDER BY Ord;";
                XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(executeSql);
                //Get Required XpObjects from Selected Data
                FIN_ConfigurationPaymentMethod xpoMoney          = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "MONEY");
                FIN_ConfigurationPaymentMethod xpoCheck          = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "BANK_CHECK");
                FIN_ConfigurationPaymentMethod xpoMB             = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "CASH_MACHINE");
                FIN_ConfigurationPaymentMethod xpoCreditCard     = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "CREDIT_CARD");
                FIN_ConfigurationPaymentMethod xpoVisa           = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "VISA");
                FIN_ConfigurationPaymentMethod xpoCurrentAccount = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "CURRENT_ACCOUNT");
                FIN_ConfigurationPaymentMethod xpoCustomerCard   = (FIN_ConfigurationPaymentMethod)xPSelectData.GetXPGuidObjectFromField(typeof(FIN_ConfigurationPaymentMethod), "Token", "CUSTOMER_CARD");

                //Instantiate Buttons
                TouchButtonIconWithText buttonMoney = new TouchButtonIconWithText("touchButtonMoney_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoMoney.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoMoney.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoMoney.Oid, Sensitive = (xpoMoney.Disabled) ? false : true
                };
                TouchButtonIconWithText buttonCheck = new TouchButtonIconWithText("touchButtonCheck_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoCheck.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoCheck.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoCheck.Oid, Sensitive = (xpoCheck.Disabled) ? false : true
                };
                TouchButtonIconWithText buttonMB = new TouchButtonIconWithText("touchButtonMB_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoMB.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoMB.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoMB.Oid, Sensitive = (xpoMB.Disabled) ? false : true
                };
                TouchButtonIconWithText buttonCreditCard = new TouchButtonIconWithText("touchButtonCreditCard_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoCreditCard.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoCreditCard.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoCreditCard.Oid, Sensitive = (xpoCreditCard.Disabled) ? false : true
                };
                TouchButtonIconWithText buttonVisa = new TouchButtonIconWithText("touchButtonVisa_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoVisa.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoVisa.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoVisa.Oid, Sensitive = (xpoVisa.Disabled) ? false : true
                };
                TouchButtonIconWithText buttonCurrentAccount = new TouchButtonIconWithText("touchButtonCurrentAccount_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoCurrentAccount.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoCurrentAccount.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoCurrentAccount.Oid, Sensitive = (xpoCurrentAccount.Disabled) ? false : true
                };
                TouchButtonIconWithText buttonCustomerCard = new TouchButtonIconWithText("touchButtonCustomerCard_Green", _colorBaseDialogDefaultButtonBackground, Resx.ResourceManager.GetString(xpoCustomerCard.ResourceString), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], xpoCustomerCard.ButtonIcon)), _sizeBaseDialogDefaultButtonIcon, _sizeBaseDialogDefaultButton.Width, _sizeBaseDialogDefaultButton.Height)
                {
                    CurrentButtonOid = xpoCustomerCard.Oid, Sensitive = (xpoCustomerCard.Disabled) ? false : true
                };
                //Secondary Buttons
                //Events
                buttonMoney.Clicked          += buttonMoney_Clicked;
                buttonCheck.Clicked          += buttonCheck_Clicked;
                buttonMB.Clicked             += buttonMB_Clicked;
                buttonCreditCard.Clicked     += buttonCredit_Clicked;
                buttonVisa.Clicked           += buttonVisa_Clicked;
                buttonCurrentAccount.Clicked += buttonCurrentAccount_Clicked;
                buttonCustomerCard.Clicked   += buttonCustomerCard_Clicked;

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                //Table
                uint  tablePaymentsPadding = 0;
                Table tablePayments        = new Table(2, 3, true)
                {
                    BorderWidth = 2
                };
                //Row 1
                tablePayments.Attach(buttonMoney, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, tablePaymentsPadding, tablePaymentsPadding);
                tablePayments.Attach(buttonMB, 1, 2, 0, 1, AttachOptions.Fill, AttachOptions.Fill, tablePaymentsPadding, tablePaymentsPadding);
                tablePayments.Attach(buttonVisa, 2, 3, 0, 1, AttachOptions.Fill, AttachOptions.Fill, tablePaymentsPadding, tablePaymentsPadding);
                //Row 2
                tablePayments.Attach(buttonCheck, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, tablePaymentsPadding, tablePaymentsPadding);
                tablePayments.Attach(buttonCreditCard, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, tablePaymentsPadding, tablePaymentsPadding);
                if (enableCurrentAccountButton)
                {
                    tablePayments.Attach(
                        (SettingsApp.PosPaymentsDialogUseCurrentAccount) ? buttonCurrentAccount : buttonCustomerCard
                        , 2, 3, 1, 2, AttachOptions.Fill, AttachOptions.Fill, tablePaymentsPadding, tablePaymentsPadding
                        );
                }

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                //Labels
                Label labelTotal    = new Label(Resx.global_total_price_to_pay + ":");
                Label labelDelivery = new Label(Resx.global_total_deliver + ":");
                Label labelChange   = new Label(Resx.global_total_change + ":");
                _labelTotalValue = new Label(FrameworkUtils.DecimalToStringCurrency(_articleBagFullPayment.TotalFinal))
                {
                    //Total Width
                    WidthRequest = 120
                };
                _labelDeliveryValue = new Label(FrameworkUtils.DecimalToStringCurrency(0));
                _labelChangeValue   = new Label(FrameworkUtils.DecimalToStringCurrency(0));

                //Colors
                labelTotal.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(Color.FromArgb(101, 137, 171)));
                labelDelivery.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(Color.FromArgb(101, 137, 171)));
                labelChange.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(Color.FromArgb(101, 137, 171)));
                _labelTotalValue.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(Color.White));
                _labelDeliveryValue.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(Color.White));
                _labelChangeValue.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(Color.White));

                //Alignments
                labelTotal.SetAlignment(0, 0.5F);
                labelDelivery.SetAlignment(0, 0.5F);
                labelChange.SetAlignment(0, 0.5F);
                _labelTotalValue.SetAlignment(1, 0.5F);
                _labelDeliveryValue.SetAlignment(1, 0.5F);
                _labelChangeValue.SetAlignment(1, 0.5F);

                //labels Font
                Pango.FontDescription fontDescription = Pango.FontDescription.FromString("Bold 10");
                labelTotal.ModifyFont(fontDescription);
                labelDelivery.ModifyFont(fontDescription);
                labelChange.ModifyFont(fontDescription);
                Pango.FontDescription fontDescriptionValue = Pango.FontDescription.FromString("Bold 12");
                _labelTotalValue.ModifyFont(fontDescriptionValue);
                _labelDeliveryValue.ModifyFont(fontDescriptionValue);
                _labelChangeValue.ModifyFont(fontDescriptionValue);

                //Table TotalPannel
                uint  totalPannelPadding = 9;
                Table tableTotalPannel   = new Table(3, 2, false);
                tableTotalPannel.HeightRequest = 132;
                //Row 1
                tableTotalPannel.Attach(labelTotal, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, totalPannelPadding, totalPannelPadding);
                tableTotalPannel.Attach(_labelTotalValue, 1, 2, 0, 1, AttachOptions.Fill, AttachOptions.Fill, totalPannelPadding, totalPannelPadding);
                //Row 2
                tableTotalPannel.Attach(labelDelivery, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, totalPannelPadding, totalPannelPadding);
                tableTotalPannel.Attach(_labelDeliveryValue, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, totalPannelPadding, totalPannelPadding);
                //Row 3
                tableTotalPannel.Attach(labelChange, 0, 1, 2, 3, AttachOptions.Fill, AttachOptions.Fill, totalPannelPadding, totalPannelPadding);
                tableTotalPannel.Attach(_labelChangeValue, 1, 2, 2, 3, AttachOptions.Fill, AttachOptions.Fill, totalPannelPadding, totalPannelPadding);

                //TotalPannel
                EventBox eventboxTotalPannel = new EventBox();
                eventboxTotalPannel.BorderWidth = 3;
                eventboxTotalPannel.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorPosPaymentsDialogTotalPannelBackground));
                eventboxTotalPannel.Add(tableTotalPannel);

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                //Customer Name
                CriteriaOperator criteriaOperatorCustomerName = null;
                _entryBoxSelectCustomerName             = new XPOEntryBoxSelectRecordValidation <ERP_Customer, TreeViewCustomer>(_sourceWindow, Resx.global_customer, "Name", "Name", null, criteriaOperatorCustomerName, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumeric, false);
                _entryBoxSelectCustomerName.ClosePopup += delegate
                {
                    GetCustomerDetails("Oid", _entryBoxSelectCustomerName.Value.Oid.ToString());
                    Validate();
                };
                _entryBoxSelectCustomerName.EntryValidation.Changed += _entryBoxSelectCustomerName_Changed;

                //Customer Discount
                _entryBoxCustomerDiscount = new EntryBoxValidation(_sourceWindow, Resx.global_discount, KeyboardMode.Alfa, SettingsApp.RegexPercentage, true);
                _entryBoxCustomerDiscount.EntryValidation.Text           = FrameworkUtils.DecimalToString(0.0m);
                _entryBoxCustomerDiscount.EntryValidation.Sensitive      = false;
                _entryBoxCustomerDiscount.EntryValidation.Changed       += _entryBoxCustomerDiscount_Changed;
                _entryBoxCustomerDiscount.EntryValidation.FocusOutEvent += delegate
                {
                    _entryBoxCustomerDiscount.EntryValidation.Text = FrameworkUtils.StringToDecimalAndToStringAgain(_entryBoxCustomerDiscount.EntryValidation.Text);
                };

                //Address
                _entryBoxCustomerAddress = new EntryBoxValidation(this, Resx.global_address, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, false);
                _entryBoxCustomerAddress.EntryValidation.Changed += delegate { Validate(); };

                //Locality
                _entryBoxCustomerLocality = new EntryBoxValidation(this, Resx.global_locality, KeyboardMode.Alfa, SettingsApp.RegexAlfa, false);
                _entryBoxCustomerLocality.EntryValidation.Changed += delegate { Validate(); };

                //ZipCode
                _entryBoxCustomerZipCode = new EntryBoxValidation(this, Resx.global_zipcode, KeyboardMode.Alfa, SettingsApp.ConfigurationSystemCountry.RegExZipCode, false);
                _entryBoxCustomerZipCode.WidthRequest             = 150;
                _entryBoxCustomerZipCode.EntryValidation.Changed += delegate { Validate(); };

                //City
                _entryBoxCustomerCity = new EntryBoxValidation(this, Resx.global_city, KeyboardMode.Alfa, SettingsApp.RegexAlfa, false);
                _entryBoxCustomerCity.WidthRequest             = 200;
                _entryBoxCustomerCity.EntryValidation.Changed += delegate { Validate(); };

                //Country
                CriteriaOperator criteriaOperatorCustomerCountry = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (RegExFiscalNumber IS NOT NULL AND RegExZipCode IS NOT NULL)");
                _entryBoxSelectCustomerCountry = new XPOEntryBoxSelectRecordValidation <CFG_ConfigurationCountry, TreeViewConfigurationCountry>(pSourceWindow, Resx.global_country, "Designation", "Oid", _intialValueConfigurationCountry, criteriaOperatorCustomerCountry, SettingsApp.RegexGuid, true);
                _entryBoxSelectCustomerCountry.WidthRequest = 235;
                //Extra Protection to prevent Customer without Country
                if (_entryBoxSelectCustomerCountry.Value != null)
                {
                    _entryBoxSelectCustomerCountry.EntryValidation.Validate(_entryBoxSelectCustomerCountry.Value.Oid.ToString());
                }
                _entryBoxSelectCustomerCountry.EntryValidation.IsEditable  = false;
                _entryBoxSelectCustomerCountry.ButtonSelectValue.Sensitive = false;
                _entryBoxSelectCustomerCountry.ClosePopup += delegate
                {
                    _selectedCountry = _entryBoxSelectCustomerCountry.Value;
                    //Require to Update RegEx and Criteria to filter Country Clients Only
                    _entryBoxSelectCustomerFiscalNumber.EntryValidation.Rule = _entryBoxSelectCustomerCountry.Value.RegExFiscalNumber;
                    _entryBoxCustomerZipCode.EntryValidation.Rule            = _entryBoxSelectCustomerCountry.Value.RegExZipCode;
                    //Clear Customer Fields, Except Country
                    ClearCustomer(false);
                    //Apply Criteria Operators
                    ApplyCriteriaToCustomerInputs();
                    //Call Main Validate
                    Validate();
                };

                //FiscalNumber
                CriteriaOperator criteriaOperatorFiscalNumber = null;
                _entryBoxSelectCustomerFiscalNumber = new XPOEntryBoxSelectRecordValidation <ERP_Customer, TreeViewCustomer>(_sourceWindow, Resx.global_fiscal_number, "FiscalNumber", "FiscalNumber", null, criteriaOperatorFiscalNumber, KeyboardMode.AlfaNumeric, _intialValueConfigurationCountry.RegExFiscalNumber, false);
                _entryBoxSelectCustomerFiscalNumber.EntryValidation.Changed += _entryBoxSelectCustomerFiscalNumber_Changed;

                //CardNumber
                CriteriaOperator criteriaOperatorCardNumber = null;//Now Criteria is assigned in ApplyCriteriaToCustomerInputs();
                _entryBoxSelectCustomerCardNumber             = new XPOEntryBoxSelectRecordValidation <ERP_Customer, TreeViewCustomer>(_sourceWindow, Resx.global_card_number, "CardNumber", "CardNumber", null, criteriaOperatorCardNumber, KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, false);
                _entryBoxSelectCustomerCardNumber.ClosePopup += delegate
                {
                    if (_entryBoxSelectCustomerCardNumber.EntryValidation.Validated)
                    {
                        GetCustomerDetails("CardNumber", _entryBoxSelectCustomerCardNumber.EntryValidation.Text);
                    }
                    Validate();
                };

                //Notes
                _entryBoxCustomerNotes = new EntryBoxValidation(this, Resx.global_notes, KeyboardMode.Alfa, SettingsApp.RegexAlfaNumericExtended, false);
                _entryBoxCustomerNotes.EntryValidation.Changed += delegate { Validate(); };

                //Fill Dialog Inputs with Defaults FinalConsumerEntity Values
                if (_processFinanceDocumentParameter == null)
                {
                    //If ProcessFinanceDocumentParameter is not null fill Dialog with value from ProcessFinanceDocumentParameter, implemented for SplitPayments
                    GetCustomerDetails("Oid", SettingsApp.XpoOidDocumentFinanceMasterFinalConsumerEntity.ToString());
                }
                //Fill Dialog Inputs with Stored Values, ex when we Work with SplitPayments
                else
                {
                    //Apply Default Customer Entity
                    GetCustomerDetails("Oid", _processFinanceDocumentParameter.Customer.ToString());

                    //Assign Totasl and Discounts Values
                    _totalDelivery  = _processFinanceDocumentParameter.TotalDelivery;
                    _totalChange    = _processFinanceDocumentParameter.TotalChange;
                    _discountGlobal = _processFinanceDocumentParameter.ArticleBag.DiscountGlobal;
                    // Update Visual Components
                    _labelDeliveryValue.Text = FrameworkUtils.DecimalToStringCurrency(_totalDelivery);
                    _labelChangeValue.Text   = FrameworkUtils.DecimalToStringCurrency(_totalChange);
                    // Selects
                    _selectedCustomer = (ERP_Customer)FrameworkUtils.GetXPGuidObject(typeof(ERP_Customer), _processFinanceDocumentParameter.Customer);
                    _selectedCountry  = _selectedCustomer.Country;
                    // PaymentMethod
                    _selectedPaymentMethod = (FIN_ConfigurationPaymentMethod)FrameworkUtils.GetXPGuidObject(typeof(FIN_ConfigurationPaymentMethod), _processFinanceDocumentParameter.PaymentMethod);
                    // Restore Selected Payment Method, require to associate button reference to selectedPaymentMethodButton
                    if (!string.IsNullOrEmpty(pSelectedPaymentMethodButtonName))
                    {
                        switch (pSelectedPaymentMethodButtonName)
                        {
                        case "touchButtonMoney_Green":
                            _selectedPaymentMethodButton = buttonMoney;
                            break;

                        case "touchButtonCheck_Green":
                            _selectedPaymentMethodButton = buttonCheck;
                            break;

                        case "touchButtonMB_Green":
                            _selectedPaymentMethodButton = buttonMB;
                            break;

                        case "touchButtonCreditCard_Green":
                            _selectedPaymentMethodButton = buttonCreditCard;
                            break;

                        case "touchButtonVisa_Green":
                            _selectedPaymentMethodButton = buttonVisa;
                            break;

                        case "touchButtonCurrentAccount_Green":
                            _selectedPaymentMethodButton = buttonCurrentAccount;
                            break;

                        case "touchButtonCustomerCard_Green":
                            _selectedPaymentMethodButton = buttonCustomerCard;
                            break;
                        }

                        //Assign Payment Method after have Reference
                        AssignPaymentMethod(_selectedPaymentMethodButton);
                    }

                    //UpdateChangeValue, if we add/remove Splits we must recalculate ChangeValue
                    UpdateChangeValue();
                }

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                //Pack Content

                HBox hboxPaymenstAndTotals = new HBox(false, 0);
                hboxPaymenstAndTotals.PackStart(tablePayments, true, true, 0);
                hboxPaymenstAndTotals.PackStart(eventboxTotalPannel, true, true, 0);

                HBox hboxCustomerNameAndCustomerDiscount = new HBox(true, 0);
                hboxCustomerNameAndCustomerDiscount.PackStart(_entryBoxSelectCustomerName, true, true, 0);
                hboxCustomerNameAndCustomerDiscount.PackStart(_entryBoxCustomerDiscount, true, true, 0);

                HBox hboxFiscalNumberAndCardNumber = new HBox(true, 0);
                hboxFiscalNumberAndCardNumber.PackStart(_entryBoxSelectCustomerFiscalNumber, true, true, 0);
                hboxFiscalNumberAndCardNumber.PackStart(_entryBoxSelectCustomerCardNumber, true, true, 0);

                HBox hboxZipCodeCityAndCountry = new HBox(false, 0);
                hboxZipCodeCityAndCountry.PackStart(_entryBoxCustomerZipCode, false, false, 0);
                hboxZipCodeCityAndCountry.PackStart(_entryBoxCustomerCity, false, false, 0);
                hboxZipCodeCityAndCountry.PackStart(_entryBoxSelectCustomerCountry, true, true, 0);

                VBox vboxContent = new VBox(false, 0);
                vboxContent.PackStart(hboxPaymenstAndTotals, true, true, 0);
                vboxContent.PackStart(hboxFiscalNumberAndCardNumber, true, true, 0);
                vboxContent.PackStart(hboxCustomerNameAndCustomerDiscount, true, true, 0);
                vboxContent.PackStart(_entryBoxCustomerAddress, true, true, 0);
                vboxContent.PackStart(_entryBoxCustomerLocality, true, true, 0);
                vboxContent.PackStart(hboxZipCodeCityAndCountry, true, true, 0);
                vboxContent.PackStart(_entryBoxCustomerNotes, true, true, 0);

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                //ActionArea Buttons
                _buttonOk             = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok);
                _buttonCancel         = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel);
                _buttonClearCustomer  = ActionAreaButton.FactoryGetDialogButtonType("touchButtonClearCustomer_DialogActionArea", Resx.global_button_label_payment_dialog_clear_client, fileIconClearCustomer);
                _buttonFullPayment    = ActionAreaButton.FactoryGetDialogButtonType("touchButtonFullPayment_DialogActionArea", Resx.global_button_label_payment_dialog_full_payment, fileIconFullPayment);
                _buttonPartialPayment = ActionAreaButton.FactoryGetDialogButtonType("touchButtonPartialPayment_DialogActionArea", Resx.global_button_label_payment_dialog_partial_payment, fileIconPartialPayment);
                // Enable if has selectedPaymentMethod defined, ex when working with SplitPayments
                _buttonOk.Sensitive          = (_selectedPaymentMethod != null);
                _buttonFullPayment.Sensitive = false;

                //ActionArea
                ActionAreaButtons actionAreaButtons = new ActionAreaButtons();
                actionAreaButtons.Add(new ActionAreaButton(_buttonClearCustomer, _responseTypeClearCustomer));
                if (enablePartialPaymentButtons)
                {
                    actionAreaButtons.Add(new ActionAreaButton(_buttonFullPayment, _responseTypeFullPayment));
                    actionAreaButtons.Add(new ActionAreaButton(_buttonPartialPayment, _responseTypePartialPayment));
                }

                actionAreaButtons.Add(new ActionAreaButton(_buttonOk, ResponseType.Ok));
                actionAreaButtons.Add(new ActionAreaButton(_buttonCancel, ResponseType.Cancel));

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                //Init Object
                this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, vboxContent, actionAreaButtons);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }