Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
I am new to ASP MVC and developing inventory control system. i have two main Tables(classes) Sale & SDetails as mentioned below. i want to use one single page to insert several products details and automatically calculate total. when user click issue button, all products details should be saved to SDetail table and respective reference with total should be saved to sale table.

public class Sale
    {
        [Key]
        public int ID { get; set; }
        public string InvoiceNo { get; set; }
        public DateTime SDate { get; set; }
        public decimal SubTotal { get; set; }
        public decimal Discount { get; set; }
        public decimal NetAmount { get; set; }
        public int PaymentID { get; set; }
        public int CustomerID { get; set; }
        public int UserID { get; set; }

        public virtual ICollection<SDetail> SDetails { get; set; }
        public virtual Payment BillNo { get; set; }
        public virtual Customer Customer { get; set; }
        public virtual User User { get; set; }
    }

 public class SDetail
    {
        [Key]
        public int ID { get; set; }
        public decimal UnitPrice { get; set; }
        public int Size { get; set; }
        public int Quantity { get; set; }
        public decimal Total { get; set; }
        public int ProductID { get; set; }
        public int SaleID { get; set; }

        public virtual Product product { get; set; }
        public virtual Sale Sale { get; set; }
    }


public enum ReOrderLevel
    {
        Surplus, High, Medium, Low, VeryLow
    }

    public class Product
    {
        [Key]
        public int ID { get; set; }
        public string PName { get; set; }
        public string PDesc { get; set; }
        public int QPerUnit { get; set; }
        public decimal UPrice { get; set;}
        public string USize { get; set; }
        public decimal Discount { get; set; }
        public int UInStock { get; set; }
        public ReOrderLevel? ReOrderLevel { get; set; }
        public string Note { get; set; }
        public int CategoryID { get; set; }
        public int SupplierID { get; set; }

        public virtual Category Category { get; set; }
        public virtual Supplier Supplier { get; set; }
    }

public class SchoolContext : DbContext
    {
        public SchoolContext() : base("SchoolContext")
        {
        }

        public DbSet<Bus> Busses { get; set; }
        public DbSet<Category> Categories { get; set; }
        public DbSet<Customer> Customers { get; set; }
        public DbSet<Department> Departments { get; set; }
        public DbSet<Grade> Grades { get; set; }
        public DbSet<Payment> Payments { get; set; }
        public DbSet<Post> Posts { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Sale> Sales { get; set; }
        public DbSet<SDetail> SDetails { get; set; }
        public DbSet<Staff> Staffs { get; set; }
        public DbSet<Student> Students { get; set; }
        public DbSet<Supplier> Suppliers { get; set; }
        public DbSet<User> Users { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();

        }
    }

Hope quick reply at the earliest.
thanks in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900