Exemplo n.º 1
0
        private void btn_bayar_Click(object sender, EventArgs e)
        {
            if (ID != 0)
            {
                using (var ctx = new db_dataEntities())
                {
                    ObjectCache cache = MemoryCache.Default;
                    dynamic     user  = cache.Get("userLogin");

                    var order = ctx.tbl_order.Where(o => o.id == ID).FirstOrDefault();
                    order.total_bayar  = decimal.Parse(total_bayar_txt.Text);
                    order.kembali      = decimal.Parse(kembali_txt.Text);
                    order.status       = 1;
                    order.updated_by   = user.username;
                    order.updated_date = DateTime.Now;

                    ctx.tbl_order.AddOrUpdate(order);
                    ctx.SaveChanges();

                    MessageBox.Show("Pembayaran Selesai");

                    //ID = 0;
                    btn_bayar.Enabled  = false;
                    btn_biling.Enabled = true;

                    MappingToDataGrid();
                }
            }
        }
Exemplo n.º 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row = dataGridView1.Rows[e.RowIndex];

            if (e.RowIndex >= 0 && !string.IsNullOrEmpty(row.Cells[0].Value.ToString()))
            {
                var id = int.Parse(row.Cells[0].Value.ToString());
                using (var ctx = new db_dataEntities())
                {
                    var order = ctx.tbl_order.Where(o => o.id == id).FirstOrDefault();
                    this.no_meja_txt.Text     = order.no_meja;
                    this.subtotal_txt.Text    = order.subtotal.ToString();
                    this.total_bayar_txt.Text = order.total_bayar.ToString();
                    this.kembali_txt.Text     = order.kembali.ToString();
                    if (order.status == 0)
                    {
                        btn_bayar.Enabled  = true;
                        btn_biling.Enabled = false;
                    }
                    else if (order.status == 1)
                    {
                        btn_bayar.Enabled  = false;
                        btn_biling.Enabled = true;
                    }
                    ID = id;
                }
            }
        }
Exemplo n.º 3
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            using (var ctx = new db_dataEntities())
            {
                var username = this.txtusername.Text;
                var password = this.txtpassword.Text;

                var getUser = ctx.tbl_user.Where(o => o.username == username && o.password == password).FirstOrDefault();

                if (getUser != null)
                {
                    ObjectCache     cache           = MemoryCache.Default;
                    CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
                    cache.Add("userLogin", getUser, cacheItemPolicy);

                    this.Hide();

                    menu_admin frm2 = new menu_admin();
                    frm2.Show();
                }
                else
                {
                    MessageBox.Show("please check username and password");
                    this.txtusername.Text = "";
                    this.txtpassword.Text = "";
                }
            }
        }
Exemplo n.º 4
0
        private void btn_hapus_Click(object sender, EventArgs e)
        {
            ObjectCache cache = MemoryCache.Default;
            dynamic     user  = cache.Get("userLogin");

            int id = ID;

            if (id != 0)
            {
                DialogResult result = MessageBox.Show("Apakah Anda yakin ingin mengahapus data ini?", "Warning",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    using (var ctx = new db_dataEntities())
                    {
                        var menu = ctx.tbl_menu.Where(o => o.id == id).FirstOrDefault();

                        menu.is_active    = 0;
                        menu.deleted_by   = user.username;
                        menu.deleted_date = DateTime.Now;

                        ctx.tbl_menu.AddOrUpdate(menu);
                        ctx.SaveChanges();
                    }
                    MessageBox.Show("Sukses Delete");
                    Initial();
                }
                else if (result == DialogResult.No)
                {
                    //code for No
                }
            }
        }
Exemplo n.º 5
0
 public List <tbl_order> GetListOrder()
 {
     using (var ctx = new db_dataEntities())
     {
         var getMenu = ctx.tbl_order.Where(o => o.is_active == 1).ToList();
         return(getMenu);
     }
 }
