protected override void PackRequest() { // Create the streams we will be writing to. var requestStream = new MemoryStream(); var requestWriter = new BinaryWriter(requestStream, Encoding.Unicode); // Package Id requestWriter.Write(PackageId); // Is ChargeDeviceFee requestWriter.Write(ChargeDeviceFee); // Package Name requestWriter.Write((ushort)PackageName.Length); requestWriter.Write(PackageName.ToCharArray()); // Receipt Text requestWriter.Write((ushort)ReceiptText.Length); requestWriter.Write(ReceiptText.ToCharArray()); //Override Validation requestWriter.Write(OverrideValidation); //Validation Quantity requestWriter.Write(ValidationQuantity); //Requires Validation to purchase requestWriter.Write(RequiresValidation); // Set the bytes to be sent. m_requestPayload = requestStream.ToArray(); // Close the streams. requestWriter.Close(); }
private void ReceiptLangComboBox_SelectedIndexChanged(object sender, EventArgs e) { try { if (!IsLoading) { if (ReceiptLangComboBox.SelectedText != null) { if (ConfigurationHelper.UpdateReceiptLanguage(ReceiptLangComboBox.Text)) { MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); string LangCheck; LangCheck = ConfigurationHelper.GetReceiptLanguage(); if (!LangCheck.Contains("ERROR")) { if (LangCheck.ToUpper() == "ARABIC") { string CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-JO"); Reports.ReportsHelper.ReceiptRTL = true; ReceiptName.TranslateReceiptText(); ReceiptText.TranslateReceiptText(); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(CurrentCulture); //TRANSLATE RECIEPT } else { string CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); Reports.ReportsHelper.ReceiptRTL = false; ReceiptName.TranslateReceiptText(); ReceiptText.TranslateReceiptText(); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(CurrentCulture); } } } else { MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private Task PrintNonfiscalText() { // instantiate string builder, to append string more efficiently. StringBuilder sb = new StringBuilder(); // plain text sb.AppendLine("Hello world!"); // text with formatting sb.Append(TextToken.Create("This line is bold.", TextFormats.Bold, TextAlignment.Center).ToString()); sb.AppendLine("After text token, newline is created automatically."); sb.Append(TextToken.Create("This line is underlined.", TextFormats.Underlined).ToString()); // "You can combine TextFormat values by using | operator sb.Append(TextToken.Create("This line is bold and underlined.", TextFormats.Underlined | TextFormats.Bold).ToString()); sb.AppendLine(TextToken.Create("Hello world!", TextFormats.DoubleHeight | TextFormats.DoubleWidth | TextFormats.Underlined | TextFormats.Inverted | TextFormats.Bold).ToString()); // Paper cut follows now. sb.Append(new PageBreakToken().ToString()); // We can print either barcodes or QR codes easily! sb.AppendLine(BarcodeToken.Create("1234567", BarcodeType.EAN8, BarcodeHriPosition.Above).ToString()); sb.AppendLine(BarcodeToken.Create("123456789012", BarcodeType.EAN13, BarcodeHriPosition.Below).ToString()); sb.AppendLine(BarcodeToken.Create("1234ABCD39", BarcodeType.Code39, BarcodeHriPosition.Both).ToString()); sb.AppendLine(BarcodeToken.Create("1234ABCD93", BarcodeType.Code93, height: 30).ToString()); sb.AppendLine(BarcodeToken.Create("1234567890", BarcodeType.Code128, elementWidth: 2).ToString()); sb.AppendLine(QrCodeToken.Create("https://www.ninedigit.sk").ToString()); string text = sb.ToString(); if (!ReceiptText.IsValid(text)) { throw new InvalidOperationException("We have used some forbidden characters in our text output!"); } ReceiptText receiptText = new ReceiptText(text); TextPrintContext context = new TextPrintContext(receiptText); return(this.client.PrintTextAsync(context, CancellationToken.None)); }
static void Main() { try { /* string resource = "Calcium_RMS.System.Windows.Forms.Ribbon35.dll"; * using (Stream stm = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) * { * byte[] ba = new byte[(int)stm.Length]; * stm.Read(ba, 0, (int)stm.Length); * ribbon = Assembly.Load(ba); * } * AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); */ Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { TestSqlService(); Helper.SetConnectionString(); if (!Helper.TestConnectionString()) { if (Helper.__ConnectionString == "ERROR:File Not Exist") { string Ret = MessageBox.Show("Cannot Connect To Database \n If This Is Your First Run For the Program Press Yes To Create New DataBase \n WARNING: if you already have a database click no to protect your database from being removed", "DATABASE", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2).ToString(); if (Ret == "Yes") { try { string ExecDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string DBEmpDir = @"\RMSV1.1EmptyDB"; File.Copy(ExecDir + DBEmpDir + @"\DB.mdf", ExecDir + @"\DataBase.mdf"); File.Copy(ExecDir + DBEmpDir + @"\DB_log.ldf", ExecDir + @"\DataBase_log.ldf"); string ConnStringnew = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + ExecDir + @"\Database.mdf;Integrated Security=True;User Instance=True"; ConfigurationHelper.UpdateConnString(ConnStringnew); MessageBox.Show("New DataBase Created Successfully, Application will restart now default logins \n Username : Admin \n Password: Admin \n note: username and password are not case sensitive", "Created succesfully", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Restart(); } catch (Exception ex) { MessageBox.Show("It seems you have a working database\nTo prevent your data loss the program will not continue\nFailed To Create New Database, Please Contact System Administrator \n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.ExitThread(); Application.Exit(); } } else { Application.ExitThread(); Application.Exit(); } } else { MessageBox.Show("Cannot Connect To Database Error In Connection String", "DataBase Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Run(new ConnStringFrm()); } } else { Application.Run(new SplashFrm()); //DateTime __StartTime = DateTime.Now; // Helper.SetConnectionString(); // Security.V1.ActivationCheck.TrialCheck(); string LangCheck; LangCheck = ConfigurationHelper.GetReceiptLanguage(); if (!LangCheck.Contains("ERROR")) { if (LangCheck.ToUpper() == "ARABIC") { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-JO"); Reports.ReportsHelper.ReceiptRTL = true; ReceiptName.TranslateReceiptText(); ReceiptText.TranslateReceiptText(); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); //TRANSLATE RECIEPT } else { Reports.ReportsHelper.ReceiptRTL = false; ReceiptName.TranslateReceiptText(); ReceiptText.TranslateReceiptText(); } } else { Reports.ReportsHelper.ReceiptRTL = false; ReceiptName.TranslateReceiptText(); ReceiptText.TranslateReceiptText(); } LangCheck = ConfigurationHelper.GetLanguage(); if (!LangCheck.Contains("ERROR")) { if (LangCheck.ToUpper() == "ARABIC") { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-JO"); } } UiText.TranslateUiText(); MsgTxt.TranslateMsgsTxt(); FormsNames.TranslateFormsNames(); //TimeSpan __TimeSpan = DateTime.Now.Subtract(__StartTime); //string __ET = string.Format("{0:00}.{1:00}.{2:00}:{3:000}", __TimeSpan.Hours, __TimeSpan.Minutes, __TimeSpan.Seconds, __TimeSpan.Milliseconds); //MessageBox.Show("ET=" + __ET); Application.Run(new login()); int x = 100; } } catch (Exception ex) { MessageBox.Show(ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } catch (Exception ex) { MessageBox.Show("Error message \n" + ex.ToString()); } }