Пример #1
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isConnected = false;
            int nCount = 0;

            // show Waiting
            using (var fsplash = new QWaitingWidget("Version " +
                Application.ProductVersion + "\r\n\r\n" +
                "Preparing application\r\nPlease wait!"))
            {
                fsplash.WindowState = FormWindowState.Maximized;
                fsplash.Show();
                fsplash.SetBigCircle();
                Application.DoEvents();

                // 5 phase before setting);
                while (!isConnected && nCount < 3)
                {
                    // connecting
                    isConnected = IsConnected(false);
                    nCount++;

                    if (!isConnected)
                    {
                        // set splash message
                        fsplash.SetMessage(
                            string.Format("Connection failed! Re-trying connecting to server\r\nPHASE {0}", nCount));
                        Application.DoEvents();

                        // delay
                        for (int i = 0; i <= 250; i++)
                        {
                            Thread.Sleep(10);
                            Application.DoEvents();
                        }
                    }
                    else
                    {
                        fsplash.SetMessage(string.Format("Connection successfully !"));
                        Application.DoEvents();
                        Thread.Sleep(250);
                    }
                }
            }

            // if still not connected, show db configuration
            if (!isConnected)
                using (var f = new DBLogonUI())
                    f.ShowDialog();
            else // in connected show main screen
                Application.Run(new MainScreen());
        }
Пример #2
0
        /// <summary>
        /// Prints the with CR layout.
        /// </summary>
        /// <param name="nomor">The nomor.</param>
        /// <param name="loket">The loket.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="sender">The sender.</param>
        public static void PrintWithCRLayout(string nomor, string loket, int copies, IWin32Window sender)
        {
            using (var f = new QWaitingWidget("Sedang proses mencetak, tunggu sejenak"))
            {
                // show PROGRESS
                f.Show(sender);
                Application.DoEvents();

                // load REPORT FILES
                var crDocument = new ReportDocument();
                crDocument.Load(Application.StartupPath + "/Reports/PrintNomor.Rpt");
                crDocument.DataDefinition.FormulaFields["nomor"].Text =
                    (char)34 + nomor + (char)34;
                crDocument.DataDefinition.FormulaFields["loket"].Text =
                    (char)34 + loket + (char)34;

                // get company profile
                var db = new CompanyBase();
                List<Company> companies = db.GetAll();
                db.Dispose();

                if (companies != null)
                {
                    crDocument.DataDefinition.FormulaFields["companyname"].Text =
                        (char)34 + companies[0].CompanyName + (char)34;
                    crDocument.DataDefinition.FormulaFields["phone"].Text =
                        (char)34 + companies[0].Phone + (char)34;
                    crDocument.DataDefinition.FormulaFields["email"].Text =
                        (char)34 + companies[0].Email + (char)34;
                }

                try
                {
                    // Get Default Printer Name
                    var pname = new StringBuilder(255);
                    int length = 255;
                    Printer.GetDefaultPrinter(pname, ref length);

                    // start PRINTING
                    crDocument.PrintOptions.PrinterName = pname.ToString().Trim();
                    crDocument.PrintToPrinter(copies, false, 1, 1);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, @"Error !",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Ts the locked.
 /// </summary>
 private void TLocked()
 {
     if (InvokeRequired)
     {
         var o = new DelegateThis(TLocked);
         Invoke(o);
     }
     else
     {
         using (var f = new QWaitingWidget("Maaf, layanan ini tidak aktif ! "))
         {
             f.Show(this);
             Application.DoEvents();
             Thread.Sleep(1000);
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Prints the with ESC.
        /// </summary>
        /// <param name="nomor">The nomor.</param>
        /// <param name="loket">The loket.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="sender">The sender.</param>
        public static void PrintWithESC(string nomor, string loket, int copies, IWin32Window sender)
        {
            using (var f = new QWaitingWidget("Sedang proses mencetak, silahkan tunggu !"))
            {
                f.Show(sender);
                Application.DoEvents();

                // get company profile
                var db = new CompanyBase();
                List<Company> companies = db.GetAll();
                db.Dispose();

                var pr = new StringBuilder();

                pr.Append(DirectPrint.InitializePrinter());
                pr.Append(DirectPrint.PrintCenterText() + "SELAMAT DATANG");

                if (companies != null && companies.Count > 0)
                {
                    pr.Append(DirectPrint.FeedPaper(1) +
                              DirectPrint.PrintCenterText() + companies[0].CompanyName);
                }

                pr.Append(DirectPrint.FeedPaper(1));
                pr.Append(DirectPrint.Bold(true));
                pr.Append(DirectPrint.Strong(Settings.Default.StrongSize));
                pr.Append(DirectPrint.FeedPaper(1) + DirectPrint.PrintCenterText() + nomor);
                pr.Append(DirectPrint.Strong(0));
                pr.Append(DirectPrint.Bold(false));
                pr.Append(DirectPrint.FeedPaper(1) + DirectPrint.PrintCenterText() + loket);
                pr.Append(DirectPrint.FeedPaper(2) +
                          DirectPrint.PrintCenterText() + DateTime.Now.ToString("dddd, dd-MM-yyyy"));
                pr.Append("  -  " + DateTime.Now.ToString("HH:mm:ss"));
                pr.Append(DirectPrint.FeedPaper(1) +
                          DirectPrint.PrintCenterText() + "SILAHKAN TUNGGU, TERIMA KASIH");

                pr.Append(DirectPrint.FeedPaper(8));

                if (Settings.Default.AutoCutter)
                {
                    pr.Append(DirectPrint.CutPaper());
                }

                try
                {
                    var pname = new StringBuilder(255);
                    int length = 255;

                    // get default printer name
                    Printer.GetDefaultPrinter(pname, ref length);

                    // loop print by copies
                    for (int i = 1; i <= copies; i++)
                        RawPrinterHelper.SendStringToPrinter(pname.ToString().Trim(), pr.ToString().Trim());

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, @"Error !",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }