示例#1
0
        private void simpan_button1_Click(object sender, EventArgs e)
        {
            modelItem.stok            = Convert.ToInt32(tambah_numericUpDown1.Value);
            db.Entry(modelItem).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            MessageBox.Show("Stok berhasil ditambahkan sejumlah " + tambah_numericUpDown1.Value + " menjadi " + modelItem.stok);
            Clear();

            PopulateDataGridView();
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            modelReturn.transaksi_id       = modelTransaksi.id;
            modelReturn.item_id            = modelItem.id;
            modelReturn.tanggal_return     = tanggal_return_dateTimePicker1.Value;
            modelReturn.status_return      = status_return_comboBox1.Text;
            modelReturn.keterangan         = keterangan_inputan_richTextBox2.Text;
            modelReturn.alasan_return      = alasan_return_richTextBox3.Text;
            modelReturn.qty                = Convert.ToInt32(qty_numericUpDown1.Value);
            modelReturn.harga_satuan_temp  = modelTransaksi.harga_satuan_temp;
            modelReturn.total_harga        = modelTransaksi.total_harga;
            modelReturn.total_bayar_return = Convert.ToInt32(harga_total_inputan_textBox5.Text);

            db.returns.Add(modelReturn);
            db.SaveChanges();
            Clear();
            MessageBox.Show("Data Berhasil Ditambahkan.");

            PopulateDataGridView();
        }
示例#3
0
        private void delete_button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Anda yakin ingin menghapus data ini?", "EF CRUD Operation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (dibumilaptopEntities db = new dibumilaptopEntities())
                {
                    var entry = db.Entry(model);
                    if (entry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.items.Attach(model);
                    }

                    db.items.Remove(model);
                    db.SaveChanges();
                    PopulateDataGridView();
                    Clear();
                    MessageBox.Show("Berhasil Menghapus.");
                }
            }
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            modelTransaksi.item_id           = modelItem.id;
            modelTransaksi.tanggal_transaksi = tanggal_transaksi_dateTimePicker1.Value;
            modelTransaksi.qty = Convert.ToInt32(qty_numericUpDown1.Value);
            modelTransaksi.harga_satuan_temp = Convert.ToInt32(harga_satuan_textBox1.Text);
            modelTransaksi.total_harga       = Convert.ToInt32(harga_total_textbox.Text);
            modelTransaksi.deskripsi         = keterangan_richTextBox1.Text;

            using (dibumilaptopEntities db = new dibumilaptopEntities())
            {
                db.transaksis.Add(modelTransaksi);

                modelItem.stok            = modelItem.stok - modelTransaksi.qty;
                db.Entry(modelItem).State = System.Data.Entity.EntityState.Modified;

                db.SaveChanges();
                MessageBox.Show("Transaksi Berhasil Ditambahkan");

                Clear();
            }
        }
示例#5
0
        private void simpan_button1_Click(object sender, EventArgs e)
        {
            model.merek_id            = Convert.ToInt64(merek_comboBox1.SelectedValue);
            model.tipe                = tipe_textBox1.Text;
            model.deskripsi           = deskripsi_richTextBox1.Text;
            model.processor           = processor_textBox2.Text;
            model.ram                 = ram_textBox3.Text;
            model.penyimpanan         = penyimpanan_textBox4.Text;
            model.ukuran_layar        = ukuran_layar_textBox5.Text;
            model.stok                = Convert.ToInt32(stok_numericUpDown1.Value);
            model.gudang_id           = Convert.ToInt64(lokasi_gudang_comboBox2.SelectedValue);
            model.kondisi_id          = Convert.ToInt64(kondisi_comboBox3.SelectedValue);
            model.tanggal_ditambahkan = tanggal_ditambahkan_dateTimePicker1.Value;
            model.garansi_id          = Convert.ToInt64(jenis_garansi_comboBox4.SelectedValue);
            model.garansi_expired     = garansi_expired_dateTimePicker2.Value;
            model.harga               = Convert.ToInt64(harga_numericUpDown1.Value);

            using (dibumilaptopEntities db = new dibumilaptopEntities())
            {
                if (model.id == 0)
                {
                    db.items.Add(model);

                    MessageBox.Show("Data berhasil ditambahkan");
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;

                    MessageBox.Show("Data berhasil diupdate");
                }
                db.SaveChanges();
            }
            Clear();
            PopulateDataGridView();
        }