private void cbbSanNiemYet_SelectedIndexChanged(object sender, EventArgs e) { SanGiaoDich exch = cbbSanNiemYet.SelectedItem as SanGiaoDich; btnDelExchange.Enabled = btnEditExchange.Enabled = (exch != null && exch.ID > 0); btnAddStock.Enabled = btnUpdateStock.Enabled = true; }
private void btnEditExchange_Click(object sender, EventArgs e) { SanGiaoDich exch = cbbSanNiemYet.SelectedItem as SanGiaoDich; ExchangesManager form = new ExchangesManager(exch); if (form.ShowDialog() != DialogResult.OK) { return; } else { InitExchangesList(); } }
private void InitExchangesList() { Settings.DanhSachSanGiaoDich.Clear(); if (null != Settings.DBConnection && Settings.DBConnection.State == ConnectionState.Open) { var cmd = new SQLiteCommand("SELECT * FROM San ORDER BY ID", Settings.DBConnection); SQLiteDataReader reader = cmd.ExecuteReader(); int ID = 0; string code = string.Empty; string name = string.Empty; string website = string.Empty; while (reader.Read()) { ID = reader.GetInt32(0); code = reader.GetString(1); try { name = reader.GetString(2); } catch (Exception ex) { Debug.Print(ex.Message); name = string.Empty; } try { website = reader.GetString(3); } catch (Exception ex) { Debug.Print(ex.Message); website = string.Empty; } SanGiaoDich exch = new SanGiaoDich(); exch.ID = ID; exch.MaSan = code; exch.TenSan = name; exch.TrangWeb = website; Settings.DanhSachSanGiaoDich.Add(exch); } } Settings.DanhSachSanGiaoDich.Insert(0, new SanGiaoDich(0, "---")); }
public ExchangesManager(SanGiaoDich exch) { InitializeComponent(); Exchange = exch; }