private void Des1_SelectedIndexChanged(object sender, EventArgs e) { AccessDB aa = new AccessDB(); aa.Dic_in.Add(Des1.Tag.ToString(), Des1.Text); Des2.DataSource = aa.GetData(aa.Dic_in, table.Text, Des2.Tag.ToString());//data source accept list }
private void MasterpactNW_Load(object sender, EventArgs e) { AccessDB aa = new AccessDB(); List <string> colomn_name; colomn_name = aa.GetTableColumnNames(table.Text); Des1.Tag = colomn_name[1]; Des2.Tag = colomn_name[2]; Des3.Tag = colomn_name[3]; Des4.Tag = colomn_name[4]; Des5.Tag = colomn_name[5]; Des6.Tag = colomn_name[6]; Des7.Tag = colomn_name[7]; Des8.Tag = colomn_name[8]; Des9.Tag = colomn_name[9]; Des10.Tag = colomn_name[10]; Des11.Tag = colomn_name[11]; Des12.Tag = colomn_name[12]; Ref1.Tag = colomn_name[13]; Ref2.Tag = colomn_name[13]; Ref3.Tag = colomn_name[13]; Des1.DataSource = aa.GetData(aa.Dic_in, table.Text, Des1.Tag.ToString()); //data source accept list Des7.DataSource = aa.GetData(aa.Dic_in, table.Text, Des7.Tag.ToString()); //data source accept list Des10.DataSource = aa.GetData(aa.Dic_in, table.Text, Des10.Tag.ToString()); //data source accept list }
private void ControlAuxiliaries_Load(object sender, EventArgs e) { AccessDB aa = new AccessDB(); List <string> colomn_name; colomn_name = aa.GetTableColumnNames(table.Text); Des1.Tag = colomn_name[1]; Des2.Tag = colomn_name[2]; Des3.Tag = colomn_name[3]; Note1.Tag = colomn_name[4]; Note2.Tag = colomn_name[5]; Ref1.Tag = colomn_name[6]; Des1.DataSource = aa.GetData(aa.Dic_in, table.Text, Des1.Tag.ToString());//data source accept list }
private void Des15_SelectedIndexChanged(object sender, EventArgs e) { AccessDB aa = new AccessDB(); aa.Dic_in.Add(Des14.Tag.ToString(), Des14.Text); aa.Dic_in.Add(Des15.Tag.ToString(), Des15.Text); if (Des15.SelectedIndex > 0) { Ref5.Text = aa.GetData(aa.Dic_in, table.Text, Ref5.Tag.ToString())[1]; } else { Ref5.Text = ""; } }
private void URL_Test_Click(object sender, EventArgs e) { //link exist let's check if it works string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + URL_Link.Text + Properties.Settings.Default.password; //check if we can access remote DB int remote_version = AccessDB.version_num(connectionString); if (remote_version < 0) { URL_Note.Text = "Not Valid Link to database"; } else { URL_Note.Text = "Valid Link to database, and Database index= " + remote_version.ToString(); } }
private void Des2_SelectedIndexChanged(object sender, EventArgs e) { AccessDB aa = new AccessDB(); aa.Dic_in.Add(Des1.Tag.ToString(), Des1.Text); aa.Dic_in.Add(Des2.Tag.ToString(), Des2.Text); //description.DataSource = aa.GetData(aa.Dic_in, table.Text, description.Name);//data source accept list if (Des2.SelectedIndex > 0) { Ref1.Text = aa.GetData(aa.Dic_in, table.Text, Ref1.Tag.ToString())[1]; } else { Ref1.Text = ""; } }
private void Des5_SelectedIndexChanged(object sender, EventArgs e) { AccessDB aa = new AccessDB(); aa.Dic_in.Add(Des4.Tag.ToString(), Des4.Text); aa.Dic_in.Add(Des5.Tag.ToString(), Des5.Text); if (Des5.SelectedIndex > 0) { Ref2.Text = aa.GetData(aa.Dic_in, table.Text, Ref2.Tag.ToString())[1]; Des6.Text = aa.GetData(aa.Dic_in, table.Text, Des6.Tag.ToString())[1];//data source accept list } else { Ref2.Text = ""; Des6.Text = ""; } }
private void Des3_SelectedIndexChanged_1(object sender, EventArgs e) { AccessDB aa = new AccessDB(); aa.Dic_in.Add(Des1.Tag.ToString(), Des1.Text); aa.Dic_in.Add(Des2.Tag.ToString(), Des2.Text); aa.Dic_in.Add(Des3.Tag.ToString(), Des3.Text); if (Des3.SelectedIndex > 0) { Ref1.Text = aa.GetData(aa.Dic_in, table.Text, Ref1.Tag.ToString())[1]; Note1.Text = aa.GetData(aa.Dic_in, table.Text, Note1.Tag.ToString())[1]; Note2.Text = aa.GetData(aa.Dic_in, table.Text, Note2.Tag.ToString())[1]; } else { Ref1.Text = ""; Note1.Text = ""; Note2.Text = ""; } }
private void VigilohmCables_Load(object sender, EventArgs e) { AccessDB aa = new AccessDB(); List <string> colomn_name; colomn_name = aa.GetTableColumnNames(table.Text); Des1.Tag = colomn_name[1]; Des2.Tag = colomn_name[2]; Des3.Tag = colomn_name[3]; Des4.Tag = colomn_name[4]; Des5.Tag = colomn_name[5]; Des6.Tag = colomn_name[6]; Ref1.Tag = colomn_name[7]; Ref2.Tag = colomn_name[7]; Ref3.Tag = colomn_name[7]; Des1.DataSource = aa.GetData(aa.Dic_in, table.Text, Des1.Tag.ToString()); //data source accept list Des3.DataSource = aa.GetData(aa.Dic_in, table.Text, Des3.Tag.ToString()); //data source accept list Des5.DataSource = aa.GetData(aa.Dic_in, table.Text, Des5.Tag.ToString()); //data source accept list }
int check_DB() { //here i should test if local db exist by check its index int current_version; int remote_version; //below function will return -1 in case of error current_version = AccessDB.version_num(Properties.Settings.Default.LocalDB); if (current_version < 0) { //check if no link to remote DB exist if (Properties.Settings.Default.Remote_file == "") { //call DB_location form with close status DB_Location.status = "close"; DB_Location.comment = "Local Database is not exist, and no valid link to remote database. Note if you press cancel or close this window application will automatically close."; DB_Location DB_loc = new DB_Location(); DB_loc.ShowDialog(); if (DB_Location.app_close == 1) { return(3); } return(1); } else { string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Properties.Settings.Default.Remote_file + Properties.Settings.Default.password; //check if we can access remote DB remote_version = AccessDB.version_num(connectionString); if (remote_version < 0) { //not valid link DB_Location.status = "close"; DB_Location.comment = "Local Database is not exist, and current link to remote database is not valid. Note if you press cancel or close this window application will automatically close."; DB_Location DB_loc = new DB_Location(); DB_loc.ShowDialog(); if (DB_Location.app_close == 1) { return(3); } return(1); } else { //here i should copy remote database to local directory. string local_file = Application.StartupPath + "\\SMB.accdb"; string remote_file = Properties.Settings.Default.Remote_file; try { File.Copy(remote_file, local_file, true); } catch (Exception) { //incase of error in copying aplication should close MessageBox.Show("Error happen while updating local Database, Please make sure you run this application as adminstrator"); this.Close(); } DB_index.Text = remote_version.ToString(); DB_status.Text = "Online"; MessageBox.Show("DataBase update to index: " + remote_version.ToString()); return(0); } } } else { //if local database exist,check if link exist if (Properties.Settings.Default.Remote_file == "") { DB_status.Text = "Offline"; DB_index.Text = current_version.ToString(); MessageBox.Show("No valid link for remote DB, Please update link from (DB Location) Button below. You now can work with local database, but it may be not the last update!!"); return(0); } else { //link exist let's check if it works string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Properties.Settings.Default.Remote_file + Properties.Settings.Default.password; //check if we can access remote DB remote_version = AccessDB.version_num(connectionString); if (remote_version < 0) { DB_status.Text = "Offline"; DB_index.Text = current_version.ToString(); MessageBox.Show("error in connection to Database, Please update link from (DB Location) button below or check your network connection. You now can work with local database, but it may be not the last update!!"); return(0); } else { //here local DB exist and remote DB exist //lets validate if (remote_version > current_version) { //here should replace local database string local_file = Application.StartupPath + "\\SMB.accdb"; string remote_file = Properties.Settings.Default.Remote_file; try { File.Delete(local_file); File.Copy(remote_file, local_file, true); } catch (Exception) { MessageBox.Show("Error happen while updating local Database, Please make sure you run this application as adminstrator"); this.Close(); } MessageBox.Show("DataBase update From index: " + current_version.ToString() + " to index: " + remote_version.ToString()); DB_index.Text = remote_version.ToString(); DB_status.Text = "Online"; return(0); } else { DB_index.Text = remote_version.ToString(); DB_status.Text = "Online"; return(0); } } } } }