public EditBus(MongoTools database, string collectionName, ObjectId id) { this.database = database; this.collectionName = collectionName; this.id = id; InitializeComponent(); }
static public MongoTools Login(string login, string pwd) { var connectionString = $"mongodb://{login}:{pwd}@94.230.138.242:49563/?authSource=bus_depot"; const string databaseName = "bus_depot"; MongoTools database = new MongoTools(connectionString, databaseName); return(database); }
public MainForm(MongoTools database) { this.database = database; InitializeComponent(); if (!MongoTools.isAdmin) { AddNewElementBtn.Visible = false; deleteSelectedBtn.Visible = false; editSelectBtn.Visible = false; } // Some style this.Table.RowsDefaultCellStyle.BackColor = Color.Gainsboro; this.Table.AlternatingRowsDefaultCellStyle.BackColor = Color.Snow; this.Table.ColumnHeadersDefaultCellStyle.BackColor = Color.White; this.Table.EnableHeadersVisualStyles = false; }
private void loginBtn_Click(object sender, EventArgs e) { string login = loginInput.Text; string pwd = pwdInput.Text; MongoTools database = Program.Login(login, pwd); if (MongoTools.isConnect) { if (login == "admin") { MongoTools.isAdmin = true; } MainForm mainForm = new MainForm(database); mainForm.Show(); this.Hide(); } else { loginBtn.ForeColor = Color.FromName("red"); loginBtn.Text = "Неверный логин или пароль. Попробуйте снова!"; } }
public AddRoute(MongoTools database) { this.database = database; InitializeComponent(); }