Дипломная работа: Автоматизация учёта посещений клиентов в ООО "ТехноКом"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
81
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApp5
{
public partial class Auth : Form
{
OleDbConnection connection = new OleDbConnection();
public Auth()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void btn_Login_Click(object sender, EventArgs e)
{
connection.ConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database3.accdb;Persist Security
Info=False";
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
82
command.CommandText = "select * from Пользователи where Логин='" +
txt_Login.Text + "' and Пароль='" + txt_Password.Text + "'";
OleDbDataReader reader = command.ExecuteReader();
int count = 0;
while (reader.Read())
{
count = count + 1;
}
reader.Close();
if (count == 1)
{
connection.Close();
connection.Dispose();
this.Hide();
if (txt_Login.Text == "admin")
{
Form f2 = new SelectDB();
f2.ShowDialog();
}
else
{
Form f3 = new Form6();
f3.ShowDialog();
}
}
else if (count > 1)
{
MessageBox.Show("Ошибка! Дублируется учетная запись");
connection.Close();
connection.Dispose();
}
else
{
MessageBox.Show("Ошибка! Учетной записи не существует!");
connection.Close();
83
connection.Dispose();
}
}
}
}
//Form1.cs
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.OleDb;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
OleDbConnection connection = new OleDbConnection();
public Form1()
{
InitializeComponent();
connection.ConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database3.accdb";
}
private void Form1_Load(object sender, EventArgs e)
{
}
84
private void button1_Click(object sender, EventArgs e)
{
try
{
double prib = 0;
double activ = 0;
double real = 0;
double real_exp = 0;
UInt64 vneob = 0;
double ob = 0;
double KapRez = 0;
double dOb = 0;
double kOb = 0;
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "select * from ТЭП where Год='" +
textBox6.Text + "'";
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
prib = Convert.ToDouble(reader["Прибыль"]);
activ = Convert.ToDouble(reader["Активы"]);
real = Convert.ToDouble(reader["Реализация"]);
real_exp = Convert.ToDouble(reader["РеалЭкспорт"]);
}
connection.Close();
connection.Open();
command.Connection = connection;
85
command.CommandText = "select * from Активы where Год='" +
textBox6.Text + "'";
reader = command.ExecuteReader();
while (reader.Read())
{
vneob = Convert.ToUInt64(reader["Внеоб"]);
ob = Convert.ToDouble(reader["Об"]);
}
connection.Close();
connection.Open();
command.Connection = connection;
command.CommandText = "select * from Пассив where Год='" +
textBox6.Text + "'";
reader = command.ExecuteReader();
while (reader.Read())
{
KapRez = Convert.ToDouble(reader["КапРез"]);
dOb = Convert.ToDouble(reader["ДОб"]);
kOb = Convert.ToDouble(reader["КОб"]);
}
connection.Close();
textBox1.Text = Convert.ToString(prib / activ);
textBox2.Text = Convert.ToString(prib/(real+real_exp));
textBox3.Text = Convert.ToString(prib / KapRez);
textBox4.Text = Convert.ToString(prib / ob);
textBox5.Text = Convert.ToString(prib / (ob-kOb));
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
Источник: https://baza.diplomsite.ru/previewfile/2482