Exemple #1
0
        // Prevent Dialog Destroy, Validate Count Records, we must override OnResponse to prevent Close Dialog
        protected override void OnResponse(ResponseType pResponse)
        {
            if (pResponse == ResponseType.Ok)
            {
                // Test Query for Records
                int    count         = 0;
                string countQuerySql = string.Empty;

                try
                {
                    countQuerySql = string.Format("SELECT COUNT(*) AS Count FROM {0} WHERE {1};", _databaseSourceObject, _filterValue);
                    DataTable dataTable = FrameworkUtils.GetDataTableFromQuery(countQuerySql);
                    count = Convert.ToInt32(Convert.ToDecimal(dataTable.Rows[0].ItemArray[0]));
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    _log.Error(string.Format("Error in countQuerySql: [{0}]", countQuerySql));
                }

                if (count <= 0)
                {
                    Utils.ShowMessageTouch(this, DialogFlags.Modal, new Size(500, 240), MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.dialog_message_report_filter_no_records_with_criteria);
                    //Keep Running
                    this.Run();
                }
                else
                {
                    // Dont Leave Dangling Dialog Arroung
                    this.Destroy();
                }
            }
        }
Exemple #2
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //WayBill

        /// <summary>
        /// Get Document <Line>s
        ///     Linhas do Documento(Line)
        /// </summary>
        /// <param name="DocumentMaster"></param>
        /// <returns></returns>
        public static string GetDocumentWayBillContentLines(FIN_DocumentFinanceMaster pDocumentMaster)
        {
            //Init Locals Vars
            string result = string.Empty;

            try
            {
                string sql = string.Format(@"
                    SELECT 
	                    Designation AS ProductDescription, Quantity, UnitMeasure AS UnitOfMeasure, Price AS UnitPrice,
	                    (SELECT rf.OriginatingON FROM fin_documentfinancedetailorderreference AS rf WHERE rf.DocumentDetail = fd.Oid) AS OrderReferences
                    FROM 
	                    fin_documentfinancedetail AS fd 
                    WHERE 
	                    DocumentMaster = '{0}' 
                    ORDER BY 
	                    Ord
                    ;"
                                           , pDocumentMaster.Oid
                                           );

                DataTable dtResult = FrameworkUtils.GetDataTableFromQuery(sql);

                //Init StringBuilder
                StringBuilder sb = new StringBuilder();

                foreach (DataRow item in dtResult.Rows)
                {
                    string orderReferences = (!string.IsNullOrEmpty(item["OrderReferences"].ToString()))
                        ? string.Format(@"{0}      <OrderReferences>
        <OriginatingON>{1}</OriginatingON>
      </OrderReferences>", Environment.NewLine, item["OrderReferences"])
                        : string.Empty
                    ;

                    sb.Append(string.Format(@"    <Line>{0}
      <ProductDescription>{1}</ProductDescription>
      <Quantity>{2}</Quantity>
      <UnitOfMeasure>{3}</UnitOfMeasure>
      <UnitPrice>{4}</UnitPrice>
    </Line>
"
                                            , orderReferences
                                            , item["ProductDescription"]
                                            , FrameworkUtils.DecimalToString(Convert.ToDecimal(item["Quantity"]), GlobalFramework.CurrentCultureNumberFormat)
                                            , item["UnitOfMeasure"]
                                            , FrameworkUtils.DecimalToString(Convert.ToDecimal(item["UnitPrice"]), GlobalFramework.CurrentCultureNumberFormat)
                                            ));
                }

                result = sb.ToString();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }
Exemple #3
0
        private DataTable GetDataTable(List <GenericTreeViewColumnProperty> pColumnProperties)
        {
            //Init Local Vars
            string    sql             = @"
                SELECT 
                    Oid,Code,Designation,HardwareId
                FROM 
                    pos_configurationplaceterminal 
                WHERE 
                    (Disabled IS NULL OR Disabled  <> 1)
                ORDER BY 
                    Ord;
            ";
            DataTable resultDataTable = FrameworkUtils.GetDataTableFromQuery(sql);

            return(resultDataTable);
        }
Exemple #4
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Helper Functions

        private static DataTable getStaticData()
        {
            //Select without licence fields COMPANY_* added above
            string    sql             = @"
                SELECT 
                    Token as token, Value as value 
                FROM 
                    cfg_configurationpreferenceparameter 
                WHERE 
                    Token = 'COMPANY_POSTALCODE' OR
                    Token = 'COMPANY_CITY' OR
                    Token = 'COMPANY_FAX'
                ORDER BY
                    Ord
            ";
            DataTable resultDataTable = FrameworkUtils.GetDataTableFromQuery(sql);

            resultDataTable.Columns[0].ColumnName = "token";
            resultDataTable.Columns[0].Unique     = true;
            resultDataTable.PrimaryKey            = new DataColumn[] { resultDataTable.Columns["token"] };

            //Add extra data to dataCompany DataTable
            //license
            resultDataTable.Rows.Add("COMPANY_NAME", GlobalFramework.LicenceCompany);
            resultDataTable.Rows.Add("COMPANY_FISCALNUMBER", GlobalFramework.LicenceNif);
            resultDataTable.Rows.Add("COMPANY_ADDRESS", GlobalFramework.LicenceAddress);
            resultDataTable.Rows.Add("COMPANY_TELEPHONE", GlobalFramework.LicenceTelephone);
            resultDataTable.Rows.Add("COMPANY_EMAIL", GlobalFramework.LicenceEmail);
            //User/Terminal
            resultDataTable.Rows.Add("TERMINAL_NAME", GlobalFramework.LoggedTerminal.Designation);
            resultDataTable.Rows.Add("TERMINAL_USERNAME", GlobalFramework.LoggedUser.Name);
            //Footer Lines : Deprecated
            //resultDataTable.Rows.Add("FOOTER_LINE1", SettingsApp.TicketFooterLine1);
            //resultDataTable.Rows.Add("FOOTER_LINE2", SettingsApp.TicketFooterLine2);
            //resultDataTable.Rows.Add("FOOTER_LINE3", SettingsApp.TicketFooterLine3);
            //resultDataTable.Rows.Add("FOOTER_LINE4", SettingsApp.TicketFooterLine4);
            //resultDataTable.Rows.Add("FOOTER_LINE5", SettingsApp.TicketFooterLine5);
            //resultDataTable.Rows.Add("FOOTER_LINE6", SettingsApp.TicketFooterLine6);
            //resultDataTable.Rows.Add("FOOTER_LINE7", SettingsApp.TicketFooterLine7);
            //resultDataTable.Rows.Add("FOOTER_LINE8", SettingsApp.TicketFooterLine8);

            return(resultDataTable);
        }
Exemple #5
0
        // Prevent Dialog Destroy, Validate Count Records, we must override OnResponse to prevent Close Dialog
        protected override void OnResponse(ResponseType pResponse)
        {
            //add responseType Export to Excel
            if (pResponse == ResponseType.Ok || pResponse == (ResponseType)DialogResponseType.ExportXls || pResponse == (ResponseType)DialogResponseType.ExportPdf)
            {
                // Test Query for Records
                int    count         = 0;
                string countQuerySql = string.Empty;
                if (pResponse == ResponseType.Ok)
                {
                    PosReportsDialog.exportType = CustomReportDisplayMode.ExportPDF;
                }

                try
                {
                    countQuerySql = string.Format("SELECT COUNT(*) AS Count FROM {0} WHERE {1};", _databaseSourceObject, _filterValue);
                    DataTable dataTable = FrameworkUtils.GetDataTableFromQuery(countQuerySql);
                    count = Convert.ToInt32(Convert.ToDecimal(dataTable.Rows[0].ItemArray[0]));
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    _log.Error(string.Format("Error in countQuerySql: [{0}]", countQuerySql));
                }

                if (count <= 0)
                {
                    /* IN009062 */
                    Utils.ShowMessageTouch(this, DialogFlags.Modal, new Size(500, 240), MessageType.Info, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_information"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_report_filter_no_records_with_criteria"));
                    //Keep Running
                    this.Run();
                }
                else
                {
                    // Dont Leave Dangling Dialog Arroung
                    this.Destroy();
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Get Document <Line>s Splitted by Tax and <DocumentTotals> Content
        ///     Linhas do Documento por Taxa (Line)
        ///     Resumo das linhas da fatura por taxa de imposto, e motivo de isenção ou não liquidação.
        ///     Deve existir uma, e uma só linha, por cada taxa (TaxType, TaxCountryRegion, TaxCode) e motivo de isenção ou não liquidação (TaxExemptionReason)
        /// </summary>
        /// <param name="DocumentMaster"></param>
        /// <returns></returns>
        public static string GetDocumentContentLinesAndDocumentTotals(FIN_DocumentFinanceMaster pDocumentMaster)
        {
            //Init Locals Vars
            string  result     = string.Empty;
            decimal taxPayable = 0.0m;
            decimal netTotal   = 0.0m;
            decimal grossTotal = 0.0m;
            //Prepare Node Name
            string nodeName = (pDocumentMaster.DocumentType.Credit) ? "CreditAmount" : "DebitAmount";

            try
            {
                string sql = string.Format(@"
                    SELECT 
	                    fdVat AS Vat,
	                    cvTaxType AS TaxType,
	                    cvTaxCode AS TaxCode,
	                    cvTaxCountryRegion AS TaxCountryRegion,
	                    SUM(fdTotalNet) AS TotalNet,
	                    SUM(fdTotalGross) AS TotalGross,
                        SUM(fdTotalDiscount) AS TotalDiscount,
	                    SUM(fdTotalTax) AS TotalTax,
	                    SUM(fdTotalFinal) AS TotalFinal,
	                    cxAcronym AS VatExemptionReasonAcronym
                    FROM
	                    view_documentfinance
                    WHERE 
	                    fmOid = '{0}'
                    GROUP BY
	                    fdVat,cvTaxType,cvTaxCode,cvTaxCountryRegion,cxAcronym
                    ORDER BY
	                    fdVat, VatExemptionReasonAcronym
                    ;"
                                           , pDocumentMaster.Oid
                                           );

                DataTable dtResult = FrameworkUtils.GetDataTableFromQuery(sql);

                //Init StringBuilder
                StringBuilder sb = new StringBuilder();

                foreach (DataRow item in dtResult.Rows)
                {
                    string taxExemptionReason = (!string.IsNullOrEmpty(item["VatExemptionReasonAcronym"].ToString()))
                        ? string.Format("{0}      <ns2:TaxExemptionReason>{1}</ns2:TaxExemptionReason>", Environment.NewLine, item["VatExemptionReasonAcronym"])
                        : string.Empty
                    ;

                    sb.Append(string.Format(@"    <Line>
      <ns2:{0}>{1}</ns2:{0}>
      <ns2:Tax>
        <ns2:TaxType>{2}</ns2:TaxType>
        <ns2:TaxCountryRegion>{3}</ns2:TaxCountryRegion>
        <ns2:TaxPercentage>{4}</ns2:TaxPercentage>
      </ns2:Tax>{5}
    </Line>
"
                                            , nodeName
                                            , FrameworkUtils.DecimalToString(Convert.ToDecimal(item["TotalNet"]), GlobalFramework.CurrentCultureNumberFormat)
                                            , item["TaxType"]
                                            , item["TaxCountryRegion"]
                                            , FrameworkUtils.DecimalToString(Convert.ToDecimal(item["Vat"]), GlobalFramework.CurrentCultureNumberFormat)
                                            , taxExemptionReason
                                            ));

                    //Sum DocumentTotals
                    taxPayable += Convert.ToDecimal(item["TotalTax"]);
                    netTotal   += Convert.ToDecimal(item["TotalNet"]);
                    //Is TotalFinal not db TotalGross
                    grossTotal += Convert.ToDecimal(item["TotalFinal"]);
                }

                //Add DocumentTotals
                sb.Append(string.Format(@"    <DocumentTotals>
      <ns2:TaxPayable>{0}</ns2:TaxPayable>
      <ns2:NetTotal>{1}</ns2:NetTotal>
      <ns2:GrossTotal>{2}</ns2:GrossTotal>
    </DocumentTotals>"
                                        , FrameworkUtils.DecimalToString(taxPayable, GlobalFramework.CurrentCultureNumberFormat)
                                        , FrameworkUtils.DecimalToString(netTotal, GlobalFramework.CurrentCultureNumberFormat)
                                        , FrameworkUtils.DecimalToString(grossTotal, GlobalFramework.CurrentCultureNumberFormat)
                                        ));

                result = sb.ToString();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }
Exemple #7
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //WayBill

        /// <summary>
        /// Get Document <Line>s
        ///     Linhas do Documento(Line)
        /// </summary>
        /// <param name="DocumentMaster"></param>
        /// <returns></returns>
        public static string GetDocumentWayBillContentLines(fin_documentfinancemaster pDocumentMaster)
        {
            /* IN007016 - escaping the following list of chars using "System.Security.SecurityElement.Escape()" method:
             *
             *      "   &quot;
             *      '   &apos;
             *      <   &lt;
             *      >   &gt;
             *      &   &amp;
             */
            _log.Debug($"string GetDocumentWayBillContentLines(fin_documentfinancemaster pDocumentMaster) :: {pDocumentMaster.DocumentNumber}");

            //Init Locals Vars
            string result = string.Empty;

            try
            {
                string sql = string.Format(@"
                    SELECT 
	                    Designation AS ProductDescription, Quantity, UnitMeasure AS UnitOfMeasure, Price AS UnitPrice,
	                    (SELECT rf.OriginatingON FROM fin_documentfinancedetailorderreference AS rf WHERE rf.DocumentDetail = fd.Oid) AS OrderReferences
                    FROM 
	                    fin_documentfinancedetail AS fd 
                    WHERE 
	                    DocumentMaster = '{0}' 
                    ORDER BY 
	                    Ord
                    ;"
                                           , pDocumentMaster.Oid
                                           );

                DataTable dtResult = FrameworkUtils.GetDataTableFromQuery(sql);

                //Init StringBuilder
                StringBuilder sb = new StringBuilder();

                foreach (DataRow item in dtResult.Rows)
                {
                    string orderReferences = (!string.IsNullOrEmpty(item["OrderReferences"].ToString()))
                        ? string.Format(@"{0}      <OrderReferences>
        <OriginatingON>{1}</OriginatingON>
      </OrderReferences>", Environment.NewLine, item["OrderReferences"])
                        : string.Empty
                    ;

                    sb.Append(string.Format(@"    <Line>{0}
      <ProductDescription>{1}</ProductDescription>
      <Quantity>{2}</Quantity>
      <UnitOfMeasure>{3}</UnitOfMeasure>
      <UnitPrice>{4}</UnitPrice>
    </Line>
"
                                            , orderReferences
                                            , SecurityElement.Escape(item["ProductDescription"].ToString())
                                            , FrameworkUtils.DecimalToString(Convert.ToDecimal(item["Quantity"]), GlobalFramework.CurrentCultureNumberFormat)
                                            , item["UnitOfMeasure"]
                                            , FrameworkUtils.DecimalToString(Convert.ToDecimal(item["UnitPrice"]), GlobalFramework.CurrentCultureNumberFormat)
                                            ));
                }

                result = sb.ToString();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }