Program.cs>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProektChashkina
{
static class Program
{
///
/// Главная точка входа для приложения.
///
[STAThread]
static void Main()
{Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginForm());}
}
}
DB.cs>>
namespace ProektChashkina
{
class DB
{
SqlConnection connection = new SqlConnection(@"Data Source=DESKTOP-0UOMSRH\SQLEXPRESS;
Initial Catalog=PP;Integrated Security=True");
public void openConnection()
{
if (connection.State == System.Data.ConnectionState.Closed)
connection.Open();
}
public void closeConnection()
{
if (connection.State == System.Data.ConnectionState.Open)
connection.Close();
}
public SqlConnection getConnection() {
return connection; }
}
}
LoginForm>>
namespace ProektChashkina
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
private void CloseButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
Point LastPoint;
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left) {
this.Left += e.X - LastPoint.X;
this.Top += e.Y - LastPoint.Y;
}
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
LastPoint = new Point(e.X, e.Y);
}
private void LoginButton_Click(object sender, EventArgs e)
{
String loginUser = LoginTextBox.Text;
String passUser = PasswordTextBox.Text;
DB db = new DB();
DataTable table = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand command = new SqlCommand("SELECT * FROM Users " +
"WHERE login=@uL AND password=@uP",db.getConnection());
command.Parameters.Add("@uL",SqlDbType.VarChar).Value=loginUser;
command.Parameters.Add("@uP", SqlDbType.VarChar).Value = passUser;
adapter.SelectCommand = command;
adapter.Fill(table);
if (table.Rows.Count > 0)
{
this.Hide();
MessageBox.Show("Добро пожаловать! Вы успешно вошли с систему.");
MainForm mainForm = new MainForm();
mainForm.Show();
}
else
MessageBox.Show("Неверный логин или пароль.");
}
}
}
MainForm>>
namespace ProektChashkina
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void button6_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button2_Click(object sender, EventArgs e)
{
TarifsForm tarifsForm = new TarifsForm();
tarifsForm.Show();
}
private void button1_Click(object sender, EventArgs e)
{
KlientsForm klientsForm = new KlientsForm();
klientsForm.Show();
}
private void button3_Click(object sender, EventArgs e)
{
AutoForm autoForm = new AutoForm();
autoForm.Show();
}
private void button4_Click(object sender, EventArgs e)
{
SalesForm salesForm = new SalesForm();
salesForm.Show();
}
private void LoginButton_Click(object sender, EventArgs e)
{
SpacesForm spacesForm = new SpacesForm();
spacesForm.Show();
}
private void button5_Click(object sender, EventArgs e)
{
RealisationForm realisationForm = new RealisationForm();
realisationForm.Show(); } }}
RealisationForm>>
namespace ProektChashkina
{
public partial class RealisationForm : Form
{
public RealisationForm()
{
InitializeComponent();
} private void RealisationForm_Load(object sender, EventArgs e) {
// TODO: данная строка кода позволяет загрузить данные в таблицу "pPDataSet.Realisation". При необходимости она может быть перемещена или удалена.
this.realisationTableAdapter.Fill(this.pPDataSet.Realisation);
}
private void button1_Click(object sender, EventArgs e)
{
this.Validate();
this.realisationBindingSource.EndEdit();
this.realisationTableAdapter.Update(this.pPDataSet.Realisation); } }}