Exemplo n.º 6
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
                if (e.RowIndex >= 0 && !string.IsNullOrEmpty(row.Cells[0].Value.ToString()))
                {
                    var id = int.Parse(row.Cells[0].Value.ToString());
                    using (var ctx = new db_dataEntities())
                    {
                        var menu = ctx.tbl_menu.Where(o => o.id == id).FirstOrDefault();
                        this.txt_nama_menu.Text  = menu.nama_menu;
                        this.txt_harga.Text      = menu.harga_satuan.ToString();
                        this.txt_keterangan.Text = menu.keterangan;
                        this.txt_foto.Text       = menu.foto;
                        if (!string.IsNullOrEmpty(menu.foto))
                        {
                            // display image in picture box
                            try
                            {
                                pictureBox2.Image = new Bitmap(menu.foto);
                            }
                            catch (Exception ex)
                            {
                                pictureBox2.Image = null;
                            }
                        }
                        else
                        {
                            pictureBox2.Image = null;
                        }
                        foreach (var jenis in this.cmb_jenis.Items)
                        {
                            var namaJenis = "";
                            if (menu.jenis == 1)
                            {
                                namaJenis = "Makanan";
                            }
                            else if (menu.jenis == 2)
                            {
                                namaJenis = "Minuman";
                            }

                            if (namaJenis == jenis)
                            {
                                this.cmb_jenis.SelectedItem = jenis.ToString();
                            }
                        }
                    }
                    ID = id;
                    this.btn_simpan.Enabled = false;
                    this.btn_update.Enabled = true;
                    this.btn_hapus.Enabled  = true;
                }
            }
        }
Exemplo n.º 7
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            ObjectCache cache = MemoryCache.Default;
            dynamic     user  = cache.Get("userLogin");


            var id = ID;

            if (id != 0)
            {
                using (var ctx = new db_dataEntities())
                {
                    var menu = ctx.tbl_menu.Where(o => o.id == id).FirstOrDefault();

                    var jenis = 0;
                    if (this.cmb_jenis.SelectedItem == "Makanan")
                    {
                        jenis = 1;
                    }
                    else if (this.cmb_jenis.SelectedItem == "Minuman")
                    {
                        jenis = 2;
                    }
                    menu.jenis        = jenis;
                    menu.updated_by   = user.username;
                    menu.updated_date = DateTime.Now;
                    menu.nama_menu    = this.txt_nama_menu.Text;
                    menu.harga_satuan = decimal.Parse(this.txt_harga.Text);
                    menu.keterangan   = this.txt_keterangan.Text;
                    menu.foto         = this.txt_foto.Text;

                    var date  = menu.updated_date.Value.ToString("yyyy-M-dd hh:mm:ss");
                    var query = "UPDATE tbl_menu " +
                                " SET " +
                                " updated_by = '" + menu.updated_by + "'," +
                                " updated_date = CAST('" + date + "' AS DATETIME2)," +
                                " nama_menu = '" + menu.nama_menu + "'," +
                                " harga_satuan = " + menu.harga_satuan + "," +
                                " keterangan = '" + menu.keterangan + "'," +
                                " foto = '" + menu.foto + "'," +
                                " jenis =" + menu.jenis + " WHERE id = " + menu.id;
                    ctx.Database.ExecuteSqlCommand(query);

                    //ctx.tbl_menu.AddOrUpdate(menu);
                    //ctx.SaveChanges();
                }

                MessageBox.Show("Sukses Update");

                Initial();
            }
        }
