12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace project
- {
- public partial class Main : Form
- {
- public static string login;
- DataBase dataBase = new DataBase();
- public Main()
- {
- InitializeComponent();
- }
- private void ReadSingleRow(DataGridView dgw, IDataRecord record)
- {
- dgw.Rows.Add(record.GetInt32(0), record.GetString(1), record.GetString(2), record.GetString(3), record.GetString(4), record.GetString(5));
- }
- private void RefresDataGird(DataGridView dgw)
- {
- dgw.Rows.Clear();
- string queryString = $"Select * from Dannye";
- SqlCommand command = new SqlCommand(queryString, dataBase.GetConnection());
- dataBase.openConnection();
- SqlDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- ReadSingleRow(dgw, reader);
- }
- reader.Close();
- }
- private void CreateColumns()
- {
- dataGridView1.Columns.Add("code", "Номер");
- dataGridView1.Columns.Add("name_dan", "Наименование");
- dataGridView1.Columns.Add("adres_dan", "Адрес");
- dataGridView1.Columns.Add("city_dan", "Город");
- dataGridView1.Columns.Add("number_dan", "Телефон");
- dataGridView1.Columns.Add("contact_dan", "Контактная информация");
- }
- private void Main_FormClosed(object sender, FormClosedEventArgs e)
- {
- Application.Exit();
- }
- private void Main_Load(object sender, EventArgs e)
- {
- CreateColumns();
- RefresDataGird(dataGridView1);
- string proverkaLogin = Login.login;
- dataBase.openConnection();
- SqlCommand sqlCommand2 = new SqlCommand($"SELECT administrator From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
- string admPolzovatel = sqlCommand2.ExecuteScalar().ToString();
- if (admPolzovatel.Trim() == "true")
- {
- button1.Visible = true;
- button2.Visible = true;
- }
- }
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- Profile profile = new Profile();
- profile.Show();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
-
- }
- }
- }
|