Esempio n. 1
0
        private void btn_cari_Click(object sender, EventArgs e)
        {
            var db       = Model.Database.Instance;
            var query    = txt_cari.Text;
            var category = cb_jenis.SelectedItem.ToString();
            IEnumerable <Model.Obat> result;

            if (category == "Kode")
            {
                //kalau ini pakai Like bisa ko ndre? jadi kode like query
                result = db.Query2 <Model.Obat>().Where(db.Column("Kode") == query).Execute();
            }
            else if (category == "Nama")
            {
                //kalau ini pakai Like bisa ko ndre? jadi kode like query
                result = db.Query2 <Model.Obat>().Where(db.Column("Nama") == query).Execute();
            }
            else
            {
                MessageBox.Show("Tidak dapat menemukan obat.");
                return;
            }

            obat = result.FirstOrDefault();

            if (obat != null)
            {
                txt_kode.DataBindings.Clear();
                txt_kode.DataBindings.Clear();
                txt_nama.DataBindings.Clear();
                cmb_satuan.DataBindings.Clear();
                txt_stok.DataBindings.Clear();
                txt_harga.DataBindings.Clear();
                txt_ket.DataBindings.Clear();

                txt_kode.DataBindings.Add("Text", obat, "Kode");
                txt_nama.DataBindings.Add("Text", obat, "Nama");
                cmb_satuan.DataBindings.Add("Text", obat, "Satuan");
                txt_stok.DataBindings.Add("Text", obat, "Stok");
                txt_harga.DataBindings.Add("Text", obat, "Harga");
                txt_ket.DataBindings.Add("Text", obat, "Keterangan");
            }
            else
            {
                txt_kode.DataBindings.Clear();
                txt_kode.DataBindings.Clear();
                txt_nama.DataBindings.Clear();
                cmb_satuan.DataBindings.Clear();
                txt_stok.DataBindings.Clear();
                txt_harga.DataBindings.Clear();
                txt_ket.DataBindings.Clear();
            }
        }
Esempio n. 2
0
        public tambah(Controller controller, Model.Obat obat = null)
        {
            this.controller = controller;

            InitializeComponent();

            if (obat != null)
            {
                model = obat;
            }
            else
            {
                model = new Model.Obat();
            }

            txt_kode.DataBindings.Add("Text", model, "Kode");
            txt_nama.DataBindings.Add("Text", model, "Nama");
            cmb_satuan.DataBindings.Add("Text", model, "Satuan");
            txt_stok.DataBindings.Add("Text", model, "Stok");
            txt_harga.DataBindings.Add("Text", model, "Harga");
            txt_ket.DataBindings.Add("Text", model, "Keterangan");
        }