예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string GS      = Convert.ToString((char)29);
            string ESC     = Convert.ToString((char)27);
            Random rno     = new Random();
            string receipt = rno.Next(0, 10000).ToString();
            string COMMAND = "";

            COMMAND  = ESC + "@";
            COMMAND += GS + "V" + (char)1;
            DateTime D = DateTime.Now;
            //  int i = 0;
            StringBuilder sb = new StringBuilder();

            sb.Append("_______________________________________________\n");
            sb.Append("           GREEN CAFE POS PRINTER TEST         \n");
            sb.Append("DATE      :" + D.ToString() + "                \n");
            sb.Append("SYSTEM    :  GREEN CARE CAFE POS               \n");
            sb.Append("ADDRESS   :  127.0.0.1                         \n");
            sb.Append("RECEIPTNO : " + receipt.ToString() + "         \n");
            sb.Append("DEVELOPER :FELIX K KIPRONO                     \n");
            sb.Append("_______________________________________________\n");
            // sb.Append("No     Name       Quantity      Price     Total\n");
            sb.Append("_______________________________________________\n");
            sb.Append("IF YOU HAVE SEEN THIS RECEIPT IT MEANS PRINTER IS WORKING\n");
            sb.Append("_______________________________________________\n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            string s = sb.ToString();
            // device-dependent string, need a FormFeed?
            //
            // Allow the user to select a printer.
            PrintDialog pd = new PrintDialog();

            pd.PrinterSettings = new PrinterSettings();
            // Send a printer-specific to the printer.
            RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s + COMMAND);
        }
예제 #2
0
        void PrintOrder()
        {
            try
            {
                //panel2.Visible = false;

                DataGridViewRow row = this.dataGridView1.SelectedRows[0];

                String on      = row.Cells[0].Value.ToString();
                String waiter1 = row.Cells[3].Value.ToString();
                String Query   = "UPDATE `orders` SET `Status`='Closed' WHERE  `OrderNumber`='" + on + "' ";
                HorsePower.ExecuteSQL(Query);
                LoadOrders();
                SaveSale(on, waiter1);
                panel2.Visible = false;
                string GS      = Convert.ToString((char)29);
                string ESC     = Convert.ToString((char)27);
                Random rno     = new Random();
                string receipt = rno.Next(0, 100).ToString();
                string COMMAND = "";
                COMMAND  = ESC + "@";
                COMMAND += GS + "V" + (char)1;
                DateTime D = DateTime.Now;
                //  int i = 0;
                StringBuilder sb = new StringBuilder();
                sb.Append("           DYKAAN HOTEL                       \n");
                sb.Append("KIAMBUU TWIGA BUILDING SECOND FLOOR           \n");
                sb.Append("P.O. Box                                      \n");

                //sb.Append("KIAMBUU                                      \n");
                // sb.Append("         BILLING RECEIPT                       \n");

                sb.Append("DATE      :" + D.ToString() + "                \n");
                sb.Append("TELL NO   : 0723156900                         \n");
                sb.Append("TILL NO   : 83359                              \n");
                sb.Append("ADDRESS   : 01000 - 152 THIKA                  \n");
                sb.Append("RECEIPTNO : " + receipt.ToString() + "         \n");
                // sb.Append("WAITER    : " + comboBox3.Text + "             \n");

                sb.Append("          CASH SALE RECEIPT                    \n");
                sb.Append("_______________________________________________\n");
                // sb.Append("No     Name       Quantity      Price     Total\n");
                sb.Append("_______________________________________________\n");
                sb.Append("               Customer Bill List              \n");
                sb.Append("_______________________________________________\n");
                int j = 0;
                for (int i = 0; i < dataGridView2.Rows.Count; i++)
                {
                    j = j + 1;
                    sb.Append(j.ToString() + "." + " " + dataGridView2.Rows[i].Cells[0].Value + "               " + dataGridView2.Rows[i].Cells[1].Value + " X   " + dataGridView2.Rows[i].Cells[2].Value + "      \n");
                }

                /*  for (int i = 0; i < dataGridView2.Rows.Count; i++)
                 * {
                 *    j = j + 1;
                 *    sb.Append("     " + dataGridView2.Rows[i].Cells[1].Value + " x       " + dataGridView2.Rows[i].Cells[2].Value + "  "+ dataGridView2.Rows[i].Cells[0].Value + "           \n");
                 * }*/
                sb.Append("______________________________________________ \n");
                sb.Append("Serverd By  : " + waiter.Text + "          \n");
                // sb.Append("Table Number : " + comboBox2.Text + "          \n");
                sb.Append("_______________________________________________\n");
                sb.Append("            Total Items  : " + dataGridView2.Rows.Count.ToString() + "\n");
                sb.Append("            Total Bill   : " + total.Text + "\n");
                //  sb.Append("            Paid Amount : " + paid.Text +     "\n");
                //  sb.Append("            Change      : " + change.Text +   "\n");
                sb.Append("            Mode         : Cash                 \n");
                sb.Append("_______________________________________________\n");
                sb.Append("   Come in as Guest Leave As Family            \n");
                sb.Append("                THANK YOU                      \n");

                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                sb.Append("                                               \n");
                string s = sb.ToString();
                // device-dependent string, need a FormFeed?
                //
                // Allow the user to select a printer.
                PrintDialog pd = new PrintDialog();
                pd.PrinterSettings = new PrinterSettings();
                // Send a printer-specific to the printer.
                RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s + COMMAND);
                total.Text  = "";
                paid.Text   = "";
                waiter.Text = "";
                change.Text = "";
            }
            catch (Exception ex)
            {
            }
        }
