public static Data.KELENGKAPANCollection GetKELENGKAPANCollection(string varKODEPBJ) { SubSonic.QueryCommand cmd = new SubSonic.QueryCommand( "SELECT * FROM KELENGKAPAN INNER JOIN KELENGKAPANPBJ ON " + "KELENGKAPAN.KODEKELENGKAPAN=KELENGKAPANPBJ.KODEKELENGKAPAN WHERE KELENGKAPANPBJ.KODEBPJ=@KODEBPJ", PBJ.Schema.Provider.Name); cmd.AddParameter("@KODEBPJ", varKODEPBJ, DbType.String); IDataReader rdr = SubSonic.DataService.GetReader(cmd); KELENGKAPANCollection coll = new KELENGKAPANCollection(); coll.LoadAndCloseReader(rdr); return(coll); }
public static void SaveKELENGKAPANMap(string varKODEPBJ, KELENGKAPANCollection items) { QueryCommandCollection coll = new SubSonic.QueryCommandCollection(); //delete out the existing QueryCommand cmdDel = new QueryCommand("DELETE FROM KELENGKAPANPBJ WHERE KODEBPJ=@KODEBPJ", PBJ.Schema.Provider.Name); cmdDel.AddParameter("@KODEBPJ", varKODEPBJ); coll.Add(cmdDel); DataService.ExecuteTransaction(coll); foreach (KELENGKAPAN item in items) { KELENGKAPANPBJ varKELENGKAPANPBJ = new KELENGKAPANPBJ(); varKELENGKAPANPBJ.SetColumnValue("KODEBPJ", varKODEPBJ); varKELENGKAPANPBJ.SetColumnValue("KODEKELENGKAPAN", item.GetPrimaryKeyValue()); varKELENGKAPANPBJ.Save(); } }
private void GetData() { bool bNoRecordsFirstPage = false; if (bNoRecordsFirstPage) { collection = new Data.DOKUMENCollection(); numrows = 0; } else { if (Search == 0) { GetSearchRows(); } else if (Search == 2) { GetAdvancedSearchRows(); } else { GetAllRows(); } } Data.KELENGKAPANController KELENGKAPAN_detailController = new Data.KELENGKAPANController(); //foreach @TABLE.arrKeyFields as @tk ArrayList KELENGKAPAN_masterids = new ArrayList(); for (int i = 0; i < collection.Count; ++i) { try{ KELENGKAPAN_masterids.Add(collection[i].KODEDOKUMEN.ToString()); } catch { } } KELENGKAPAN_detailCollection = KELENGKAPAN_detailController.FetchForDetails("KODEDOKUMEN", KELENGKAPAN_masterids.ToArray(), OwnerColumn, OwnerID); // save SQL for use in "Export" and "Printer-friendly" pages // select and display records if (allow_search) { // Pagination: if (numrows == 0) { rowsfound = false; message = "No records found"; IDictionary message_block = array(); message_block["begin"] = "<span name=\"notfound_message\">"; message_block["end"] = "</span>"; smarty.Add("message_block", message_block); smarty.Add("message", message); } else { rowsfound = true; int maxRecords = numrows; smarty.Add("records_found", numrows); int maxpages = (int)Math.Ceiling((double)maxRecords / PageSize); if (mypage > maxpages) { mypage = maxpages; } if (mypage < 1) { mypage = 1; } smarty.Add("page", mypage); smarty.Add("maxpages", maxpages); // write pagination if (maxpages > 1) { smarty.Add("pagination_block", true); string pagination = string.Format("<script language=\"JavaScript\">WritePagination({0},{1});function GotoPage(nPageNumber)", mypage, maxpages); pagination += "{window.location='DOKUMEN_list.aspx?goto=' + nPageNumber;}</script>"; smarty.Add("pagination", pagination); } } // hide colunm headers if needed int recordsonpage = numrows - (mypage - 1) * PageSize; if (recordsonpage > PageSize) { recordsonpage = PageSize; } colsonpage = 1; if (colsonpage > recordsonpage) { colsonpage = recordsonpage; } if (colsonpage < 1) { colsonpage = 1; } } }