示例#1
0
        private void btnpos_MouseUp(object sender, MouseEventArgs e)
        {
            frmscreenlogin fr = new frmscreenlogin();

            fr.Show();
        }
示例#2
0
        private void button11_MouseUp_1(object sender, MouseEventArgs e)
        {
            //save and print order
            try
            {
                try
                {
                    for (int j = 0; j <= ListView1.Items.Count - 1; j++)
                    {
                        MySqlConnection conn = new MySqlConnection(cs.myconnection1);
                        conn.Open();
                        string       fquery      = "select availablequantity from food where  food_name ='" + ListView1.Items[j].SubItems[2].Text + "'";
                        MySqlCommand mycommand11 = new MySqlCommand(fquery, conn);
                        string       prev_value  = mycommand11.ExecuteScalar().ToString();

                        if (Convert.ToInt32(prev_value) < 1)
                        {
                            MessageBox.Show("Food out of stock");
                            return;
                        }
                        else if (Convert.ToInt32(prev_value) < Convert.ToInt32(ListView1.Items[j].SubItems[1].Text))
                        {
                            MessageBox.Show("More products than the available quantity");
                            return;
                        }
                    }


                    if (ListView1.Items.Count == 0)
                    {
                        MessageBox.Show("sorry no Food  selected", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                catch (Exception)
                {
                }

                q1();
                /********/
                q2();
                for (int j = 0; j <= ListView1.Items.Count - 1; j++)
                {
                    MySqlConnection conn = new MySqlConnection(cs.myconnection1);
                    conn.Open();
                    string       fquery      = "select availablequantity from food where  food_name ='" + ListView1.Items[j].SubItems[2].Text + "'";
                    MySqlCommand mycommand11 = new MySqlCommand(fquery, conn);
                    string       prev_value  = mycommand11.ExecuteScalar().ToString();

                    int x3 = Convert.ToInt32(prev_value);
                    int x1 = Convert.ToInt32(ListView1.Items[j].SubItems[1].Text);
                    int x4;
                    x4 = x3 - x1;

                    string Query2 = "UPDATE  food set  availablequantity='" + x4 + "' where  food_name='" + ListView1.Items[j].SubItems[2].Text + "'";

                    MySqlCommand    mycommand2 = new MySqlCommand(Query2, conn);
                    MySqlDataReader myreader2;
                    myreader2 = mycommand2.ExecuteReader();//execution command
                    conn.Close();
                }

                prinreceipt();
                clr();
                frmscreenlogin fr = new frmscreenlogin();
                this.Hide();
                fr.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex + "Error ocurrred while rtying to save, try again");
            }
        }