private void cbxCN_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox cbxCN = (ComboBox)sender; QLVTDataSet.V_CNDataTable cn = (QLVTDataSet.V_CNDataTable)Common.ChiNhanhInfo; DataRow[] rows = cn.Select("ChiNhanhId =" + (int)cbxCN.SelectedValue); string sv = (string)rows[0]["subscriber_server"]; Common.CurrentChiNhanh = sv; Common.CurrentChiNhanhId = cbxCN.SelectedValue; Common.CurrentCNName = ((DataRowView)cbxCN.SelectedItem).Row["Ten"].ToString(); Common.Database = (Common.GetDatabase0); Common.Server = ((string)Common.CurrentChiNhanh); Common.Userid = (Common.GetUserid0); Common.Password = (Common.GetPassword0); string connectionString = Common.buildConnectionString(); try { if (Common.IsServerConnected(connectionString)) { Common.connection = new SqlConnection(connectionString); } else { MessageBox.Show("Lỗi kết nối"); } } catch (Exception ex) { MessageBox.Show("Lỗi kết nối"); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { QLVTDataSet.V_CNDataTable cn = (QLVTDataSet.V_CNDataTable)Common.ChiNhanhInfo; DataRow[] rows = cn.Select("ChiNhanhId =" + (int)value); return(rows[0]["Ten"]); }
public MainWindow() { InitializeComponent(); QLVTDataSet.V_CNDataTable v_CNs = new QLVTDataSet.V_CNDataTable(); QLVTDataSetTableAdapters.V_CNTableAdapter v_CNTableAdapter = new QLVTDataSetTableAdapters.V_CNTableAdapter(); v_CNTableAdapter.Connection.ConnectionString = Common.getDefaultConnectionString(); v_CNTableAdapter.Fill(v_CNs); cbxCN.ItemsSource = v_CNs; Common.ChiNhanhInfo = v_CNs; cbxCN.DisplayMemberPath = "Ten"; cbxCN.SelectedValuePath = "ChiNhanhId"; cbxCN.SelectedIndex = 0; this.DataContext = new ViewModel(); }