Exemplo n.º 8
0
        private void btn_simpan_Click(object sender, EventArgs e)
        {
            ObjectCache cache = MemoryCache.Default;
            dynamic     user  = cache.Get("userLogin");
            var         jenis = 0;

            if (this.cmb_jenis.SelectedItem == "Makanan")
            {
                jenis = 1;
            }
            else if (this.cmb_jenis.SelectedItem == "Minuman")
            {
                jenis = 2;
            }

            var menu = new tbl_menu()
            {
                is_active    = 1,
                created_by   = user.username,
                created_date = DateTime.Now,
                nama_menu    = this.txt_nama_menu.Text,
                harga_satuan = decimal.Parse(this.txt_harga.Text),
                keterangan   = this.txt_keterangan.Text,
                foto         = this.txt_foto.Text,
                jenis        = jenis
            };

            var date = menu.created_date.Value.ToString("yyyy-M-dd hh:mm:ss");

            using (var ctx = new db_dataEntities())
            {
                //ctx.tbl_menu.Add(menu);
                //ctx.SaveChanges();
                ctx.Database.ExecuteSqlCommand("INSERT INTO tbl_menu (is_active,created_by,created_date," +
                                               "nama_menu,harga_satuan,keterangan,foto,jenis) " +
                                               " VALUES (" +
                                               "" + menu.is_active + "," +
                                               "'" + menu.created_by + "'," +
                                               " CAST('" + date + "' AS DATETIME2)," +
                                               "'" + menu.nama_menu + "'," +
                                               "" + menu.harga_satuan + "," +
                                               "'" + menu.keterangan + "'," +
                                               "'" + menu.foto + "'," +
                                               "" + menu.jenis + ")");
                var id = ctx.tbl_menu.OrderByDescending(o => o.id).FirstOrDefault();
            }

            MessageBox.Show("Sukses Simpan");

            Initial();
        }
Exemplo n.º 9
0
        public List <tbl_menu> GetMenuTerlaris(int jenis, string terlaris, int page = 0, int size = 3)
        {
            using (var ctx = new db_dataEntities())
            {
                var listMenuWithCount = new List <MenuWithCount>();

                var menuIds = ctx.tbl_detail_order.Where(o => o.is_active == 1).Select(o => o.id_menu).Distinct().ToList();

                foreach (var menuId in menuIds)
                {
                    var count = 0;
                    if (terlaris == "Minggu Ini")
                    {
                        var date = DateTime.Now.AddDays(-7);
                        count = ctx.tbl_detail_order.Where(o => o.is_active == 1 &&
                                                           o.created_date >= date && o.created_date <= DateTime.Now &&
                                                           o.id_menu == menuId).Count();
                    }
                    else if (terlaris == "Bulan Ini")
                    {
                        var date = DateTime.Now.AddMonths(-1);
                        count = ctx.tbl_detail_order.Where(o => o.is_active == 1 &&
                                                           o.created_date >= date &&
                                                           o.created_date <= DateTime.Now && o.id_menu == menuId).Count();
                    }
                    else
                    {
                        count = ctx.tbl_detail_order.Where(o => o.is_active == 1 && o.id_menu == menuId).Count();
                    }

                    var menuWCount = new MenuWithCount
                    {
                        IdMenu = menuId.Value,
                        Count  = count
                    };

                    listMenuWithCount.Add(menuWCount);
                }
                var idslistMenuWithCount = listMenuWithCount
                                           .OrderByDescending(c => c.Count)
                                           .Skip(page * size)
                                           .Take(size)
                                           .Select(c => c.IdMenu);

                var getMenu = ctx.tbl_menu
                              .Where(o => o.jenis == jenis && idslistMenuWithCount.Contains(o.id))
                              .ToList();

                return(getMenu);
            }
        }
Exemplo n.º 10
0
        public List <tbl_menu> GetMenu(int jenis, int page = 0, int size = 3)
        {
            using (var ctx = new db_dataEntities())
            {
                var getMenu = ctx.tbl_menu
                              .Where(o => o.jenis == jenis && o.is_active == 1)
                              .OrderBy(o => o.nama_menu)
                              .Skip(page * size)
                              .Take(size)
                              .ToList();

                return(getMenu);
            }
        }
