правки по 3
This commit is contained in:
parent
cccd753680
commit
3153d5bffc
@ -12,9 +12,9 @@ public class MaterialReplenishment
|
||||
public int Count { get; private set; }
|
||||
public DateTime DataTime { get; private set; }
|
||||
|
||||
public int IDMaterial { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public static MaterialReplenishment CreateOperation(int id, int count, DateTime dataTime, int idmaterial)
|
||||
public static MaterialReplenishment CreateOperation(int id, int count, DateTime dataTime, string name)
|
||||
{
|
||||
return new MaterialReplenishment
|
||||
{
|
||||
@ -22,7 +22,7 @@ public class MaterialReplenishment
|
||||
|
||||
Count = count,
|
||||
DataTime = dataTime,
|
||||
IDMaterial = idmaterial
|
||||
Name = name
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,15 @@
|
||||
label1 = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
label3 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
label4 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(77, 130);
|
||||
label2.Location = new Point(73, 186);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(90, 20);
|
||||
label2.TabIndex = 1;
|
||||
@ -50,14 +52,14 @@
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
numericUpDownCount.Location = new Point(212, 123);
|
||||
numericUpDownCount.Location = new Point(212, 184);
|
||||
numericUpDownCount.Name = "numericUpDownCount";
|
||||
numericUpDownCount.Size = new Size(150, 27);
|
||||
numericUpDownCount.TabIndex = 3;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(77, 197);
|
||||
buttonAdd.Location = new Point(73, 255);
|
||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(107, 53);
|
||||
@ -68,7 +70,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(231, 197);
|
||||
buttonCancel.Location = new Point(228, 255);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(117, 53);
|
||||
@ -80,7 +82,7 @@
|
||||
// comboBoxMaterial
|
||||
//
|
||||
comboBoxMaterial.FormattingEnabled = true;
|
||||
comboBoxMaterial.Location = new Point(210, 76);
|
||||
comboBoxMaterial.Location = new Point(211, 127);
|
||||
comboBoxMaterial.Name = "comboBoxMaterial";
|
||||
comboBoxMaterial.Size = new Size(151, 28);
|
||||
comboBoxMaterial.TabIndex = 6;
|
||||
@ -88,11 +90,11 @@
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(77, 76);
|
||||
label1.Location = new Point(73, 135);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(103, 20);
|
||||
label1.Size = new Size(78, 20);
|
||||
label1.TabIndex = 7;
|
||||
label1.Text = "ID материала";
|
||||
label1.Text = "Mатериал";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
@ -110,11 +112,29 @@
|
||||
label3.TabIndex = 9;
|
||||
label3.Text = "Дата";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(210, 78);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(152, 27);
|
||||
textBoxName.TabIndex = 10;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(77, 85);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(156, 20);
|
||||
label4.TabIndex = 11;
|
||||
label4.Text = "Название материала";
|
||||
//
|
||||
// FormMaterialReplenishment
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(411, 273);
|
||||
ClientSize = new Size(502, 363);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(label1);
|
||||
@ -144,5 +164,7 @@
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Label label3;
|
||||
private TextBox textBoxName;
|
||||
private Label label4;
|
||||
}
|
||||
}
|
@ -30,10 +30,10 @@ namespace ProjectAtelier.Forms
|
||||
{
|
||||
throw new InvalidDataException(nameof(materialReplenishment));
|
||||
}
|
||||
|
||||
|
||||
textBoxName.Text = materialReplenishment.Name;
|
||||
comboBoxMaterial.Text = materialReplenishment.Name;
|
||||
numericUpDownCount.Value = materialReplenishment.Count;
|
||||
comboBoxMaterial.SelectedValue = materialReplenishment.IDMaterial; // Устанавливаем выбранный материал
|
||||
dateTimePicker.Value = materialReplenishment.DataTime; // Устанавливаем выбранную дату и время
|
||||
_materialReplenishmentId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -58,9 +58,8 @@ namespace ProjectAtelier.Forms
|
||||
|
||||
private MaterialReplenishment CreateMaterialReplenishment(int id)
|
||||
{
|
||||
int selectedMaterialId = (int)comboBoxMaterial.SelectedValue;
|
||||
DateTime selectedDateTime = dateTimePicker.Value;
|
||||
return MaterialReplenishment.CreateOperation(id, Convert.ToInt32(numericUpDownCount.Value), selectedDateTime, selectedMaterialId);
|
||||
return MaterialReplenishment.CreateOperation(id, Convert.ToInt32(numericUpDownCount.Value), selectedDateTime, textBoxName.Text);
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click_1(object sender, EventArgs e)
|
||||
|
@ -29,8 +29,8 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO MaterialReplenishment (Count, DataTime, IDMaterial)
|
||||
VALUES (@Count, @DataTime, @IDMaterial)";
|
||||
INSERT INTO MaterialReplenishment (Count, DataTime, Name)
|
||||
VALUES (@Count, @DataTime, @Name)";
|
||||
connection.Execute(queryInsert, material);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -93,7 +93,7 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
||||
SET
|
||||
Count=@Count,
|
||||
DataTime=@DataTime,
|
||||
IDMaterial=@IDMaterial
|
||||
Name=@Name
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, material);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class ChartReport
|
||||
return _materialReplenishmentRepository
|
||||
.ReadMaterialsSpent()
|
||||
.Where(x => x.DataTime.Date == dateTime.Date)
|
||||
.GroupBy(x => x.IDMaterial, (key, group) => new { Id = key, Count = group.Sum(x => x.Count) })
|
||||
.GroupBy(x => x.Name, (key, group) => new { Id = key, Count = group.Sum(x => x.Count) })
|
||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ internal class TableReport
|
||||
{
|
||||
var data = _materialReplenishmentRepository
|
||||
.ReadMaterialsSpent()
|
||||
.Where(x => x.DataTime >= startDate && x.DataTime <= endDate && x.IDMaterial == materialId)
|
||||
.Where(x => x.DataTime >= startDate && x.DataTime <= endDate && x.Name == _materialRepository.ReadMaterialById(materialId).Name)
|
||||
.Select(x => new { Date = x.DataTime, CountIn = (int?)x.Count, CountOut = (int?)null })
|
||||
.Union(
|
||||
_orderMaterialsRepository
|
||||
@ -65,5 +65,3 @@ internal class TableReport
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
//.Where(x => x.DataTime >= startDate && x.DataTime <= endDate && x.Name == _materialRepository.ReadMaterialById(materialId).Name)
|
||||
// .Select(x => new { Date = x.DateReplenishment, CountIn = (int?)x.Count , CountOut = (int?)null })
|
@ -21,7 +21,9 @@ public class OrderMaterialsRepository : IOrderMaterialsRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT orders.*, materials.id AS materialid, pm.count*op.count AS count
|
||||
SELECT
|
||||
orders.datatime AS DataOrder,
|
||||
orders.*, materials.id AS materialid, pm.count*op.count AS count
|
||||
FROM orders
|
||||
INNER JOIN order_products AS op ON orders.id = op.orderid
|
||||
INNER JOIN products ON op.productid = products.id
|
||||
|
Loading…
Reference in New Issue
Block a user