public static bool PrintFinanceDocument(Window pSourceWindow, SYS_ConfigurationPrinters pPrinter, FIN_DocumentFinanceMaster pDocumentFinanceMaster) { bool result = false; bool openDrawer = false; PosDocumentFinancePrintDialog.PrintDialogResponse response; if (!LicenceManagement.IsLicensed || !LicenceManagement.CanPrint) { Utils.ShowMessageTouchErrorUnlicencedFunctionDisabled(pSourceWindow, Resx.global_printing_function_disabled); return(false); } //Both printer can be the same, if not Defined in DocumentType //Printer for Drawer and Document, if not defined in DocumentType SYS_ConfigurationPrinters printer = (pPrinter != null) ? pPrinter : GlobalFramework.LoggedTerminal.Printer; //Printer for Document : Override default Printer is DocumentType has a Printer Defined SYS_ConfigurationPrinters printerDoc = (pDocumentFinanceMaster.DocumentType.Printer != null) ? pDocumentFinanceMaster.DocumentType.Printer : printer; try { //Overload Management if (printerDoc == null) { //Notification : Show Message TouchTerminalWithoutAssociatedPrinter and Store user input, to Show Next Time(Yes) or Not (No) if (printerDoc == null) { Utils.ShowMessageTouchTerminalWithoutAssociatedPrinter(pSourceWindow, Resx.ResourceManager.GetString(pDocumentFinanceMaster.DocumentType.ResourceString)); } else { response = PosDocumentFinancePrintDialog.GetDocumentFinancePrintProperties(pSourceWindow, pDocumentFinanceMaster); //Print with default DocumentFinanceYearSerieTerminal Template if (response.Response == ResponseType.Ok) { result = PrintRouter.PrintFinanceDocument(pDocumentFinanceMaster); } } } else { bool validFiles = true; string extraMessage = string.Format(Resx.dialog_message_error_protected_files_invalid_files_detected_print_document_ignored, pDocumentFinanceMaster.DocumentNumber); //Printer Drawer : Set openDrawer switch (PrintRouter.GetPrinterToken(printer.PrinterType.Token)) { //ThermalPrinter : Ticket Files case "THERMAL_PRINTER_WINDOWS": case "THERMAL_PRINTER_LINUX": case "THERMAL_PRINTER_SOCKET": case "THERMAL_PRINTER_USB": openDrawer = true; break; } //Printer Document : Set Valid Files switch (PrintRouter.GetPrinterToken(printerDoc.PrinterType.Token)) { //ThermalPrinter : Ticket Files case "THERMAL_PRINTER_WINDOWS": case "THERMAL_PRINTER_LINUX": case "THERMAL_PRINTER_SOCKET": case "THERMAL_PRINTER_USB": //validFiles = IsValidProtectedFile(FrameworkUtils.OSSlash(template.FileTemplate), extraMessage); break; //FastReport : Report Files case "GENERIC_PRINTER_WINDOWS": case "REPORT_EXPORT_PDF": //Required both Template Files ReportDocumentFinance and ReportDocumentFinanceWayBill //validFiles = ( // IsValidProtectedFile(FrameworkUtils.OSSlash(@"Resources/Reports/UserReports/ReportDocumentFinance.frx"), extraMessage) && // IsValidProtectedFile(FrameworkUtils.OSSlash(@"Resources/Reports/UserReports/ReportDocumentFinanceWayBill.frx"), extraMessage) //); break; case "VIRTUAL_SCREEN": break; } //ProtectedFiles Protection if (!validFiles) { return(false); } //Call Print Document : Receives ResponseType.Ok without user Confirmation, if Document was never Printer response = PosDocumentFinancePrintDialog.GetDocumentFinancePrintProperties(pSourceWindow, pDocumentFinanceMaster); //Print with Parameters Printer and Template if (response.Response == ResponseType.Ok) { //Print Document use Printer Document result = PrintRouter.PrintFinanceDocument(printerDoc, pDocumentFinanceMaster, response.CopyNames, response.SecondCopy, response.Motive); //OpenDoor use Printer Drawer if (openDrawer && pDocumentFinanceMaster.DocumentType.PrintOpenDrawer && !response.SecondCopy) { PrintRouter.OpenDoor(printer); } } } } catch (Exception ex) { Utils.ShowMessageTouchErrorPrintingTicket(pSourceWindow, printer, ex); } return(result); }
public static PrintDialogResponse GetDocumentFinancePrintProperties(Window pSourceWindow, FIN_DocumentFinanceMaster pDocumentFinanceMaster) { //Log4Net log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //Init Response PrintDialogResponse result = new PrintDialogResponse(ResponseType.Cancel); try { //TODO: Xpo Required to use ExecuteScalar, else we dont have real value but a cached value //Get Fresh Object to get Printed Status //DocumentFinanceMaster documentFinanceMaster = (DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(DocumentFinanceMaster), pDocumentFinanceMaster.Oid); //bool printed = documentFinanceMaster.Printed; //Fix Cache Problem var sqlResPrinted = GlobalFramework.SessionXpo.ExecuteScalar(string.Format( "SELECT Printed FROM fin_documentfinancemaster WHERE Oid = '{0}';", pDocumentFinanceMaster.Oid) ); bool printed = (sqlResPrinted != null) ? Convert.ToBoolean(sqlResPrinted) : false; //Call Re-Print Dialog if (printed) { PosDocumentFinancePrintDialog dialog = new PosDocumentFinancePrintDialog(pSourceWindow, DialogFlags.DestroyWithParent, pDocumentFinanceMaster); result.Response = (ResponseType)dialog.Run(); if (result.Response == ResponseType.Ok) { //Modify Result with Dialog Properties result.Items = dialog._checkButtonCopyNamesBoxGroup.Items; //Generate CopyNames from CheckButtonCopyNamesBoxGroup.Items result.CopyNames = new List <int>(); foreach (var item in dialog._checkButtonCopyNamesBoxGroup.Items) { result.CopyNames.Add(item.Key); } result.SecondCopy = dialog._secondCopy; if (dialog._entryBoxValidationBoxMotive != null) { result.Motive = dialog._entryBoxValidationBoxMotive.EntryValidation.Text; } } dialog.Destroy(); } //Normal Print Without Dialog else { //Modify Result result.Response = ResponseType.Ok; //Initialize CopyNames List from PrintCopies result.CopyNames = CustomReport.CopyNames(pDocumentFinanceMaster.DocumentType.PrintCopies); } } catch (Exception ex) { log.Error(ex.Message, ex); } return(result); }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //PrintFinanceDocument public static bool PrintFinanceDocument(Window pSourceWindow, FIN_DocumentFinanceMaster pDocumentFinanceMaster) { return(PrintFinanceDocument(pSourceWindow, null, pDocumentFinanceMaster)); }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //ProcessFinanceDocument //Use: DocumentFinanceMaster resultDocument = FrameworkCalls.ProcessFinanceDocument(SourceWindow, processFinanceDocumentParameter); public static FIN_DocumentFinanceMaster PersistFinanceDocument(Window pSourceWindow, ProcessFinanceDocumentParameter pProcessFinanceDocumentParameter) { bool printDocument = true; FIN_DocumentFinanceMaster result = null; try { //Protection to Check if SystemDate is < Last DocumentDate ResponseType responseType = Utils.ShowMessageTouchCheckIfFinanceDocumentHasValidDocumentDate(pSourceWindow, pProcessFinanceDocumentParameter); if (responseType != ResponseType.Yes) { return(result); } FIN_DocumentFinanceMaster documentFinanceMaster = ProcessFinanceDocument.PersistFinanceDocument(pProcessFinanceDocumentParameter, true); if (documentFinanceMaster != null) { //ATWS : SendDocumentToATWSDialog if (SendDocumentToATWSEnabled(documentFinanceMaster)) { SendDocumentToATWSDialog(pSourceWindow, documentFinanceMaster); } //Always Send back the Valid Document result = documentFinanceMaster; if (documentFinanceMaster.DocumentType.PrintRequestConfirmation) { responseType = Utils.ShowMessageTouch( pSourceWindow, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Resx.window_title_dialog_document_finance, Resx.dialog_message_request_print_document_confirmation ); if (responseType == ResponseType.No) { printDocument = false; } } //Print Document if (printDocument) { PrintFinanceDocument(pSourceWindow, documentFinanceMaster); } } } catch (Exception ex) { string errorMessage = string.Empty; switch (ex.Message) { case "ERROR_MISSING_SERIE": errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_missing_series); break; case "ERROR_INVALID_DOCUMENT_NUMBER": errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_invalid_documentnumber); break; case "ERROR_COMMIT_FINANCE_DOCUMENT": errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_commit_session); break; //TODO: NEW CLASS FinanceDocumentValidate : IMPLEMENT HERE THE RESULT EXCEPTION FOR VALIDATE_SIMPLIFIED_INVOICE default: errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, ex.Message); break; } Utils.ShowMessageTouch( pSourceWindow, DialogFlags.Modal, _sizeDefaultWindowSize, MessageType.Error, ButtonsType.Close, Resx.global_error, errorMessage ); } return(result); }
public static bool PersistWorkSessionMovement(Session pSession, POS_WorkSessionPeriod pWorkSessionPeriod, POS_WorkSessionMovementType pWorkSessionMovementType, FIN_DocumentFinanceMaster pDocumentFinanceMaster, FIN_DocumentFinancePayment pDocumentFinancePayment, SYS_UserDetail pUserDetail, POS_ConfigurationPlaceTerminal pTerminal, DateTime pDate, decimal pMovementAmount, string pDescription, uint pOrd = 1) { //Prevent Deleted Objects, Get Fresh Objects SYS_UserDetail userDetail = pSession.GetObjectByKey <SYS_UserDetail>(GlobalFramework.LoggedUser.Oid); POS_ConfigurationPlaceTerminal terminal = pSession.GetObjectByKey <POS_ConfigurationPlaceTerminal>(GlobalFramework.LoggedTerminal.Oid); POS_WorkSessionMovementType workSessionMovementType = pSession.GetObjectByKey <POS_WorkSessionMovementType>(pWorkSessionMovementType.Oid); try { POS_WorkSessionMovement workSessionMovement = new POS_WorkSessionMovement(pSession) { Ord = pOrd, WorkSessionPeriod = pWorkSessionPeriod, WorkSessionMovementType = workSessionMovementType, UserDetail = userDetail, Terminal = terminal, Date = pDate, MovementAmount = pMovementAmount, Description = pDescription }; //Assign parent DocumentFinanceMaster and PaymentMethod if (pDocumentFinanceMaster != null) { workSessionMovement.DocumentFinanceMaster = pDocumentFinanceMaster; workSessionMovement.DocumentFinanceType = pDocumentFinanceMaster.DocumentType; workSessionMovement.PaymentMethod = pDocumentFinanceMaster.PaymentMethod; } //Assign parent DocumentFinancePayment and PaymentMethod if (pDocumentFinancePayment != null) { workSessionMovement.DocumentFinancePayment = pDocumentFinancePayment; workSessionMovement.DocumentFinanceType = pDocumentFinancePayment.DocumentType; workSessionMovement.PaymentMethod = pDocumentFinancePayment.PaymentMethod; } //Save WorkSessionMovement if not in UOW if (pSession.GetType() == typeof(Session)) { workSessionMovement.Save(); } return(true); } catch (Exception ex) { _log.Error(ex.Message, ex); return(false); } }
//Main Method - With and Without Session public static bool PersistWorkSessionMovement(POS_WorkSessionPeriod pWorkSessionPeriod, POS_WorkSessionMovementType pWorkSessionMovementType, FIN_DocumentFinanceMaster pDocumentFinanceMaster, FIN_DocumentFinancePayment pDocumentFinancePayment, SYS_UserDetail pUserDetail, POS_ConfigurationPlaceTerminal pTerminal, DateTime pDate, decimal pMovementAmount, string pDescription, uint pOrd = 1) { return(PersistWorkSessionMovement(GlobalFramework.SessionXpo, pWorkSessionPeriod, pWorkSessionMovementType, pDocumentFinanceMaster, pDocumentFinancePayment, pUserDetail, pTerminal, pDate, pMovementAmount, pDescription)); }
public DocumentReference(FIN_DocumentFinanceMaster pDocumentFinanceMaster, string pReason) { _reference = pDocumentFinanceMaster; _reason = pReason; }