Exemplo n.º 11
0
        public int GetCountMenu(int jenis, int page = 0, int size = 3)
        {
            using (var ctx = new db_dataEntities())
            {
                var getMenu = ctx.tbl_menu
                              .Where(o => o.jenis == jenis)
                              .OrderBy(o => o.nama_menu)
                              .Skip(page * size)
                              .Take(size)
                              .Count();

                return(getMenu);
            }
        }
Exemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            var subTotal = listOrder.Sum(o => o.harga_total);
            var idOrder  = 0;

            if (listOrder.Count > 0)
            {
                var data = new tbl_order
                {
                    created_by   = "user",
                    created_date = DateTime.Now,
                    no_meja      = no_meja.Text,
                    subtotal     = subTotal,
                    status       = 0,
                    is_active    = 1
                };
                using (var ctx = new db_dataEntities())
                {
                    var id = ctx.tbl_order.Add(data);
                    ctx.SaveChanges();
                    idOrder = id.id;
                }
            }

            foreach (var order in listOrder)
            {
                var detailOrder = new tbl_detail_order
                {
                    created_by   = "user",
                    created_date = DateTime.Now,
                    id_order     = idOrder,
                    id_menu      = order.id_menu,
                    qty          = order.qty,
                    harga_satuan = order.harga_satuan,
                    harga_total  = order.harga_total,
                    is_active    = 1
                };

                using (var ctx = new db_dataEntities())
                {
                    ctx.tbl_detail_order.Add(detailOrder);
                    ctx.SaveChanges();
                }
            }

            MessageBox.Show("Menu Telah Di Order");

            Initial();
        }
Exemplo n.º 13
0
        private void btn_hapus_Click(object sender, EventArgs e)
        {
            ObjectCache cache = MemoryCache.Default;
            dynamic     user  = cache.Get("userLogin");

            int id = ID;

            if (id != 0)
            {
                DialogResult result = MessageBox.Show("Apakah Anda yakin ingin mengahapus data ini?", "Warning",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    using (var ctx = new db_dataEntities())
                    {
                        var menu = ctx.tbl_menu.Where(o => o.id == id).FirstOrDefault();

                        menu.is_active    = 0;
                        menu.deleted_by   = user.username;
                        menu.deleted_date = DateTime.Now;

                        var date  = menu.deleted_date.Value.ToString("yyyy-M-dd hh:mm:ss");
                        var query = "UPDATE tbl_menu " +
                                    " SET " +
                                    " deleted_by = '" + menu.deleted_by + "'," +
                                    " deleted_date = CAST('" + date + "' AS DATETIME2)," +
                                    " is_active = " + menu.is_active +
                                    " WHERE id = " + menu.id;

                        ctx.Database.ExecuteSqlCommand(query);


                        //ctx.tbl_menu.AddOrUpdate(menu);
                        //ctx.SaveChanges();
                    }
                    MessageBox.Show("Sukses Delete");
                    Initial();
                }
                else if (result == DialogResult.No)
                {
                    //code for No
                }
            }
        }
Exemplo n.º 14
0
        private void btn_bayar_Click(object sender, EventArgs e)
        {
            if (ID != 0)
            {
                using (var ctx = new db_dataEntities())
                {
                    ObjectCache cache = MemoryCache.Default;
                    dynamic     user  = cache.Get("userLogin");

                    var order = ctx.tbl_order.Where(o => o.id == ID).FirstOrDefault();
                    order.total_bayar  = decimal.Parse(total_bayar_txt.Text);
                    order.kembali      = decimal.Parse(kembali_txt.Text);
                    order.status       = 1;
                    order.updated_by   = user.username;
                    order.updated_date = DateTime.Now;


                    var date  = order.updated_date.Value.ToString("yyyy-M-dd hh:mm:ss");
                    var query = "UPDATE tbl_order " +
                                " SET " +
                                " updated_by = '" + order.updated_by + "'," +
                                " updated_date = CAST('" + date + "' AS DATETIME2)," +
                                " total_bayar = " + order.total_bayar + "," +
                                " kembali = " + order.kembali + "," +
                                " status = " + order.status +
                                " WHERE id = " + order.id;

                    ctx.Database.ExecuteSqlCommand(query);

                    //ctx.tbl_order.AddOrUpdate(order);
                    //ctx.SaveChanges();

                    MessageBox.Show("Pembayaran Selesai");

                    //ID = 0;
                    btn_bayar.Enabled  = false;
                    btn_biling.Enabled = true;

                    MappingToDataGrid();
                }
            }
        }
