некие изменения
This commit is contained in:
parent
ca0d26f08b
commit
fbde5f4237
@ -8,14 +8,14 @@ namespace ProjectFamilyBudget.Entities;
|
|||||||
|
|
||||||
public class ExpensePeopleExpense
|
public class ExpensePeopleExpense
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int PeopleExpenseId { get; private set; }
|
||||||
public int ExpenseId { get; private set; }
|
public int ExpenseId { get; private set; }
|
||||||
public int Sum { get; private set; }
|
public int Sum { get; private set; }
|
||||||
public static ExpensePeopleExpense CreateElement(int id, int expenseId, int sum)
|
public static ExpensePeopleExpense CreateElement(int peopleExpenseId, int expenseId, int sum)
|
||||||
{
|
{
|
||||||
return new ExpensePeopleExpense
|
return new ExpensePeopleExpense
|
||||||
{
|
{
|
||||||
Id = id,
|
PeopleExpenseId = peopleExpenseId,
|
||||||
ExpenseId = expenseId,
|
ExpenseId = expenseId,
|
||||||
Sum = sum
|
Sum = sum
|
||||||
};
|
};
|
||||||
|
@ -8,14 +8,14 @@ namespace ProjectFamilyBudget.Entities;
|
|||||||
|
|
||||||
public class IncomePeopleIncome
|
public class IncomePeopleIncome
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int PeopleIncomeId { get; private set; }
|
||||||
public int IncomeId { get; private set; }
|
public int IncomeId { get; private set; }
|
||||||
public int Sum { get; private set; }
|
public int Sum { get; private set; }
|
||||||
public static IncomePeopleIncome CreateElement(int id,int incomeId, int sum)
|
public static IncomePeopleIncome CreateElement(int peopleIncomeId,int incomeId, int sum)
|
||||||
{
|
{
|
||||||
return new IncomePeopleIncome
|
return new IncomePeopleIncome
|
||||||
{
|
{
|
||||||
Id = id,
|
PeopleIncomeId = peopleIncomeId,
|
||||||
IncomeId = incomeId,
|
IncomeId = incomeId,
|
||||||
Sum = sum
|
Sum = sum
|
||||||
};
|
};
|
||||||
|
@ -12,13 +12,13 @@ public class PeopleExpense
|
|||||||
public int PeopleId { get; private set; }
|
public int PeopleId { get; private set; }
|
||||||
public DateTime DataReceipt { get; private set; }
|
public DateTime DataReceipt { get; private set; }
|
||||||
public IEnumerable<ExpensePeopleExpense> ExpensePeopleExpenses { get; private set; } = [];
|
public IEnumerable<ExpensePeopleExpense> ExpensePeopleExpenses { get; private set; } = [];
|
||||||
public static PeopleExpense CreateOperation(int id, int peopleId, IEnumerable<ExpensePeopleExpense> expensePeopleExpenses)
|
public static PeopleExpense CreateOperation(int id, int peopleId, DateTime dataReceipt,IEnumerable<ExpensePeopleExpense> expensePeopleExpenses)
|
||||||
{
|
{
|
||||||
return new PeopleExpense
|
return new PeopleExpense
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
PeopleId = peopleId,
|
PeopleId = peopleId,
|
||||||
DataReceipt = DateTime.Now,
|
DataReceipt = dataReceipt,
|
||||||
ExpensePeopleExpenses = expensePeopleExpenses
|
ExpensePeopleExpenses = expensePeopleExpenses
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ public class PeopleIncome
|
|||||||
public int PeopleId { get; private set; }
|
public int PeopleId { get; private set; }
|
||||||
public DateTime DataReceipt { get; private set; }
|
public DateTime DataReceipt { get; private set; }
|
||||||
public IEnumerable<IncomePeopleIncome> IncomePeopleIncomes { get; private set; } = [];
|
public IEnumerable<IncomePeopleIncome> IncomePeopleIncomes { get; private set; } = [];
|
||||||
public static PeopleIncome CreateOperation(int id, int peopleId,IEnumerable<IncomePeopleIncome> incomePeopleIncomes)
|
public static PeopleIncome CreateOperation(int id, int peopleId,DateTime dataReciept,IEnumerable<IncomePeopleIncome> incomePeopleIncomes)
|
||||||
{
|
{
|
||||||
return new PeopleIncome
|
return new PeopleIncome
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
PeopleId = peopleId,
|
PeopleId = peopleId,
|
||||||
DataReceipt = DateTime.Now,
|
DataReceipt = dataReciept,
|
||||||
IncomePeopleIncomes = incomePeopleIncomes
|
IncomePeopleIncomes = incomePeopleIncomes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace ProjectFamilyBudget.Forms
|
|||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
_peopleEpxense.CreatePeopleExpense(PeopleExpense.CreateOperation(0, (int)comboBoxPeople.SelectedValue!,
|
_peopleEpxense.CreatePeopleExpense(PeopleExpense.CreateOperation(0, (int)comboBoxPeople.SelectedValue!, dateTimePicker.Value,
|
||||||
CreateListPeopleExpenseFromDataGrid()));
|
CreateListPeopleExpenseFromDataGrid()));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,6 @@
|
|||||||
//
|
//
|
||||||
// dateTimePicker
|
// dateTimePicker
|
||||||
//
|
//
|
||||||
dateTimePicker.Enabled = false;
|
|
||||||
dateTimePicker.Location = new Point(127, 62);
|
dateTimePicker.Location = new Point(127, 62);
|
||||||
dateTimePicker.Name = "dateTimePicker";
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
dateTimePicker.Size = new Size(216, 23);
|
dateTimePicker.Size = new Size(216, 23);
|
||||||
|
@ -39,7 +39,7 @@ namespace ProjectFamilyBudget.Forms
|
|||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
_peopleIncome.CreatePeopleIncome(PeopleIncome.CreateOperation(0, (int)comboBoxPeople.SelectedValue!,
|
_peopleIncome.CreatePeopleIncome(PeopleIncome.CreateOperation(0, (int)comboBoxPeople.SelectedValue!, dateTimePicker.Value,
|
||||||
CreateListPeopleIncomeFromDataGrid()));
|
CreateListPeopleIncomeFromDataGrid()));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
@ -48,7 +48,7 @@
|
|||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
@ -95,6 +95,7 @@
|
|||||||
dataGridViewData.Name = "dataGridViewData";
|
dataGridViewData.Name = "dataGridViewData";
|
||||||
dataGridViewData.ReadOnly = true;
|
dataGridViewData.ReadOnly = true;
|
||||||
dataGridViewData.RowHeadersVisible = false;
|
dataGridViewData.RowHeadersVisible = false;
|
||||||
|
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridViewData.Size = new Size(609, 450);
|
dataGridViewData.Size = new Size(609, 450);
|
||||||
dataGridViewData.TabIndex = 1;
|
dataGridViewData.TabIndex = 1;
|
||||||
//
|
//
|
||||||
|
@ -8,5 +8,5 @@ namespace ProjectFamilyBudget.Repositories.Implementations;
|
|||||||
|
|
||||||
public class ConnectionString : IConnectionString
|
public class ConnectionString : IConnectionString
|
||||||
{
|
{
|
||||||
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=otp";
|
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=otp2";
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class ExpenseRepository : IExpense
|
|||||||
SET
|
SET
|
||||||
ExpenseType=@ExpenseType,
|
ExpenseType=@ExpenseType,
|
||||||
Name=@Name,
|
Name=@Name,
|
||||||
ExpenseCategory=@ExpenseCategory,
|
ExpenseCategory=@ExpenseCategory
|
||||||
WHERE Id=@Id";
|
WHERE Id=@Id";
|
||||||
connection.Execute(queryUpdate, expense);
|
connection.Execute(queryUpdate, expense);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class IncomeRepository : IIncome
|
|||||||
SET
|
SET
|
||||||
IncomeType=@IncomeType,
|
IncomeType=@IncomeType,
|
||||||
Name=@Name,
|
Name=@Name,
|
||||||
IncomeCategory=@IncomeCategory,
|
IncomeCategory=@IncomeCategory
|
||||||
WHERE Id=@Id";
|
WHERE Id=@Id";
|
||||||
connection.Execute(queryUpdate, income);
|
connection.Execute(queryUpdate, income);
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,14 @@ public class PeopleExpenseRepository : IPeopleExpense
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO PeopleExpense (PeopleId, Date)
|
INSERT INTO PeopleExpense (Date,PeopleId)
|
||||||
VALUES (@PeopleId, @Date);
|
VALUES (@Date, @PeopleId);
|
||||||
SELECT MAX(Id) FROM PeopleIncome";
|
SELECT MAX(Id) FROM PeopleExpense";
|
||||||
var peopleExpenseId =
|
var peopleExpenseId =
|
||||||
connection.QueryFirst<int>(queryInsert, peopleExpense, transaction);
|
connection.QueryFirst<int>(queryInsert, peopleExpense, transaction);
|
||||||
var querySubInsert = @"
|
var querySubInsert = @"
|
||||||
INSERT INTO ExpensePeopleExpense (ExpenseId, PeopleExpenseId, Sum)
|
INSERT INTO ExpensePeopleExpense (ExpenseId, PeopleExpenseId, Sum)
|
||||||
VALUES (@IncomeId, @PeopleIncomeId, @Sum)";
|
VALUES (@ExpenseId, @PeopleExpenseId, @Sum)";
|
||||||
foreach (var elem in peopleExpense.ExpensePeopleExpenses)
|
foreach (var elem in peopleExpense.ExpensePeopleExpenses)
|
||||||
{
|
{
|
||||||
connection.Execute(querySubInsert, new
|
connection.Execute(querySubInsert, new
|
||||||
|
@ -8,6 +8,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectFamilyBudget.Repositories.Implementations;
|
namespace ProjectFamilyBudget.Repositories.Implementations;
|
||||||
|
|
||||||
@ -32,8 +35,8 @@ public class PeopleIncomeRepository : IPeopleIncome
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO PeopleIncome (PeopleId, Date)
|
INSERT INTO PeopleIncome (DateReciept,PeopleId)
|
||||||
VALUES (@PeopleId, @Date);
|
VALUES (@DateReciept, @PeopleId);
|
||||||
SELECT MAX(Id) FROM PeopleIncome";
|
SELECT MAX(Id) FROM PeopleIncome";
|
||||||
var peopleIncomeId =
|
var peopleIncomeId =
|
||||||
connection.QueryFirst<int>(queryInsert, peopleIncome, transaction);
|
connection.QueryFirst<int>(queryInsert, peopleIncome, transaction);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user