Esempio n. 1
0
        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);
                    if (pnContent.Children.Count > 0)
                    {
                        UpdateDataWindow w = (UpdateDataWindow)pnContent.Children[0];
                        w.loadData(0);
                    }
                }
                else
                {
                    MessageBox.Show("Lỗi kết nối");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi kết nối");
            }
        }