Controller
[HttpGet]
public ActionResult postyourad()
{
return View(new masterList());
}
[HttpPost]
public ActionResult postyourad(masterList ddlListPostData)
{
return View(ddlListPostData);
}
Model Class
namespace ModelEdmx.Models
{
public class masterList
{
[Required]
public virtual string _model { get; set; }
[Required]
public virtual string _product { get; set; }
[Required]
public virtual string _brand { get; set; }
public IList
ConnectionClass con_cs = new ConnectionClass();
public SelectList getBrand()
{
IEnumerable
select new SelectListItem()
{
Text = s.brand,
Value = s.brand
}).Distinct().OrderBy(x => x).ToList
return new SelectList(stateList, "Value", "Text", _brand);
}
public SelectList getProduct()
{
IEnumerable
if (!string.IsNullOrEmpty(_brand))
{
ProductList = (from s in con_cs.stock_entries
where s.brand == _brand
select new SelectListItem()
{
Text = s.product,
Value = s.product
}).Distinct().ToList
}
return new SelectList(ProductList, "Value", "Text", _product);
}
public SelectList getModel()
{
IEnumerable
if (!string.IsNullOrEmpty(_brand) && !string.IsNullOrEmpty(_product))
{
ModelList = (from s in con_cs.stock_entries
orderby s.model
where s.brand == _brand && s.product== _product
select new SelectListItem()
{
Text = s.model,
Value = s.model
}).Distinct().ToList
}
return new SelectList(ModelList, "Value", "Text", _model);
}
public List
{
List
//var query="";
if (!string.IsNullOrEmpty(_brand) && !string.IsNullOrEmpty(_product) && !string.IsNullOrEmpty(_model))
{
query = (from pd in con_cs.SaleDtls_entries
join od in con_cs.SaleMstr_entries on pd.req_no equals od.req_no
where pd.brand == _brand && pd.product == _product && pd.model_no == _model
orderby od.Id
select new Mydata
{
Id = od.Id,
req_no = od.req_no,
product = pd.product,
brand = pd.brand,
price = pd.price,
Qty = pd.Qty,
bill_amt = od.bill_amt,
}).ToList();
}
else
{
if (!string.IsNullOrEmpty(_brand) && !string.IsNullOrEmpty(_product))
{
query = (from pd in con_cs.SaleDtls_entries
join od in con_cs.SaleMstr_entries on pd.req_no equals od.req_no
where pd.brand == _brand && pd.product == _product
orderby od.Id
select new Mydata
{
Id = od.Id,
req_no = od.req_no,
product = pd.product,
brand = pd.brand,
price = pd.price,
Qty = pd.Qty,
bill_amt = od.bill_amt,
}).ToList();
}
else
{
if (!string.IsNullOrEmpty(_brand))
{
query = (from pd in con_cs.SaleDtls_entries
join od in con_cs.SaleMstr_entries on pd.req_no equals od.req_no
where pd.brand == _brand
orderby od.Id
select new Mydata
{
Id = od.Id,
req_no = od.req_no,
product = pd.product,
brand = pd.brand,
price = pd.price,
Qty = pd.Qty,
bill_amt = od.bill_amt,
}).ToList();
}
}
}
return query;
}
}
}
View
Replies
Know the answer? Post it — somebody with the same question will find it here.