Esempio n. 1
0
        public void Tambah(String noMeja, String nama, int jumlah, int harga, int total)
        {
            try
            {
                koneksi                 = new Koneksi();
                koneksi.cmd             = koneksi.conn.CreateCommand();
                koneksi.cmd.CommandText = "select id, menu, jumlah, total from tblOrder where noMeja = '" + noMeja + "'";
                koneksi.dt              = new DataTable("tblOrder");

                koneksi.conn.Open();
                koneksi.dt.Load(koneksi.cmd.ExecuteReader());
                koneksi.conn.Close();

                bool cek = false;
                foreach (DataRow i in koneksi.dt.Rows)
                {
                    if ((String)i["menu"] == nama)
                    {
                        this.id     = (int)i["id"];
                        this.jumlah = jumlah + (int)i["jumlah"];
                        this.total  = this.jumlah * harga;
                        cek         = true;
                        break;
                    }
                }

                if (cek == true)
                {
                    koneksi.cmd.CommandText = "update tblOrder set jumlah='" + this.jumlah + "', total='" + this.total + "' where id='" + this.id + "'";
                    koneksi.conn.Open();
                    koneksi.cmd.ExecuteNonQuery();
                    koneksi.conn.Close();
                }
                else
                {
                    koneksi.cmd.CommandText = "insert into tblOrder values('','" + noMeja + "','" + nama + "', '" + jumlah + "', '" + harga + "', '" + total + "')";
                    koneksi.conn.Open();
                    koneksi.cmd.ExecuteNonQuery();
                    koneksi.conn.Close();
                }

                MessageBox.Show(string.Format("Pesanan anda telah disimpan"), "Özil Cafe", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}", ex.Message), "Özil Cafe", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        public void Tambah(String noMeja, String nama, int jumlah, int harga, int total)
        {
            try
            {
                koneksi = new Koneksi();
                koneksi.cmd.CommandText = "insert into tblOrder values('','" + noMeja + "','" + nama + "', '" + jumlah + "', '" + harga + "', '" + total + "')";

                koneksi.conn.Open();
                koneksi.cmd.ExecuteNonQuery();
                koneksi.conn.Close();

                MessageBox.Show(string.Format("Pesanan anda telah disimpan"), "Özil Cafe", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}", ex.Message), "Özil Cafe", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
        public void Hapus(String noMeja)
        {
            try
            {
                koneksi                 = new Koneksi();
                koneksi.cmd             = koneksi.conn.CreateCommand();
                koneksi.cmd.CommandText = "delete from tblOrder where noMeja = '" + noMeja + "'";

                koneksi.conn.Open();
                koneksi.cmd.ExecuteNonQuery();
                koneksi.conn.Close();

                MessageBox.Show(string.Format("Pesanan anda telah dihapus"), "Özil Cafe", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}", ex.Message), "Özil Cafe", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }