Полезное:
Как сделать разговор полезным и приятным
Как сделать объемную звезду своими руками
Как сделать то, что делать не хочется?
Как сделать погремушку
Как сделать так чтобы женщины сами знакомились с вами
Как сделать идею коммерческой
Как сделать хорошую растяжку ног?
Как сделать наш разум здоровым?
Как сделать, чтобы люди обманывали меньше
Вопрос 4. Как сделать так, чтобы вас уважали и ценили?
Как сделать лучше себе и другим людям
Как сделать свидание интересным?
Категории:
АрхитектураАстрономияБиологияГеографияГеологияИнформатикаИскусствоИсторияКулинарияКультураМаркетингМатематикаМедицинаМенеджментОхрана трудаПравоПроизводствоПсихологияРелигияСоциологияСпортТехникаФизикаФилософияХимияЭкологияЭкономикаЭлектроника
|
Приложение 1. using System.Collections.Generic; ⇐ ПредыдущаяСтр 5 из 5 Авторизация using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; using System.Windows.Forms;
namespace WindowsFormsApplication2 { public partial class avtoriza: Form { public avtoriza() { InitializeComponent(); } OleDbDataAdapter adapter = new OleDbDataAdapter(); OleDbCommand command = new OleDbCommand(); OleDbConnection connect = new OleDbConnection(); DataSet dataset = new DataSet(); List<User> users = new List<User>();
private void avtoriza_Load(object sender, EventArgs e) {
connect.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"Users.mdb" + ";Persist Security Info=False;"; connect.Open(); command.CommandText = "Select * from Users"; command.Connection = connect; adapter.SelectCommand = command; dataset.Reset(); adapter.Fill(dataset); connect.Close(); for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) { User us = new User(); us.Login = dataset.Tables[0].Rows[i][1].ToString(); us.Password = dataset.Tables[0].Rows[i][2].ToString(); us.Level = (int)dataset.Tables[0].Rows[i][3]; users.Add(us); } } private void button1_Click(object sender, EventArgs e) {
for (int i = 0; i < users.Count; i++) { if (tb_user.Text == users[i].Login) {
if (tb_password.Text == users[i].Password) {
goroskop goroskop = new goroskop (this, users[i]); goroskop.Show(); this.Hide();
} else MessageBox.Show("Неверный пароль"); } } } private void avtoriza_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) button1.PerformClick(); }
private void avtoriza_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(); } } }
Таблицы using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace WindowsFormsApplication2 { public partial class goroskop: Form { avtoriza _auto; User _user; redaktor _red; public goroskop(avtoriza auto, User user) { _auto = auto; _user = user; InitializeComponent(); } public goroskop(redaktor red, User user) { _user = user; _red = red; InitializeComponent(); }
OleDbDataAdapter adapter = new OleDbDataAdapter(); OleDbCommand command = new OleDbCommand(); OleDbDataAdapter adapter1 = new OleDbDataAdapter(); OleDbCommand command1 = new OleDbCommand(); OleDbDataAdapter adapter2 = new OleDbDataAdapter(); OleDbCommand command2 = new OleDbCommand(); OleDbDataAdapter adapter3 = new OleDbDataAdapter(); OleDbCommand command3 = new OleDbCommand(); OleDbConnection connect = new OleDbConnection(); DataSet dataset = new DataSet(); List<User> users = new List<User>(); List<Prognoz> prognoz = new List<Prognoz>(); private void Form1_Load(object sender, EventArgs e) { connect.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"Users.mdb" + ";Persist Security Info=False;";
connect.Open();
command.CommandText = "Select * from Users"; command.Connection = connect; adapter.SelectCommand = command; adapter.TableMappings.Add("Table", "Users");
command1.CommandText = "Select * from magazins"; command1.Connection = connect; adapter1.SelectCommand = command1; adapter1.TableMappings.Add("Table", "magazins");
command2.CommandText = "Select * from produkts"; command2.Connection = connect; adapter2.SelectCommand = command2; adapter2.TableMappings.Add("Table", "produkts");
command3.CommandText = "Select * from person"; command3.Connection = connect; adapter3.SelectCommand = command3; adapter3.TableMappings.Add("Table", "person");
adapter.Fill(dataset); adapter1.Fill(dataset); adapter2.Fill(dataset); adapter3.Fill(dataset);
connect.Close();
}
private void b_last_Click(object sender, EventArgs e) { avtoriza avtoriza = new avtoriza(); avtoriza.Show(); this.Hide(); } private void b_prev_Click(object sender, EventArgs e) {
{ if (_user.Login.ToString() == "admin") { redaktor redaktor = new redaktor(this, _user); redaktor.Show(); this.Hide(); } else MessageBox.Show("Сасямба"); } }
private void goroskop_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(); }
private void button1_Click(object sender, EventArgs e) { if (cb_table.Text == "Магазины") dgv.DataSource = dataset.Tables[1].DefaultView; else if (cb_table.Text == "Продукция") dgv.DataSource = dataset.Tables[2].DefaultView; else if (cb_table.Text == "Персонал") dgv.DataSource = dataset.Tables[3].DefaultView; }
}
}
Редактирование using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace WindowsFormsApplication2 { public partial class redaktor: Form {
avtoriza _auto; User _user; goroskop _gor; public redaktor(avtoriza auto) { _auto = auto;
InitializeComponent(); }
OleDbDataAdapter adapter = new OleDbDataAdapter(); OleDbCommand command = new OleDbCommand(); OleDbDataAdapter adapter1 = new OleDbDataAdapter(); OleDbCommand command1 = new OleDbCommand(); OleDbDataAdapter adapter2 = new OleDbDataAdapter(); OleDbCommand command2 = new OleDbCommand(); OleDbConnection connect = new OleDbConnection(); DataSet ds = new DataSet();
public redaktor(goroskop gor, User user) { _gor = gor; _user = user; InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) {
connect.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"Users.mdb" + ";Persist Security Info=False;";
connect.Open();
command.CommandText = "Select * from magazins"; command.Connection = connect; adapter.SelectCommand = command; adapter.TableMappings.Add("Table", "magazins"); OleDbCommandBuilder bulder = new OleDbCommandBuilder(adapter); adapter.UpdateCommand = bulder.GetUpdateCommand(); adapter.InsertCommand = bulder.GetInsertCommand(); adapter.DeleteCommand = bulder.GetDeleteCommand(); adapter.Fill(ds);
command1.CommandText = "Select * from produkts"; command1.Connection = connect; adapter1.SelectCommand = command1; adapter1.TableMappings.Add("Table", "produkts"); OleDbCommandBuilder bulder1 = new OleDbCommandBuilder(adapter1); adapter1.UpdateCommand = bulder1.GetUpdateCommand(); adapter1.InsertCommand = bulder1.GetInsertCommand(); adapter1.DeleteCommand = bulder1.GetDeleteCommand(); adapter1.Fill(ds);
command2.CommandText = "Select * from person"; command2.Connection = connect; adapter2.SelectCommand = command2; adapter2.TableMappings.Add("Table", "person"); OleDbCommandBuilder bulder2 = new OleDbCommandBuilder(adapter); adapter2.UpdateCommand = bulder2.GetUpdateCommand(); adapter2.InsertCommand = bulder2.GetInsertCommand(); adapter2.DeleteCommand = bulder2.GetDeleteCommand(); adapter2.Fill(ds);
} private void b_save_Click(object sender, EventArgs e) { adapter = null; adapter.Update(ds.Tables[0]); ds.Clear(); adapter.Fill(ds.Tables[0]); MessageBox.Show("База обновлена успешно!");
adapter1 = null; adapter1.Update(ds.Tables[1]); ds.Clear(); adapter1.Fill(ds.Tables[1]); MessageBox.Show("База обновлена успешно!");
adapter2 = null; adapter2.Update(ds.Tables[2]); ds.Clear(); adapter2.Fill(ds.Tables[2]); MessageBox.Show("База обновлена успешно!"); } private void b_last_Click(object sender, EventArgs e) { if (_user.Login.ToString() == "admin") { goroskop goroskop = new goroskop(this, _user); goroskop.Show(); this.Hide(); } }
private void redaktor_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(); } private void button1_Click(object sender, EventArgs e) { if (cb_table.Text == "Магазины") dgv.DataSource = ds.Tables[0].DefaultView; else if (cb_table.Text == "Продукция") dgv.DataSource = ds.Tables[1].DefaultView; else if (cb_table.Text == "Персонал") dgv.DataSource = ds.Tables[2].DefaultView; } } }
|