Exemplo n.º 15
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            ObjectCache cache = MemoryCache.Default;
            dynamic     user  = cache.Get("userLogin");


            var id = ID;

            if (id != 0)
            {
                using (var ctx = new db_dataEntities())
                {
                    var menu = ctx.tbl_menu.Where(o => o.id == id).FirstOrDefault();

                    var jenis = 0;
                    if (this.cmb_jenis.SelectedItem == "Makanan")
                    {
                        jenis = 1;
                    }
                    else if (this.cmb_jenis.SelectedItem == "Minuman")
                    {
                        jenis = 2;
                    }
                    menu.jenis        = jenis;
                    menu.updated_by   = user.username;
                    menu.updated_date = DateTime.Now;
                    menu.nama_menu    = this.txt_nama_menu.Text;
                    menu.harga_satuan = decimal.Parse(this.txt_harga.Text);
                    menu.keterangan   = this.txt_keterangan.Text;
                    menu.foto         = this.txt_foto.Text;

                    ctx.tbl_menu.AddOrUpdate(menu);
                    ctx.SaveChanges();
                }

                MessageBox.Show("Sukses Update");

                Initial();
            }
        }
Exemplo n.º 16
0
        private void btn_simpan_Click(object sender, EventArgs e)
        {
            ObjectCache cache = MemoryCache.Default;
            dynamic     user  = cache.Get("userLogin");
            var         jenis = 0;

            if (this.cmb_jenis.SelectedItem == "Makanan")
            {
                jenis = 1;
            }
            else if (this.cmb_jenis.SelectedItem == "Minuman")
            {
                jenis = 2;
            }

            var menu = new tbl_menu()
            {
                is_active    = 1,
                created_by   = user.username,
                created_date = DateTime.Now,
                nama_menu    = this.txt_nama_menu.Text,
                harga_satuan = decimal.Parse(this.txt_harga.Text),
                keterangan   = this.txt_keterangan.Text,
                foto         = this.txt_foto.Text,
                jenis        = jenis
            };

            using (var ctx = new db_dataEntities())
            {
                ctx.tbl_menu.Add(menu);
                ctx.SaveChanges();
            }

            MessageBox.Show("Sukses Simpan");

            Initial();
        }