예제 #3
0
        private void button7_Click(object sender, EventArgs e)
        {
            //then print receipt
            string GS      = Convert.ToString((char)29);
            string ESC     = Convert.ToString((char)27);
            Random rno     = new Random();
            string receipt = rno.Next(0, 10000).ToString();
            string COMMAND = "";

            COMMAND  = ESC + "@";
            COMMAND += GS + "V" + (char)1;
            DateTime D = DateTime.Now;
            //  int i = 0;
            StringBuilder sb = new StringBuilder();

            sb.Append("           DYKAAN HOTEL                       \n");
            //sb.Append("KIAMBUU                                      \n");
            sb.Append("         BILLING RECEIPT                       \n");

            sb.Append("DATE      :" + D.ToString() + "                \n");
            sb.Append("TELL NO   :                                    \n");
            sb.Append("ADDRESS   : 386-30400                          \n");
            sb.Append("RECEIPTNO : " + receipt.ToString() + "         \n");
            sb.Append("WAITER    : " + comboBox3.Text + "             \n");

            sb.Append("           CUSTOMER BILL RECEIPT               \n");
            sb.Append("_______________________________________________\n");
            // sb.Append("No     Name       Quantity      Price     Total\n");
            sb.Append("_______________________________________________\n");
            sb.Append("          ITEMS LISTS                          \n");
            sb.Append("_______________________________________________\n");

            foreach (ListViewItem item in listView1.Items)
            {
                i = i + 1;
                sb.Append(i.ToString() + "." + "     " + item.SubItems[0].Text + "        " + item.SubItems[1].Text + " X   " + item.SubItems[2].Text + "       " + item.SubItems[3].Text + "\n");
            }
            sb.Append("_______________________________________________\n");
            sb.Append("Servered By  : " + comboBox3.Text + "          \n");
            sb.Append("Table Number : " + comboBox2.Text + "          \n");
            sb.Append("_______________________________________________\n");
            sb.Append("            Total Bill  : " + Subtotal.Text + "\n");
            sb.Append("            Total Items : " + Subtotal.Text + "\n");
            sb.Append("                 Mode   : Cash                 \n");
            sb.Append("_______________________________________________\n");
            sb.Append("   Come in as Guest Leave As Family           \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            sb.Append("                                               \n");
            string s = sb.ToString();
            // device-dependent string, need a FormFeed?
            //
            // Allow the user to select a printer.
            PrintDialog pd = new PrintDialog();

            pd.PrinterSettings = new PrinterSettings();
            // Send a printer-specific to the printer.
            RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s + COMMAND);
            listView1.Items.Clear();
            Subtotal.Text  = "";
            qtytotal.Text  = "";
            comboBox2.Text = "";
            comboBox3.Text = "";
            LoadOrders();
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            panel2.Visible = false;
            try
            {
                DataGridViewRow row = this.dataGridView1.SelectedRows[0];


                DialogResult res = MessageBox.Show("ARE YOU SURE YOU WANT TO CLOSE THIS ORDER : " + row.Cells[0].Value.ToString(), "Order", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (res == DialogResult.Yes)
                {
                    String on      = row.Cells[0].Value.ToString();
                    String waiter1 = row.Cells[3].Value.ToString();
                    String Query   = "UPDATE `orders` SET `Status`='Closed' WHERE  `OrderNumber`='" + on + "' ";
                    HorsePower.ExecuteSQL(Query);
                    LoadOrders();
                    //save the sale
                    SaveSale(on, waiter1);
                    //save statement
                    HorsePower.ExecuteSQL(" INSERT INTO `finance_statement` (`name`, `type`, `date`, `debit`, `credit`, `balance` ) VALUES ('Income', 'Income', '" + DateTime.Now.ToShortDateString() + "', '0', '" + paid.Text + "', '0' );");

                    panel2.Visible = false;

                    string GS      = Convert.ToString((char)29);
                    string ESC     = Convert.ToString((char)27);
                    Random rno     = new Random();
                    string receipt = rno.Next(0, 100).ToString();
                    string COMMAND = "";
                    COMMAND  = ESC + "@";
                    COMMAND += GS + "V" + (char)1;
                    DateTime D = DateTime.Now;
                    //  int i = 0;
                    StringBuilder sb = new StringBuilder();
                    sb.Append("           DYKAAN HOTEL                       \n");
                    sb.Append("KIAMBUU TWIGA BUILDING SECOND FLOOR           \n");
                    sb.Append("P.O. Box                                      \n");

                    //sb.Append("KIAMBUU                                      \n");
                    // sb.Append("         BILLING RECEIPT                       \n");

                    sb.Append("DATE      :" + D.ToString() + "                \n");
                    sb.Append("TELL NO   : 0723156900                         \n");
                    sb.Append("TILL NO   : 83359                              \n");
                    sb.Append("ADDRESS   : 01000 - 152 THIKA                  \n");
                    sb.Append("RECEIPTNO : " + receipt.ToString() + "         \n");
                    // sb.Append("WAITER    : " + comboBox3.Text + "             \n");

                    sb.Append("          CASH SALE RECEIPT                    \n");
                    sb.Append("_______________________________________________\n");
                    // sb.Append("No     Name       Quantity      Price     Total\n");
                    sb.Append("_______________________________________________\n");
                    sb.Append("               Customer Bill List              \n");
                    sb.Append("_______________________________________________\n");
                    int j = 0;
                    for (int i = 0; i < dataGridView2.Rows.Count; i++)
                    {
                        j = j + 1;
                        sb.Append(j.ToString() + "." + "     " + dataGridView2.Rows[i].Cells[0].Value + "        " + dataGridView2.Rows[i].Cells[1].Value + " X   " + dataGridView2.Rows[i].Cells[2].Value + "      \n");
                    }

                    /*  for (int i = 0; i < dataGridView2.Rows.Count; i++)
                     * {
                     *    j = j + 1;
                     *    sb.Append("     " + dataGridView2.Rows[i].Cells[1].Value + " x       " + dataGridView2.Rows[i].Cells[2].Value + "  "+ dataGridView2.Rows[i].Cells[0].Value + "           \n");
                     * }*/
                    sb.Append("______________________________________________ \n");
                    sb.Append("Serverd By  : " + waiter.Text + "          \n");
                    // sb.Append("Table Number : " + comboBox2.Text + "          \n");
                    sb.Append("_______________________________________________\n");
                    sb.Append("            Total Items  : " + dataGridView2.Rows.Count.ToString() + "\n");
                    sb.Append("            Total Bill   : " + total.Text + "\n");
                    //  sb.Append("            Paid Amount : " + paid.Text +     "\n");
                    //  sb.Append("            Change      : " + change.Text +   "\n");
                    sb.Append("            Mode         : Cash                 \n");
                    sb.Append("_______________________________________________\n");
                    sb.Append("   Come in as Guest Leave As Family            \n");
                    sb.Append("                THANK YOU                      \n");

                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    string s = sb.ToString();
                    // device-dependent string, need a FormFeed?
                    //
                    // Allow the user to select a printer.
                    PrintDialog pd = new PrintDialog();
                    pd.PrinterSettings = new PrinterSettings();
                    // Send a printer-specific to the printer.
                    RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s + COMMAND);
                    total.Text  = "";
                    paid.Text   = "";
                    waiter.Text = "";
                    change.Text = "";
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
예제 #5
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkBox1.Checked == true)
                {
                    //place order
                    //generate the random order number
                    Random   r   = new Random();
                    int      ii  = r.Next(0, 50000);
                    String   id1 = ii.ToString();
                    DateTime d   = DateTime.Now;
                    //add order to db
                    String SQL1 = "INSERT INTO `Orders`(`OrderNumber`,`Date`, `Status`, `Total`, `Waiter`,`TableNumber`) VALUES ('" + id1 + "','" + dateTimePicker1.Text + "','Open','" + Subtotal.Text + "','" + textBox3.Text + "','" + comboBox2.Text + "')";
                    HorsePower.ExecuteSQL(SQL1);
                    MessageBox.Show("Order Posted Successfully", "Green Care POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    foreach (ListViewItem item in this.listView1.Items)
                    {
                        HorsePower.ExecuteSQL("INSERT INTO `OrderInfor`(`OrderNumber`, `ItemName`, `Quantity`, `Price`,`Total`)VALUES('" + id1 + "','" + item.SubItems[0].Text + "','" + item.SubItems[1].Text + "','" + item.SubItems[2].Text + "','" + item.SubItems[3].Text + "')");
                    }

                    string GS      = Convert.ToString((char)29);
                    string ESC     = Convert.ToString((char)27);
                    Random rno     = new Random();
                    string receipt = rno.Next(0, 10000).ToString();
                    string COMMAND = "";
                    COMMAND  = ESC + "@";
                    COMMAND += GS + "V" + (char)1;
                    DateTime D = DateTime.Now;
                    //  int i = 0;
                    StringBuilder sb = new StringBuilder();
                    sb.Append("           DYKAAN HOTEL                       \n");
                    //sb.Append("KIAMBUU                                      \n");
                    sb.Append("         BILLING RECEIPT                       \n");

                    sb.Append("DATE      :" + D.ToString() + "                \n");
                    sb.Append("TELL NO   :                                    \n");
                    sb.Append("ADDRESS   : 386-30400                          \n");
                    sb.Append("RECEIPTNO : " + receipt.ToString() + "         \n");
                    sb.Append("WAITER    : " + comboBox3.Text + "             \n");

                    sb.Append("           CUSTOMER BILL RECEIPT               \n");
                    sb.Append("_______________________________________________\n");
                    // sb.Append("No     Name       Quantity      Price     Total\n");
                    sb.Append("_______________________________________________\n");
                    sb.Append("          ITEMS LISTS                          \n");
                    sb.Append("_______________________________________________\n");

                    foreach (ListViewItem item in listView1.Items)
                    {
                        i = i + 1;
                        sb.Append(i.ToString() + "." + "     " + item.SubItems[0].Text + "        " + item.SubItems[1].Text + " X   " + item.SubItems[2].Text + "       " + item.SubItems[3].Text + "\n");
                    }
                    sb.Append("_______________________________________________\n");
                    sb.Append("Servered By  : " + comboBox3.Text + "          \n");
                    sb.Append("Table Number : " + comboBox2.Text + "          \n");
                    sb.Append("_______________________________________________\n");
                    sb.Append("            Total Bill  : " + Subtotal.Text + "\n");
                    sb.Append("            Total Items : " + Subtotal.Text + "\n");
                    sb.Append("                 Mode   : Cash                 \n");
                    sb.Append("_______________________________________________\n");
                    sb.Append("   Come in as Guest Leave As Family           \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    sb.Append("                                               \n");
                    string s = sb.ToString();
                    // device-dependent string, need a FormFeed?
                    //
                    // Allow the user to select a printer.
                    PrintDialog pd = new PrintDialog();
                    pd.PrinterSettings = new PrinterSettings();
                    // Send a printer-specific to the printer.
                    RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s + COMMAND);
                    listView1.Items.Clear();
                    Subtotal.Text  = "";
                    qtytotal.Text  = "";
                    comboBox2.Text = "";
                    comboBox3.Text = "";
                    LoadOrders();
                }
                else
                {
                    //generate the random order number
                    Random   r  = new Random();
                    int      i  = r.Next(0, 50000);
                    String   id = i.ToString();
                    DateTime d  = DateTime.Now;
                    //add order to db
                    String SQL = "INSERT INTO `Orders`(`OrderNumber`,`Date`, `Status`, `Total`, `Waiter`,`TableNumber`) VALUES ('" + id + "','" + dateTimePicker1.Text + "','Open','" + Subtotal.Text + "','" + textBox3.Text + "','" + comboBox2.Text + "')";
                    HorsePower.ExecuteSQL(SQL);
                    MessageBox.Show("Order Posted Successfully", "Green Care POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    foreach (ListViewItem item in this.listView1.Items)
                    {
                        HorsePower.ExecuteSQL("INSERT INTO `OrderInfor`(`OrderNumber`, `ItemName`, `Quantity`, `Price`,`Total`)VALUES('" + id + "','" + item.SubItems[0].Text + "','" + item.SubItems[1].Text + "','" + item.SubItems[2].Text + "','" + item.SubItems[3].Text + "')");
                    }
                    LoadOrders();
                    listView1.Items.Clear();
                    Subtotal.Text  = "";
                    qtytotal.Text  = "";
                    comboBox2.Text = "";
                    comboBox3.Text = "";
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }