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