Hi,
I'm using three different viewmodels - *Header, *Details and *Conditions respectively.
I've saved the data in three tables using MVC and Entity Framework (database first).
*before name of view models can be Quotation, Purchase Order, Invoice etc... like QuotationHeader,InvoiceHeader.....
*Details and *Conditions are common among Quotation, Purchase Order, Invoice etc...
So I've used partial views for *details and *conditions. In my main view I'm calling
this two partial views. Now I've to edit that data the same way I've added it, partial view data should also get displayed and should be editable.
How can I implement such functionality in MVC ? Can any one please provide the solution ?
Given below is my code.
ViewModels:
* Quotation Viewmodel:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using iBillingMVC_Dev.ViewModel.Transactions;
using ibillingDB.Db;
using System.ComponentModel.DataAnnotations;
namespace iBillingMVC_Dev.ViewModel.Transactions
{
public class QuotationHeaderViewModel
{
public string QuotationNO { get; set; }
public int CompanyID { get; set; }
public int FinYearID { get; set; }
[Required(ErrorMessage = "Select Location")]
[Display(Name = "Location")]
public int LocationID { get; set; }
public IEnumerable<SelectListItem> Locations { get; set; }
[Required(ErrorMessage = "Select Customer")]
[Display(Name = "Customer")]
public int CustomerID { get; set; }
public IEnumerable<SelectListItem> Customers { get; set; }
[Required(ErrorMessage = "Enter Quotation Date")]
[Display(Name = "Quotation Date")]
public DateTime QuotDate { get; set; }
public string Remark { get; set; }
public int CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public bool IsActive { get; set; }
[Required(ErrorMessage = "Select Item")]
[Display(Name = "Item")]
public int ItemID { get; set; }
public IEnumerable<SelectListItem> Items { get; set; }
}
}
Item details viewmodel:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using iBillingMVC_Dev.ViewModel.Transactions;
using ibillingDB.Db;
using System.ComponentModel.DataAnnotations;
namespace iBillingMVC_Dev.ViewModel.Transactions
{
public class ItemDetailsViewModel
{
public int SortID { get; set; }
[Required(ErrorMessage = "Select Item")]
[Display(Name = "Item")]
public int ItemID { get; set; }
public IEnumerable<SelectListItem> Items { get; set; }
public List<ItemDetailsTable> ItemList { get; set; }
}
public class ItemDetailsTable
{
public int ItemID { get; set; }
public int Qty { get; set; }
public decimal Rate { get; set; }
public decimal TotalAmount { get; set; }
}
}
Terms Conditions viewmodel:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using iBillingMVC_Dev.ViewModel.Transactions;
using ibillingDB.Db;
using System.ComponentModel.DataAnnotations;
namespace iBillingMVC_Dev.ViewModel.Transactions
{
public class TermsConditionsViewModel
{
public List<TermsConditionTable> ConditionList { get; set; }
}
public class TermsConditionTable
{
public bool ischecked { get; set; }
public int ConditionID { get; set; }
public string ConditionName { get; set; }
}
}