Exemplo n.º 17
0
        private void button1_Click(object sender, EventArgs e)
        {
            var subTotal = listOrder.Sum(o => o.harga_total);
            var idOrder  = 0;

            if (listOrder.Count > 0)
            {
                var data = new tbl_order
                {
                    created_by   = "user",
                    created_date = DateTime.Now,
                    no_meja      = no_meja.Text,
                    subtotal     = subTotal,
                    status       = 0,
                    is_active    = 1
                };

                var date = data.created_date.Value.ToString("yyyy-M-dd hh:mm:ss");

                using (var ctx = new db_dataEntities())
                {
                    var query = "INSERT INTO tbl_order (is_active,created_by,created_date," +
                                "no_meja,subtotal,status) " +
                                " VALUES (" +
                                "" + data.is_active + "," +
                                "'" + data.created_by + "'," +
                                " CAST('" + date + "' AS DATETIME2)," +
                                "'" + data.no_meja + "'," +
                                "" + data.subtotal + "," +
                                "" + data.status + ")";

                    ctx.Database.ExecuteSqlCommand(query);

                    var id = ctx.tbl_order.OrderByDescending(o => o.id).FirstOrDefault();

                    //var id = ctx.tbl_order.Add(data);
                    //ctx.SaveChanges();
                    idOrder = id.id;
                }
            }

            foreach (var order in listOrder)
            {
                var detailOrder = new tbl_detail_order
                {
                    created_by   = "user",
                    created_date = DateTime.Now,
                    id_order     = idOrder,
                    id_menu      = order.id_menu,
                    qty          = order.qty,
                    harga_satuan = order.harga_satuan,
                    harga_total  = order.harga_total,
                    is_active    = 1
                };

                var date = detailOrder.created_date.Value.ToString("yyyy-M-dd hh:mm:ss");

                using (var ctx = new db_dataEntities())
                {
                    var query = "INSERT INTO tbl_detail_order ([is-active],created_by,created_date," +
                                "id_order,id_menu,qty,harga_satuan,harga_total) " +
                                " VALUES (" +
                                "" + detailOrder.is_active + "," +
                                "'" + detailOrder.created_by + "'," +
                                " CAST('" + date + "' AS DATETIME2)," +
                                "" + detailOrder.id_order + "," +
                                "" + detailOrder.id_menu + "," +
                                "" + detailOrder.qty + "," +
                                "" + detailOrder.harga_satuan + "," +
                                "" + detailOrder.harga_total + ")";

                    ctx.Database.ExecuteSqlCommand(query);

                    //ctx.tbl_detail_order.Add(detailOrder);
                    //ctx.SaveChanges();
                }
            }

            MessageBox.Show("Menu Telah Di Order");

            Initial();
        }
Exemplo n.º 18
0
        public void LoadReport(DateTime startDate, DateTime endDate)
        {
            reportViewer1.LocalReport.DataSources.Clear();
            //reportViewer1.LocalReport.DataSources.Add(rptds);
            reportViewer1.LocalReport.Refresh();
            ReportDataSource rptDS;

            this.reportViewer1.RefreshReport();
            try
            {
                reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Reports\\Report_Laporan.rdlc";


                var ds = new DataSet_Billing();
                var da = new SqlDataAdapter();


                using (var ctx = new db_dataEntities())
                {
                    var listOrder = ctx.tbl_order.Where(o => EntityFunctions.TruncateTime(o.created_date.Value) >= startDate.Date && EntityFunctions.TruncateTime(o.created_date.Value) <= endDate.Date).ToList();

                    foreach (var getOrder in listOrder)
                    {
                        DataRow row;
                        var     status = "";
                        if (getOrder.status == 0)
                        {
                            status = "Belum Bayar";
                        }
                        else if (getOrder.status == 1)
                        {
                            status = "Sudah Bayar";
                        }

                        var getDetailOrder = ctx.tbl_detail_order.Where(o => o.id_order == getOrder.id).ToList();

                        foreach (var detailOrder in getDetailOrder)
                        {
                            var menu = ctx.tbl_menu.Where(o => o.id == detailOrder.id_menu).FirstOrDefault();
                            row = ds.Tables["DataTableLaporan"].NewRow();

                            row[0]  = getOrder.id.ToString();
                            row[1]  = getOrder.no_meja.ToString();
                            row[2]  = menu.nama_menu.ToString();
                            row[3]  = detailOrder.qty.ToString();
                            row[4]  = menu.harga_satuan.ToString();
                            row[5]  = detailOrder.harga_total.ToString();
                            row[6]  = getOrder.subtotal.ToString();
                            row[7]  = getOrder.total_bayar.ToString();
                            row[8]  = getOrder.kembali.ToString();
                            row[9]  = status.ToString();
                            row[10] = detailOrder.created_date.Value.Date.ToString();

                            ds.Tables["DataTableLaporan"].Rows.Add(row);
                        }
                    }
                }



                rptDS = new ReportDataSource("DataTableLaporan", ds.Tables["DataTableLaporan"]);
                reportViewer1.LocalReport.DataSources.Add(rptDS);
                reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                reportViewer1.ZoomMode    = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
            }
            catch (Exception ex)
            {
                //MsgBox(ex.Message)
            }
        }