public List <TB_Material_Group_md> ParcelGroup_SearchData(string sName, string sIsActive) { List <TB_Material_Group_md> listtb_material_group_md = new List <TB_Material_Group_md>(); List <TB_Material_Group> tb_material_group = new List <TB_Material_Group>(); PTTGSP_DWSContext db = new PTTGSP_DWSContext(); tb_material_group = db.TB_Material_Group.Where(w => w.IsDel == false && (w.sName.Trim().ToLower().Contains(sName ?? "")) && (sIsActive != null ? w.IsActive == (sIsActive == "1") : 1 == 1) ).OrderBy(o => o.nOrder).ToList(); foreach (TB_Material_Group i in tb_material_group) { TB_Material_Group_md tb_material_group_md = new TB_Material_Group_md(); tb_material_group_md.nGroupID = i.nGroupID; tb_material_group_md.sName = i.sName; tb_material_group_md.sDetail = i.sDetail; tb_material_group_md.IsActive = i.IsActive; tb_material_group_md.IsDel = i.IsDel; tb_material_group_md.sCreateBy = i.sCreateBy; tb_material_group_md.nOrder = i.nOrder; tb_material_group_md.dCreate = i.dCreate; tb_material_group_md.sUpdateBy = i.sUpdateBy; tb_material_group_md.dUpdate = String.Format("{0:D2}", i.dUpdate.Day.ToString()) + "/" + String.Format("{0:D2}", i.dUpdate.Month.ToString()) + "/" + i.dUpdate.AddYears(543).Year.ToString(); tb_material_group_md.IsUse = db.TB_Material_Category.Where(w => w.nGroupID == i.nGroupID).FirstOrDefault() == null ? false : true; tb_material_group_md.sActive = i.IsActive ? "ใช้งาน" : "ไม่ใช้งาน"; listtb_material_group_md.Add(tb_material_group_md); } return(listtb_material_group_md); }
public List <TB_Material_Group_md> ParcelGroup() { List <TB_Material_Group_md> listtb_material_group_md = new List <TB_Material_Group_md>(); List <TB_Material_Group> listtb_material_group = new List <TB_Material_Group>(); PTTGSP_DWSContext db = new PTTGSP_DWSContext(); listtb_material_group = db.TB_Material_Group.Where(w => w.IsDel == false).OrderBy(o => o.nOrder).ToList(); if (listtb_material_group != null) { foreach (TB_Material_Group i in listtb_material_group) { TB_Material_Group_md tb_material_group_md = new TB_Material_Group_md(); tb_material_group_md.nGroupID = i.nGroupID; tb_material_group_md.sName = i.sName; tb_material_group_md.sDetail = i.sDetail; tb_material_group_md.IsActive = i.IsActive; tb_material_group_md.IsDel = i.IsDel; tb_material_group_md.sCreateBy = i.sCreateBy; tb_material_group_md.nOrder = i.nOrder; tb_material_group_md.dCreate = i.dCreate; tb_material_group_md.sUpdateBy = i.sUpdateBy; tb_material_group_md.dUpdate = String.Format("{0:D2}", i.dUpdate.Day) + "/" + String.Format("{0:D2}", i.dUpdate.Month) + "/" + i.dUpdate.AddYears(543).Year.ToString(); tb_material_group_md.IsUse = db.TB_Material_Category.Where(w => w.nGroupID == i.nGroupID).FirstOrDefault() == null ? false : true; tb_material_group_md.sActive = i.IsActive ? "ใช้งาน" : "ไม่ใช้งาน"; listtb_material_group_md.Add(tb_material_group_md); } } return(listtb_material_group_md); }