/// <summary> /// kiểm tra 1 đối tượng /// nếu là teststructcode hoặc là cha-> load teststructcontent /// nếu là lá thì load teststructdetail /// </summary> /// <param name="code">mã cần kiểm tra</param> /// <returns> /// ret = -1: LỖI; /// data.count > 0: có con /// </returns> public JsonResult CheckParent(string code, string teststructcode) { var ret = -1; List <TESTSTRUCTCONTENT_OBJ> liTestStructContent = new List <TESTSTRUCTCONTENT_OBJ>(); List <TESTSTRUCTDETAIL_OBJ> liTestStructDetail = null; TESTSTRUCTCONTENT_BUS bus = new TESTSTRUCTCONTENT_BUS(); var res = bus.getAllBy2("THEORDER", new fieldpara("PARENTCODE", code, 0)); if (res != null && res.Count > 0) { ret = 1; } if (ret >= 0) { liTestStructContent = res; } else // là nút lá-> get teststructdetail { TESTSTRUCTDETAIL_BUS bus2 = new TESTSTRUCTDETAIL_BUS(); List <fieldpara> lipa = new List <fieldpara>(); lipa.Add(new fieldpara("TESTSTRUCTCODE", teststructcode, 0)); lipa.Add(new fieldpara("TESTSTRUCTCONTENTCODE", code, 0)); var res2 = bus2.getAllBy2("CODE", lipa.ToArray()); if (res2 != null) { ret = 2; liTestStructDetail = res2; } bus2.CloseConnection(); } bus.CloseConnection(); return(Json(new { ret = ret, liTestStructContent = liTestStructContent, liTestStructDetail = liTestStructDetail }, JsonRequestBehavior.AllowGet)); }
// GET: TestStructDetail public JsonResult getAllSearch(int page, int pageSize, string teststructcode, string code, bool codetype, string name, bool nametype, string note, bool notetype) { List <TESTSTRUCTDETAIL_OBJ> li; //mặc định cho phần trang if (pageSize == 0) { pageSize = AppConfig.item4page(); } if (page < 1) { page = 1; } //Khai báo lấy dữ liệu TESTSTRUCTDETAIL_BUS bus = new TESTSTRUCTDETAIL_BUS(); List <fieldpara> lipa = new List <fieldpara>(); lipa.Add(new fieldpara("TESTSTRUCTCODE", teststructcode, 0)); if (!string.IsNullOrEmpty(code)) { lipa.Add(codetype ? new fieldpara("CODEVIEW", code, 0) : new fieldpara("CODEVIEW", code, 1)); } if (!string.IsNullOrEmpty(name)) { lipa.Add(nametype ? new fieldpara("NAME", name, 0) : new fieldpara("NAME", name, 1)); } if (!string.IsNullOrEmpty(note)) { lipa.Add(notetype ? new fieldpara("NOTE", note, 0) : new fieldpara("NOTE", note, 1)); } int countpage; int totalItem = 0; //order by theorder, with pagesize and the page var data = bus.getAllBy2("CODE", pageSize, page, out countpage, out totalItem, lipa); //Chỉ số đầu tiên của trang hiện tại (đã trừ -1) int startpage = (page - 1) * pageSize; return(Json(new { lst = data, //Danh sách totalItem = totalItem, // số lượng tất cả các bản ghi totalPage = countpage, // số lượng trang startindex = startpage, //bắt đầu số trang ret = 0 //ok }, JsonRequestBehavior.AllowGet)); }