Esempio n. 1
0
 void SendMail()
 {
     try
     {
         //send mail
         MailMessage Msg = new MailMessage();
         Msg.From = new MailAddress(from.Text);
         Msg.To.Add(recepient.Text);
         Msg.Subject = subject.Text;
         Msg.Body    = message.Text;
         SmtpClient smtp = new SmtpClient();
         smtp.Host        = "smtp.gmail.com";
         smtp.Port        = 587;
         smtp.Credentials = new System.Net.NetworkCredential(from.Text, password.Text);
         smtp.EnableSsl   = true;
         smtp.Send(Msg);
         //save the record in db
         DateTime d   = DateTime.Now;
         string   add = "INSERT INTO `MailMaster`(`To`, `From`, `Date`, `Subject`, `Message`, `Attachments`) VALUES  ('" + recepient.Text + "','" + from.Text + "','" + d.ToString() + "','" + subject.Text + "','" + message.Text + "','" + listBox1.Items.Count + "')";
         HorsePower.ExecuteSQL(add);
         MessageBox.Show("Email Sent and Saved", "Mail Master", MessageBoxButtons.OK, MessageBoxIcon.Information);
         loadMails();
     }
     catch (SmtpException ex)
     {
         MessageBox.Show("Cannot Send E-Mail : " + ex);
     }
 }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //check if there is an existing shift

            try
            {
                DataGridViewRow row       = this.dataGridView1.SelectedRows[0];
                String          number    = row.Cells[0].Value.ToString();
                String          firstname = row.Cells[1].Value.ToString();
                String          lastname  = row.Cells[2].Value.ToString();
                DateTime        d         = DateTime.Now;
                String          Time      = d.ToString("t");
                if (check(number, dateTimePicker1.Text))
                {
                    MessageBox.Show("Sorry But : " + firstname + lastname + " Has Already Started Shift", "Hotel POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    //insert to db
                    String QSL = "INSERT INTO `shift`(`IDNumber`,`FullNames`, `Date`,`StartTime`) VALUES ('" + number + "','" + firstname + lastname + "','" + dateTimePicker1.Text + "','" + Time + "')";

                    HorsePower.ExecuteSQL(QSL);

                    //get shifts
                    getShifts();
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || comboBox1.Text == "")
         {
             MessageBox.Show("Please Fill Account Details", "Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             //check if account exists
             MySqlCommand cmd = HorsePower.OpenConnection().CreateCommand();
             cmd.CommandText = "Select * From  `account`  WHERE `AccountNumber` = '" + textBox1.Text + "'";
             MySqlDataReader read = cmd.ExecuteReader();
             if (read.Read())
             {
                 MessageBox.Show("Duplicate Account Exists", "Account", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 //create account
                 String SQLQUERY = "INSERT INTO `account`(`AccountNumber`, `AccountName`, `Bank`, `DateOpened`, `Signitory`, `Accounttype`, `Amount`) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + dateTimePicker1.Text + "','" + textBox4.Text + "','" + comboBox1.Text + "','" + textBox5.Text + "')";
                 HorsePower.ExecuteSQL(SQLQUERY);
                 MessageBox.Show("Account Information Saved", "Account", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime     date = DateTime.Now;
         DialogResult res  = MessageBox.Show("Be Sure Because This Will Reduce Stock", "Stock", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (res == DialogResult.Yes)
         {
             //REDECE STOCK
             ReduceQty(textBox1.Text, textBox2.Text);
             //ADD TO LIST
             ListViewItem lv = new ListViewItem(new String[] { textBox1.Text, textBox2.Text });
             listView1.Items.Add(lv);
             Reload();
             HorsePower.ExecuteSQL("INSERT INTO `StockOut`(`Code`, `Name`, `Date`, `QuantityOut`, `Notes`) VALUES ('" + code.Text + "','" + textBox1.Text + "','" + date + "','" + textBox2.Text + "','" + textBox3.Text + "')");
         }
         else
         {
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                //delete item now
                DialogResult res = MessageBox.Show("ARE YOU SURE YOU WANT TO DELETE ITEM : " + itemname.Text + " COMPLETELY", "SYSTEM CONFIRMATION", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    HorsePower.ExecuteSQL("DELETE FROM `stock` WHERE `ItemName`='" + itemname.Text + "' AND `Code` = '" + code.Text + "'");

                    MessageBox.Show("Item Deleted/Removed From Current Stock DB", "Green Care POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    itemname.Text   = "";
                    code.Text       = "";
                    quantity.Text   = "";
                    categories.Text = "";
                    units.Text      = "";
                    bp.Text         = "";
                    supplier.Text   = "";
                    button1.Visible = true;
                    button2.Visible = false;
                    button3.Visible = false;
                    button4.Visible = false;
                    get();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 6
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         //check user account
         String AS = "SELECT `Username`, `Role`, `Password` FROM `login2` WHERE `Username` = '" + comboBox2.Text + "' AND `Role` = 'Admin' AND `Password` = '" + textBox1.Text + "'";
         // V2MySqlServer v2 = new V2MySqlServer(Server.getIP(), "root", "", "hotel");
         MySqlCommand cmd = HorsePower.OpenConnection().CreateCommand();
         cmd.CommandText = AS;
         MySqlDataReader read = cmd.ExecuteReader();
         if (read.Read())
         {
             if (!comboBox1.Text.Equals(""))
             {
                 //proceed to transfer money
                 int total = int.Parse(amount.Text) + int.Parse(tobank.Text);
                 //confirm from user
                 DialogResult res = MessageBox.Show("AMOUNT KSH:" + tobank.Text + " \n WILL BE TRANSFERED TO : " + bankname.Text + " \n ON : " + dateTimePicker1.Text + " \n BY : " + comboBox2.Text, "CONFIRM", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (res == DialogResult.Yes)
                 {
                     textBox1.Text    = "";
                     textBox1.Visible = false;
                     label11.Visible  = false;
                     //proceed
                     HorsePower.ExecuteSQL("UPDATE `account` SET `Amount`='" + total.ToString() + "' WHERE `AccountNumber` ='" + accountnumber.Text + "' AND `AccountName` = '" + accountname.Text + "'");
                     //save transaction trail
                     TransactionTrail();
                     //clear everything
                     accountname.Text   = "";
                     accountnumber.Text = "";
                     bankname.Text      = "";
                     signitory.Text     = "";
                     amount.Text        = "";
                     tobank.Text        = "";
                     source.Text        = "";
                     //refresh the account balance
                     RefreshAccount(comboBox1.Text);
                 }
                 else
                 {
                     MessageBox.Show("Oooh No ! You Have Not Selected Bank Account", "Invalid Parameters", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 }
             }
             //do nothing
         }
         else
         {
             //do not do anything
             MessageBox.Show("Sorry You Do Not Have Sufficient To Complete This Operation", "Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             textBox1.Text    = "";
             textBox1.Visible = false;
             label11.Visible  = false;
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            String SQL = "UPDATE `itemsmenu` SET `Price`='" + newprice.Text + "'  WHERE  `Name`= '" + name.Text + "'";

            HorsePower.ExecuteSQL(SQL);
            newprice.Text = "";
            ReloadGrid();
        }
Esempio n. 8
0
        private void button4_Click(object sender, EventArgs e)
        {
            int total = int.Parse(textBox2.Text) - int.Parse(add.Text);

            //update the db
            HorsePower.ExecuteSQL("UPDATE `openingbalance` SET `Amount`='" + total.ToString() + "' WHERE `FullNames`='" + textBox1.Text + "' AND `Date` = '" + dateTimePicker1.Text + "'");
            //reload the datagrid
            LoadStuff();
            //hide me
            groupBox1.Visible = false;
        }
Esempio n. 9
0
 void RemoveShift(string id, string date)
 {
     try
     {
         HorsePower.ExecuteSQL("DELETE FROM `shift` WHERE `IDNumber`='" + id + "' AND `Date` = '" + date + "'");
         getShifts();
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 10
0
        private void SaveSale(string on, string waiter)
        {
            //loop through the order
            MySqlCommand    cmd  = new MySqlCommand("SELECT `ItemName`, `Quantity`, `Price`, `Total` FROM `orderinfor` WHERE `OrderNumber` = '" + on + "'", HorsePower.OpenConnection());
            MySqlDataReader read = cmd.ExecuteReader();

            while (read.Read())
            {
                //insert the sales table
                HorsePower.ExecuteSQL("INSERT INTO `sales`(`Worker`,`Date`,`ItemName`,`Quantity`, `Price`,`Total`) VALUES ('" + waiter + "','" + dateTimePicker1.Text + "','" + read.GetString(0) + "','" + read.GetString(1) + "','" + read.GetString(2) + "','" + read.GetString(3) + "')");
            }
            MessageBox.Show("Hotel Sale Information Saved Successfully ", "Sale Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 11
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         String Update = "DELETE FROM `suppliers` WHERE `FullNames` ='" + NAMES + "'";
         HorsePower.ExecuteSQL(Update);
         get();
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 12
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         String Update = "UPDATE `suppliers` SET `Company`='" + company.Text + "',`Location`='" + location.Text + "',`FullNames`='" + fullnames.Text + "',`OfficeTel`='" + office.Text + "',`Mobile`='" + mobile.Text + "' WHERE `FullNames` = '" + NAMES + "'";
         HorsePower.ExecuteSQL(Update);
         // MessageBox.Show("Successfully Updated Supplier Information", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         get();
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 13
0
        private void seenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dataGridView1.SelectedRows[0];
            DialogResult    res = MessageBox.Show("ARE YOU SURE YOU WANT TO MARK ORDER : " + row.Cells[0].Value.ToString() + " AS SEEN", "Order", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                String on     = row.Cells[0].Value.ToString();
                String waiter = row.Cells[3].Value.ToString();
                String Query  = "UPDATE `orders` SET `OrderStatus`='Seen' WHERE  `OrderNumber`='" + on + "' ";
                HorsePower.ExecuteSQL(Query);
            }
            LoadOrders();
        }
Esempio n. 14
0
        private void clearFloatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewRow row  = this.dataGridView2.SelectedRows[0];
            String          name = row.Cells[0].Value.ToString();
            DialogResult    res  = MessageBox.Show("ARE YOU SURE YOU WANT TO CLEAR FLOAT FOR : " + row.Cells[0].Value.ToString() + "\n This Means That He/She Has Returned Total Float", "FLOAT", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                //set status to cleared
                HorsePower.ExecuteSQL("UPDATE `openingbalance` SET `Status`='Cleared' WHERE `FullNames`='" + name + "' AND `Date` = '" + dateTimePicker1.Text + "'");

                LoadStuff();
            }
        }
Esempio n. 15
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (ListViewItem item in this.listView1.Items)
         {
             HorsePower.ExecuteSQL("INSERT INTO `sales`(`Worker`,`Date`,`ItemName`,`Quantity`, `Price`,`Total`) VALUES ('" + textBox3.Text + "','" + saledate.Text + "','" + item.SubItems[0].Text + "','" + item.SubItems[1].Text + "','" + item.SubItems[2].Text + "','" + item.SubItems[3].Text + "')");
         }
         MessageBox.Show("Hotel Sale Information Saved Successfully ", "Sale Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 16
0
        public void DeleteOrders(String q1, String q2)
        {
            try
            {
                //delete orders
                HorsePower.ExecuteSQL(q1);

                //delete order infor
                HorsePower.ExecuteSQL(q2);
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 17
0
        private void closeOrderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dataGridView1.SelectedRows[0];


            DialogResult res = MessageBox.Show("ARE YOU SURE YOU WANT TO MARK : " + row.Cells[0].Value.ToString() + " AS COOKED", "STATUS", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                String on    = row.Cells[0].Value.ToString();
                String Query = "UPDATE `itemsmenu` SET `Status`='Cooked' WHERE `Name`='" + on + "' ";
                HorsePower.ExecuteSQL(Query);
                LoadStatus();
            }
        }
Esempio n. 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (firstname.Text == "" || lastname.Text == "" || idnumber.Text == "" || phone.Text == "" || residence.Text == "")
            {
                MessageBox.Show("Some Important Details Missing", "GreenCafe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                String QSL = "INSERT INTO `workers`(`FirstName`, `LastName`, `IDNumber`, `Gender`, `Telephone`, `Residence`, `WorkPosition`, `Salary`, `PaymentMode`, `WorkingDuration`) VALUES ('" + firstname.Text + "','" + lastname.Text + "','" + idnumber.Text + "','" + gender.Text + "','" + phone.Text + "','" + residence.Text + "','" + position.Text + "','" + salary.Text + "','" + mode.Text + "','" + duration.Text + "')";

                HorsePower.ExecuteSQL(QSL);
                //reload the grid
                LoadAllWorkers();
            }
        }
Esempio n. 19
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox2.Text == "")
         {
             MessageBox.Show("Some  Information Missing", "Point Of Sale", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             HorsePower.ExecuteSQL("INSERT INTO `Units`(`UnitName`)VALUES ('" + textBox2.Text + "')");
             getUnits();
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 20
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (ItemName.Text == "")
                {
                    MessageBox.Show("Some  Information Missing", "Point Of Sale", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    HorsePower.ExecuteSQL("INSERT INTO `ItemCategories`(`ItemName`,`Image`)VALUES ('" + ItemName.Text + "','" + pictureBox1.Image + "')");

                    Loads();
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 21
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text == "" || textBox2.Text == "")
         {
             MessageBox.Show("Some  Information Missing", "Point Of Sale", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             HorsePower.ExecuteSQL("INSERT INTO `Table`(`TableNumber`,`TableName`)VALUES ('" + textBox1.Text + "','" + textBox2.Text + "')");
             //MessageBox.Show("Successfully Added Table", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
             gettable();
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 22
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (firstname.Text == "" || lastname.Text == "" || amount.Text == "")
     {
         MessageBox.Show("Please Select Worker", "GreenCare", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         try
         {
             String sql = "INSERT INTO `OpeningBalance`(`FullNames`, `Date`, `Amount`,`Status`) VALUES ('" + firstname.Text + lastname.Text + "','" + dateTimePicker1.Text + "','" + amount.Text + "','Pending')";
             HorsePower.ExecuteSQL(sql);
             LoadStuff();
         }
         catch (Exception ex)
         {
             Console.Write(ex);
         }
     }
 }
Esempio n. 23
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (username.Text == "" || comboBox2.Text == "" || password.Text == "")
         {
             MessageBox.Show("Incomplete Information ", "Warning");
         }
         else
         {
             string add = "INSERT INTO `login2`(`username`,`Role`, `Password`) VALUES ('" + username.Text + "','" + comboBox2.Text + "','" + password.Text + "')";
             HorsePower.ExecuteSQL(add);
             MessageBox.Show("New Account Created ", "Transaction Succeeded", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 24
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (company.Text == "" || location.Text == "" || fullnames.Text == "" || mobile.Text == "")
         {
             MessageBox.Show("Some Supplier Information Missing", "GreenCafe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             String SQL = "INSERT INTO `suppliers`(`Company`, `Location`, `FullNames`, `OfficeTel`, `Mobile`, `Date`) VALUES ('" + company.Text + "','" + location.Text + "','" + fullnames.Text + "','" + office.Text + "','" + mobile.Text + "','" + dateTimePicker1.Text + "')";
             HorsePower.ExecuteSQL(SQL);
             MessageBox.Show("Successfully Saved Supplier Information", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
             get();
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
 }
Esempio n. 25
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (itemname.Text == "" || quantity.Text == "" || bp.Text == "" || categories.Text == "" || units.Text == "" || supplier.Text == "" || date.Text == "")
                {
                    MessageBox.Show("Some  Information Missing", "Point Of Sale", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        HorsePower.ExecuteSQL("INSERT INTO `Stock`(`Code`, `ItemName`, `Quantity`, `Categories`, `Units`, `BuyingPrice`, `Supplier`, `PurchaseDate`)VALUES ('" + code.Text + "','" + itemname.Text + "','" + quantity.Text + "','" + categories.Text + "','" + units.Text + "','" + bp.Text + "','" + supplier.Text + "','" + date.Text + "')");
                        //insert purchase record
                        int total = int.Parse(bp.Text) * int.Parse(quantity.Text);
                        HorsePower.ExecuteSQL("INSERT INTO `purchase_log`(`Date`, `Name`, `Quantity`, `Price`, `Total`) VALUES ('" + date.Text + "','" + itemname.Text + "','" + quantity.Text + "','" + bp.Text + "','" + total.ToString() + "')");


                        MessageBox.Show("Successfully Added New  Stock", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        itemname.Text   = "";
                        code.Text       = "";
                        quantity.Text   = "";
                        categories.Text = "";
                        units.Text      = "";
                        bp.Text         = "";
                        supplier.Text   = "";

                        get();
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 26
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow row       = this.dataGridView1.SelectedRows[0];
                String          number    = row.Cells[0].Value.ToString();
                String          firstname = row.Cells[1].Value.ToString();
                String          lastname  = row.Cells[2].Value.ToString();
                String          Names     = firstname + lastname;
                DateTime        d         = DateTime.Now;
                String          Time      = d.ToString("t");
                String          SQL       = "UPDATE `shift` SET  `StopTime`='" + Time + "' WHERE  `FullNames`='" + Names + "'";

                HorsePower.ExecuteSQL(SQL);

                //get shifts
                getShifts();
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 27
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (newitem.Text.Equals("") || newqty.Text.Equals("") || newbp.Text.Equals(""))
                {
                    MessageBox.Show("Please Search item First", "Green Care POS", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    int totqty = int.Parse(quantity.Text) + int.Parse(newqty.Text);
                    HorsePower.ExecuteSQL("UPDATE `stock` SET `ItemName`='" + newitem.Text + "',`Quantity`='" + totqty.ToString() + "',`Units`='" + newunits.Text + "',`BuyingPrice`='" + newbp.Text + "',`Supplier`='" + newsupplier.Text + "',`PurchaseDate`='" + pdate.Text + "' WHERE `ItemName`='" + itemname.Text + "' AND `Code` = '" + code.Text + "'");
                    MessageBox.Show("Successfully Updated " + newitem.Text, "Green Care POS", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //save purchase log
                    int total = int.Parse(newbp.Text) * int.Parse(newqty.Text);
                    HorsePower.ExecuteSQL("INSERT INTO `purchase_log`(`Date`, `Name`, `Quantity`, `Price`, `Total`) VALUES ('" + pdate.Text + "','" + newitem.Text + "','" + newqty.Text + "','" + newbp.Text + "','" + total.ToString() + "')");
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 28
0
        private void ReduceQty(string name, string qty)
        {
            try
            {
                int q = 0;
                //fetch the quantity
                MySqlCommand    cmd  = new MySqlCommand("SELECT `Quantity` FROM `stock` WHERE `ItemName` = '" + name + "'", HorsePower.OpenConnection());
                MySqlDataReader read = cmd.ExecuteReader();
                if (read.Read())
                {
                    q = int.Parse(read.GetString(0));
                }
                //now reduce the stock by subtratcting
                int total = q - int.Parse(qty);

                //now update the new stock qty

                HorsePower.ExecuteSQL("UPDATE `stock` SET `Quantity`='" + total + "' WHERE `ItemName` = '" + name + "'");
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
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)
            {
            }
        }