data form

This commit is contained in:
redtea committed 2024-06-04 22:34:17 +03:00
1 parent eee7548fc8
commit 4c422d90af
7 files changed
+41 -59

No files matched your search

@@ -0,0 +1,16 @@
@echo off
:: Created by: Shawn Brink
:: Created on: October 17, 2021
:: Tutorial: https://www.elevenforum.com/t/clear-and-reset-thumbnail-cache-in-windows-11.2051/
echo.
taskkill /f /im explorer.exe
timeout 2 /nobreak>nul
echo.
DEL /F /S /Q /A %LocalAppData%\Microsoft\Windows\Explorer\thumbcache_*.db
timeout 2 /nobreak>nul
start explorer.exe
-2
View File
@@ -10,9 +10,7 @@ namespace PaymentLogs.Domain
{ {
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Type { get; set; }
public int Cost { get; set; } public int Cost { get; set; }
public int Duration { get; set; }
public int StudentsCount { get; set; } public int StudentsCount { get; set; }
} }
} }
-25
View File
@@ -34,8 +34,6 @@
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
@@ -90,25 +88,6 @@
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.button1.Click += new System.EventHandler(this.button1_Click);
// //
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label2.Location = new System.Drawing.Point(1119, 291);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(203, 22);
this.label2.TabIndex = 4;
this.label2.Text = "Наименование курсов:";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(1124, 318);
this.textBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(366, 26);
this.textBox2.TabIndex = 5;
//
// toolStrip1 // toolStrip1
// //
this.toolStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); this.toolStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
@@ -164,8 +143,6 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1593, 706); this.ClientSize = new System.Drawing.Size(1593, 706);
this.Controls.Add(this.toolStrip1); this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1); this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
@@ -192,8 +169,6 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton toolStripButton1; private System.Windows.Forms.ToolStripButton toolStripButton1;
+12 -4
View File
@@ -15,13 +15,15 @@ namespace PaymentLogs
{ {
public partial class DataForm : Form public partial class DataForm : Form
{ {
private Course _course;
public DataForm() public DataForm(string courseName)
{ {
InitializeComponent(); InitializeComponent();
_course = Program.CourseRepository.ByName(courseName);
} }
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
@@ -33,11 +35,17 @@ namespace PaymentLogs
dataGridView1.Columns.Add("debt", "Долг"); dataGridView1.Columns.Add("debt", "Долг");
foreach (Payment payment in Program.PaymentRepository.All()) foreach (Payment payment in Program.PaymentRepository.All())
{ {
if(payment.CourseId != _course.Id)
{
continue;
}
dataGridView1.Rows.Add(payment.Id.ToString(), payment.FCs.ToString(), Program.CourseRepository.Get(payment.CourseId).Name, dataGridView1.Rows.Add(payment.Id.ToString(), payment.FCs.ToString(), Program.CourseRepository.Get(payment.CourseId).Name,
payment.CoursePrice.ToString(), payment.Paid.ToString(), payment.Debt.ToString()); payment.CoursePrice.ToString(), payment.Paid.ToString(), payment.Debt.ToString());
} }
} }
private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e) private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
{ {
@@ -89,7 +97,7 @@ namespace PaymentLogs
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
string FCsText = textBox1.Text; string FCsText = textBox1.Text;
string CourseText = textBox2.Text;
List<List<string>> filtredList = new List<List<string>>(); List<List<string>> filtredList = new List<List<string>>();
foreach (DataGridViewRow row in dataGridView1.Rows) foreach (DataGridViewRow row in dataGridView1.Rows)
{ {
@@ -101,7 +109,7 @@ namespace PaymentLogs
} }
string FCs = row.Cells["fcs"].Value.ToString(); string FCs = row.Cells["fcs"].Value.ToString();
string course = row.Cells["course"].Value.ToString(); string course = row.Cells["course"].Value.ToString();
if (((FCs.Equals(FCsText)) && (course.Equals(CourseText))) ) if (((FCs.Equals(FCsText))) )
{ {
List<string> list = new List<string> List<string> list = new List<string>
{ row.Cells["id"].Value.ToString(), row.Cells["fcs"].Value.ToString(), { row.Cells["id"].Value.ToString(), row.Cells["fcs"].Value.ToString(),
+3 -7
View File
@@ -22,14 +22,12 @@ namespace PaymentLogs.Forms
{ {
dataGridView1.Columns.Add("id", "Номер"); dataGridView1.Columns.Add("id", "Номер");
dataGridView1.Columns.Add("name", "Наименование"); dataGridView1.Columns.Add("name", "Наименование");
dataGridView1.Columns.Add("type", "Тип");
dataGridView1.Columns.Add("cost", "Цена"); dataGridView1.Columns.Add("cost", "Цена");
dataGridView1.Columns.Add("duration", "Длительность");
dataGridView1.Columns.Add("studentsCount", "Кол-во студентов"); dataGridView1.Columns.Add("studentsCount", "Кол-во студентов");
foreach (Course course in Program.CourseRepository.All()) foreach (Course course in Program.CourseRepository.All())
{ {
dataGridView1.Rows.Add(course.Id.ToString(), course.Name.ToString(), course.Type.ToString(), course.Cost.ToString(), dataGridView1.Rows.Add(course.Id.ToString(), course.Name.ToString(), course.Cost.ToString(),
course.Duration.ToString(), course.StudentsCount.ToString()); course.StudentsCount.ToString());
} }
} }
@@ -43,7 +41,7 @@ namespace PaymentLogs.Forms
{ {
String text = textBox2.Text; String text = textBox2.Text;
this.Hide(); this.Hide();
new StudentsForm(text).Show(); new DataForm(text).Show();
} }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
@@ -63,9 +61,7 @@ namespace PaymentLogs.Forms
{ {
Id = Convert.ToInt32(row.Cells["id"].Value), Id = Convert.ToInt32(row.Cells["id"].Value),
Name = row.Cells["name"].Value.ToString(), Name = row.Cells["name"].Value.ToString(),
Type = row.Cells["type"].Value.ToString(),
Cost = Convert.ToInt32(row.Cells["cost"].Value), Cost = Convert.ToInt32(row.Cells["cost"].Value),
Duration = Convert.ToInt32(row.Cells["duration"].Value),
StudentsCount = Convert.ToInt32(row.Cells["studentsCount"].Value) StudentsCount = Convert.ToInt32(row.Cells["studentsCount"].Value)
}; };
Program.CourseRepository.Update(course.Id, course); Program.CourseRepository.Update(course.Id, course);
-9
View File
@@ -188,15 +188,6 @@
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripButton toolStripButton3; private System.Windows.Forms.ToolStripButton toolStripButton3;
private System.Windows.Forms.BindingSource студентыBindingSource;
private System.Windows.Forms.DataGridViewTextBoxColumn способОплатыDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn датаОплатыDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn долгDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn оплаченоDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn дисциплинаDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn местоПроживанияDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn датаРожденияDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn фИОDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn iDDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn iDDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridView dataGridView1;
} }
+10 -12
View File
@@ -28,9 +28,7 @@ namespace PaymentLogs.Repositories
Course course = new Course() { Course course = new Course() {
Id = reader.GetInt32("id"), Id = reader.GetInt32("id"),
Name = reader.GetString("name"), Name = reader.GetString("name"),
Type = reader.GetString("type"),
Cost = reader.GetInt32("cost"), Cost = reader.GetInt32("cost"),
Duration = reader.GetInt32("duration"),
StudentsCount = reader.GetInt32("students_count") StudentsCount = reader.GetInt32("students_count")
}; };
_data[course.Id] = course; _data[course.Id] = course;
@@ -41,21 +39,21 @@ namespace PaymentLogs.Repositories
public override void Save() public override void Save()
{ {
DataBase db = new DataBase();
foreach(Course course in All()) db.openConnection();
foreach (Course course in All())
{ {
DataBase db = new DataBase();
db.openConnection(); string sql = $" INSERT INTO `courses` (`id`, `name`, `cost`, `students_count`) VALUES ('{course.Id}'," +
string sql = $" INSERT INTO `courses` (`id`, `name`, `type`, `cost`, `duration`, `students_count`) VALUES ('{course.Id}'," + $"'{course.Name}', '{course.Cost}', '{course.StudentsCount}') " +
$"'{course.Name}', '{course.Type}', '{course.Cost}', '{course.Duration}', '{course.StudentsCount}') " + $"ON DUPLICATE KEY UPDATE `name`='{course.Name}', `cost`='{course.Cost}'," +
$"ON DUPLICATE KEY UPDATE `name`='{course.Name}', `type`='{course.Type}', `cost`='{course.Cost}', `duration`='{course.Duration}'," +
$"`students_count`='{course.StudentsCount}' "; $"`students_count`='{course.StudentsCount}' ";
MySqlCommand cmd = new MySqlCommand(sql, db.getConnection()); MySqlCommand cmd = new MySqlCommand(sql, db.getConnection());
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
db.closeConnection();
} }
db.closeConnection();
} }
public Course ByName(string name) public Course ByName(string name)