Query to select fields and perform operations on them

Mishkkk

New member
Joined
Feb 10, 2021
Messages
2
Programming Experience
Beginner
Help me please!!!
I have:
C#:
public class Warehouse
    {
        public int WarehouseId { get; set; }
        public DateTime? DateOperation { get; set; }// date record
        public int Nomenclature { get; set; }// name
        public int Operation { get; set; }// operation: only income and  expense
        public decimal Quantity { get; set; }
    }
using (Cxt db = new Cxt())
            {
                gridQuery.DataSource = ???

            }
i need to calculate the difference between income and expense and show everything in the table. I think the approach should be:
select all fields income, summarize, select all fields expenditure, summarize, subtract from the amounts of income the amount of expenditure and write in the table, and so on all fields of the nomenclature.
 
Last edited by a moderator:
Is the "Quantity" field the actual amount of income or expense?

That class there looks to be a Database First class imported into Entity Framework instead of a Code First class used to create the database. If it were a code first, the "Nomenclature" and "Operation" fields should be enums, not ints.
 
Is the "Quantity" field the actual amount of income or expense?

That class there looks to be a Database First class imported into Entity Framework instead of a Code First class used to create the database. If it were a code first, the "Nomenclature" and "Operation" fields should be enums, not ints.
yes, the quantity is written from the dialog box
C#:
public partial class Warehouse
    {
        public int WarehouseId { get; set; }
        public int OperationId { get; set; }
        public int StorageId { get; set; }
        public int NomenclatureId { get; set; }
        public decimal Quantity { get; set; }
        public DateTime? DateOperation { get; set; }
        public string Notes { get; set; }
        public virtual Nomenclature Nomenclature { get; set; }
        public virtual Operation Operation { get; set; }
        public virtual Storage Storage { get; set; }
    }
 
Last edited by a moderator:
When posting, please put your code in code tags.
 
Back
Top Bottom