Ejemplo n.º 1
0
        private void RebindItems() {
            string query = "SELECT *, (CASE WHEN(kondisi_alat = 1) THEN \"Baik\" ELSE \"Rusak\" END) as kondisi FROM inventory JOIN master_inventory_type ON inventralalab.inventory.id_jenis = inventralalab.master_inventory_type.id";
            try {
                using (MySqlCommand cmd = new MySqlCommand(query, db.ConnectionManager.Connection)) {
                    using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmd)) {
                        DataTable dataTable = new DataTable();
                        dataAdapter.Fill(dataTable);

                        items = new List<Alat>();
                        foreach (DataRow row in dataTable.Rows) {
                            Alat alat = new Alat(
                                (string)row["id"],
                                (string)row["id_jenis"],
                                (string)row["nama"],
                                (bool)row["kondisi_alat"],
                                (string)row["lokasi"]
                                );
                            items.Add(alat);
                        }
                        listBox_Alat.ItemsSource = items;
                    }
                }
            }
            catch (MySqlException ex) {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public EditAlat(Alat alat)
        {
            InitializeComponent();
            this.alat = alat;

            status = new List<KV>();
            status.Add(new KV("Baik", 1));
            status.Add(new KV("Rusak", 0));
            comboBox_Status.ItemsSource = status;
            comboBox_Status.DisplayMemberPath = "Key";
            comboBox_Status.SelectedValuePath = "Value";
            comboBox_Status.SelectedValue = (alat.KondisiAlat) ? 1 : 0;

            textbox_Laboratorium.Text = alat.Lokasi;

            string query = "SELECT * FROM master_inventory_type";
            using (MySqlCommand cmd = new MySqlCommand(query, db.ConnectionManager.Connection)) {
                try {
                    DataTable dataSet = new DataTable();
                    using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmd)) {
                        dataAdapter.Fill(dataSet);
                        comboBox_Jenis_Barang.ItemsSource = dataSet.DefaultView;
                        comboBox_Jenis_Barang.DisplayMemberPath = dataSet.Columns["nama"].ToString();
                        comboBox_Jenis_Barang.SelectedValuePath = dataSet.Columns["id"].ToString();
                        comboBox_Jenis_Barang.SelectedValue = alat.IdJenis;
                    }
                }
                catch (MySql.Data.MySqlClient.MySqlException ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 3
0
        private void RebindItems() {
            string query = "SELECT * FROM inventory JOIN borrowers ON inventralalab.inventory.id_peminjam = inventralalab.borrowers.id WHERE id_peminjam IS NOT NULL";
            try {
                using (MySqlCommand cmd = new MySqlCommand(query, db.ConnectionManager.Connection)) {
                    using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmd)) {
                        DataTable dataTable = new DataTable();
                        dataAdapter.Fill(dataTable);

                        items = new List<Alat>();
                        foreach (DataRow row in dataTable.Rows) {
                            Alat alat = new Alat(
                                (string)row["id"],
                                (string)row["nama"],
                                (DateTime?)row["tanggal_mulai"],
                                (DateTime?)row["tanggal_selesai"],
                                (bool)row["kondisi_alat"],
                                (string)row["lokasi"]
                                );
                            items.Add(alat);
                        }
                        listbox_Peminjam.ItemsSource = dataTable.DefaultView;
                    }
                }
            }
            catch (MySqlException ex) {
                MessageBox.Show(ex.Message);
            }
        }