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:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
2,583
Location
Chesapeake, VA
Programming Experience
10+
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.
 

Mishkkk

New member
Joined
Feb 10, 2021
Messages
2
Programming Experience
Beginner
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:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
2,583
Location
Chesapeake, VA
Programming Experience
10+
When posting, please put your code in code tags.
 
Top Bottom