Search result for 'populate'
(0.0140709877014 seconds)
David Carter/Dictionary Populates ( C#)
public Dictionary<string, int> GetAListOfFullFilledOrderCounts(int subscriberid, string orderid)
{
Dictionary<string, int> newDict = new Dictionary<string, int>();
IQuery q =
session.CreateQuery(
"Select c.Name, Count(r) from Reminder r inner join r.Campaign c where r.Subscriber.ID = :sid and r.UserAction.ID = 3 and r.PageflexOrderID = :oid group by c.Name");
q.SetInt32("sid", subscriberid);
q.SetString("oid", orderid);
IList<object[]> oas = q.List<object[]>();
if (oas.Count > 0)
{
foreach (object[] oa in oas)
{
newDict.Add(oa[0].ToString(), Convert.ToInt32(oa[1]));
}
}
return newDict;
}
This Function populates a dictionary with Objects
krisdb/Populate data ( C#)
DataTable dtData = DataSelection.ReturnDataTable("sp_StoredProc");
if (dtData.Rows.Count > 0)
{
txtFormField.Text = dtData.Rows[0]["Column"].ToString();
}
foreach (DataRow dr in dtData.Rows)
{
txtFormField.Text = dr["Column"].ToString();
}
dom111/autoPopulate 0.1 - Automatically populate form fields using a bookmarklet ( JavaScript)
(function() {
var data = {
// personal details
'forename': {
'expression': /^(delivery|billing|card)?_?(fore|first)_?name$/i,
'value': [
'Bob',
'Alice'
]
},
'surname': {
'expression': /^(delivery|billing|card)?_?(sur|family|last)_?name$/i,
'value': [
'Tester',
'O\'Test' // test for quote acceptance
]
},
'company': {
'expression': /^(delivery|billing|card)?_?(company|business|organisation)_?(name)?$/i,
'value': [
'Test Ltd.',
'Test O\'Sites Ltd.',
'Test "Testing" Ltd.'
]
},
'email': {
'expression': /^(confirm)?_?email_?(address|confirm)?$/i,
'value': 'test.user@testdomain.co.uk'
},
// address details
'house_number': {
'expression': /^(delivery|billing|card)?_?(house|street|building)_?(num(ber)?|no)?$/i,
'value': '45'
},
'address1': {
'expression': /^(delivery|billing|card)?_?address_?1$/i,
'value': [
'45 Test Road',
'"Test House", 45 Test Road',
'\'Test House\', 45 Test Road'
]
},
'address2': {
'expression': /^(delivery|billing|card)?_?address_?2$/i,
'value': 'Teston'
},
'town': {
'expression': /^(delivery|billing|card)?_?(town|city|address_?3)$/i,
'value': 'Testville'
},
'county': {
'expression': /^(delivery|billing|card)?_?(county|state|address_?4)$/i,
'value': 'Testshire'
},
'postcode': {
'expression': /^(delivery|billing|card)?_?(post(al)?|zip)_?code$/i,
'value': [
'WR2 6NJ' // postcode anywhere test postcode - no charge for testing!
]
},
'country': {
'expression': /^(delivery|billing|card)?_?country$/i,
'value': [
'United Kingdom',
'Great Britain',
'England',
'UK'
]
},
// contact details
'phone': {
'expression': /^(delivery|billing|card)?_?((tele?)?phone|tel)_?(num(ber)?|no)?$/i,
'value': '01234 567 890'
},
'mobile': {
'expression': /^mob(ile)?_?(num(ber)?|no)?$/i,
'value': '07777 123 456'
},
'fax': {
'expression': /^(fax|facsimile)_?(num(ber)?|no)?$/i,
'value': '01234 567 891'
},
// date of birth
'dob_day': {
'expression': /^d(a?te)?_?of?_?b(irth)?_?d(a?y)?$/i,
'value': 1
},
'dob_month': {
'expression': /^d(a?te)?_?of?_?b(irth)?_?m((on)?th)?$/i,
'value': 1
},
'dob_year': {
'expression': /^d(a?te)?_?of?_?b(irth)?_?y(ear|r)?$/i,
'value': 1980
},
// card details
'card_number': {
'expression': /^(credit|debit)?_?card_?(num(ber)?|no)?$/i,
'value': '4929 0000 0000 6'
},
'card_valid_month': {
'expression': /^(credit|debit)?_?(card)?_?(start|valid_?(from)?)_?month$/i,
'value': '01'
},
'card_valid_year': {
'expression': /^(credit|debit)?_?(card)?_?(start|valid_?(from)?)_?year$/i,
'value': '2010'
},
'card_expiry_month': {
'expression': /^(credit|debit)?_?(card)?_?expiry_?month$/i,
'value': '12'
},
'card_expiry_year': {
'expression': /^(credit|debit)?_?(card)?_?expiry_?year$/i,
'value': '2015'
},
'security_code': {
'expression': /^(credit|debit)?_?(card)?_?(verification|cv2|security)?_?code$/i,
'value': '123'
},
// message/notes
'message': {
'expression': /^(message|(delivery|billing|card)?_?notes?|info(rmation)?|comments?)$/i,
'value': 'This is a test.'
},
// concatenation
'name': {
'expression': /^(full|delivery|billing|card)?_?(name(_?on_?card)?|cardholder)$/i,
'combine': [
'forename',
'surname'
],
'separator': ' '
},
'address': {
'expression': /^(delivery|billing|card)?_?address$/i,
'combine': [
'address1',
'address2',
'town'
],
'separator': ', '
},
'dob': {
'expression': /^d(ate)?_?of?_?b(irth)?$/i,
'combine': [
'dob_day',
'dob_month',
'dob_year'
],
'separator': '/'
},
'card_valid': {
'expression': /^(credit|debit)?_?(card)?_?(start|valid_?(from)?)y_?(da?te)?$/i,
'combine': [
'card_valid_month',
'card_valid_year'
],
'separator': ''
},
'card_expiry': {
'expression': /^(credit|debit)?_?(card)?_?expiry_?(da?te)?$/i,
'combine': [
'card_expiry_month',
'card_expiry_year'
],
'separator': ''
}
};
var concatFields = function(values, separator, data) {
var r = [];
for (var i = 0; i < values.length; i++) {
if (values[i] in data) {
var field = data[values[i]];
if ('value' in field) {
var value = field.value;
if (typeof(value) == 'string') {
if (value.length > 0) {
r.push(value);
}
} else if (value.length) {
var key = Math.floor(Math.random() * value.length);
if (value[key].length > 0) {
r.push(value[key]);
}
}
} else if ('combine' in field && 'separator' in field) {
r.push(concatFields(field.combine, field.separator, data));
}
}
}
return r.join(separator);
}
if (document.querySelectorAll) {
var elements = document.querySelectorAll('input, textarea, select');
} else {
var elements = [];
elements = elements.concat(document.getElementsByTagName('input'), document.getElementsByTagName('textarea'), document.getElementsByTagName('select'));
}
for (var i = 0; i < elements.length; i++) {
var name = (elements[i].name ? elements[i].name : elements[i].id);
for (var key in data) {
var field = data[key];
if (name.match(field.expression)) {
var value = (('combine' in field && 'separator' in field) ? concatFields(field.combine, field.separator, data) : (('value' in field) ? field.value : false));
if (value !== false) {
if (elements[i].tagName.toLowerCase() == 'select') {
for (var j = 0; j < elements[i].options.length; j++) {
if (typeof(value) == 'string' || typeof(value) == 'number') {
if (elements[i].options[j].value == value || elements[i].options[j].text == value) {
elements[i].selectedIndex = j;
break;
}
} else if (value.length) {
if (value.indexOf(elements[i].options[j].value) > -1 || value.indexOf(elements[i].options[j].text) > -1) {
elements[i].selectedIndex = j;
break;
}
}
}
} else if (elements[i].tagName.toLowerCase() == 'input' && (elements[i].type == 'checkbox' || elements[i].type == 'radio')) {
if (elements[i].value == value) {
elements[i].checked = true;
} else {
elements[i].checked = false;
}
} else {
if (typeof(value) == 'string' || typeof(value) == 'number') {
elements[i].value = value;
} else if (value.length) {
elements[i].value = value[Math.floor(Math.random() * value.length)];
}
}
elements[i].blur();
}
continue;
}
}
}
})();
I\'m constantly testing forms over and over for one reason or another, and am fed up with making a typo and autocomplete not populating all the data, so I made this little snippet. It searches for form elements on the page (input, textarea and select) and using regular expressions, tries to match the field name and populate the data as best it can. There\'s also a generator so instead of the random test data I\'ve provided you can generate your own.\r\n\r\nDemo:\r\nhttp://www.dom111.co.uk/files/autoPopulate/\r\n\r\nGenerator:\r\nhttp://www.dom111.co.uk/files/autoPopulate/generate.html
Himanshu Kaushik/Populating DataSet ( C#)
SqlConnection Conn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=test");
SqlCommand selectCMD = new SqlCommand("SELECT CustomerID, CompanyName FROM Customers", Conn);
selectCMD.CommandTimeout = 30;
SqlDataAdapter custDA = new SqlDataAdapter();
custDA.SelectCommand = selectCMD;
nwindConn.Open();
DataSet custDS = new DataSet();
custDA.Fill(custDS, "Customers");
nwindConn.Close();
Populating DataSet
David Carter/Dataset Population ADO ( C#)
public DataSet GetPageFlexProductsAndThumbnailsList(int categoryid)
{
DataSet ds = new DataSet();
using (SqlConnection cn = getConnection())
{
Debug.WriteLine(cn.ConnectionString);
string query = "select pce.ProductID, p.ThumbnailID from ProductCatalogEntries pce, Products p " +
" where pce.ProductID = p.ProductID and pce.ParentCategoryID = " + categoryid + " and p.b_IsDeleted = 0 and p.b_IsRetired = 0 and p.b_IsDeleted = 0 order by pce.PresentationSequence";
Debug.Print(query);
_logger.Info(query);
cn.Open();
using (SqlCommand cm = new SqlCommand(query, cn))
{
SqlDataAdapter sqlAdapter = new SqlDataAdapter(cm);
sqlAdapter.Fill(ds);
}
}
return ds;
}
This runs a query and populates a dataset
Sam West/Populate dropdown from result ( JavaScript)
//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetStateListItems(countryNode)
{
var stateList = document.getElementById("stateList");
//Clears the state combo box contents.
for (var count = stateList.options.length-1; count >-1; count--)
{
stateList.options[count] = null;
}
var stateNodes = countryNode.getElementsByTagName('state');
var textValue;
var optionItem;
//Add new states list to the state combo box.
for (var count = 0; count < stateNodes.length; count++)
{
textValue = GetInnerText(stateNodes[count]);
optionItem = new Option( textValue, textValue, false, false);
stateList.options[stateList.length] = optionItem;
}
}
//Returns the node text value
function GetInnerText (node)
{
return (node.textContent || node.innerText || node.text) ;
}
Populate dropdown from result
John Baker/Populate a treeview control with ADO ( VB.NET)
Private Sub LoadtreeView()
Dim nodeMyFirstNode, nodeMySecondNode As TreeNode
Dim rowMyFirstRow, rowMySecondRow As DataRow
For Each rowMyFistRow In ds_DataSet.tblMyTable.Rows
nodeMyFirstNode = New TreeNode
nodeMyFirstNode.Text = rowMyFirstRow("Column")
TreeView1.Nodes.Add(nodeMyFirstNode)
For Each rowMySecondNode In rowMyFirstRow.GetChildRows("Relation")
nodeMySecondNode = New TreeNode
nodeMySecondNode.Text = rowMySecondRow("Column")
nodeMyFirstNode.Nodes.Add(nodeMySecondNode)
Next
Next
End Sub
Populate a treeview control from a Dataset
Zafar Iqbal/PopulateTimeList ( ASP.NET)
Public Shared Sub PopulateTimeList(ByRef list As System.Web.UI.WebControls.ListControl, ByVal startTime As DateTime, ByVal endTime As DateTime, ByVal increment As Integer)
list.Items.Clear()
Do While startTime <= endTime
list.Items.Add(New ListItem(startTime.ToLongTimeString(), startTime.ToLongTimeString()))
startTime = startTime.AddMinutes(increment)
Loop
End Sub
Populates a list control with time intervals based on particular interval
Carl Wyand/Populate Datagrid with Directory filenames ( C#)
private void UpdateGrid()
{
string dirPath = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings.Get("CompanyFormsDirectory"));
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("LinkFile", typeof(string)));
dt.Columns.Add(new DataColumn("LinkUrl", typeof(string)));
// Read from the directory and store contents in a stream
if (Directory.Exists(dirPath))
{
// Make a reference to a directory.
DirectoryInfo di = new DirectoryInfo(dirPath);
// Get a reference to each file in that directory.
FileInfo[] fiArr = di.GetFiles();
// Display the names of the files.
foreach (FileInfo fri in fiArr)
{
if (!fri.Name .Equals ("vssver.scc"))
{
dr = dt.NewRow ();
dr[1] = "~/Content/SiteMap/Agents/CompanyForms/" + fri.Name ;
int strDot = fri.Name.IndexOf('.');
string linkToFile = fri.Name.Remove(strDot, (int)(fri.Name.Length - (long)strDot));
dr[0] = linkToFile;
dt.Rows.Add(dr);
}
}
dgFiles.DataSource = dt;
dgFiles.DataBind();
if (dgFiles.Items.Count > 0)
dgFiles.Visible = true;
}
}
Reads the names of files in a directory and populates a datagrid with the list. Includes hyperlinks in the filenames to enable user to click on filename link and open the file.
Bort/Populating ListBoxes ( VB.NET)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Add items to ListBox
Me.ListBox1.Items.Add("Red")
Me.ListBox1.Items.Add("Green")
Me.ListBox1.Items.Add("Yellow")
Me.ListBox1.Items.Add("Blue")
End Sub
This is a pretty easy one showing you how to add items to a ListBox from within the code.
Sacid/Gelişmiş populer konular ( PHP)
index.template.php
(BUL)
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/fonts-compat.css" />';
SONRASINA EKLE
// Geli�mi� Popüler Konular Modifikasyonu by d-gan //
echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/tabview/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/tabview/tabview.css" />
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/tabview/yahoo-dom-event.js"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/tabview/element-beta-min.js"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/tabview/tabview-min.js"></script>';
// Geli�mi� Popüler Konular Modifikasyonu by d-gan //
BUL:
<body>
DE�İ�TİR:
<body class=" yui-skin-sam">
BoardIndex.template.php
BUL:
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/fader.js"></script>
</td>
</tr>
</table>';
}
SONRASINA EKLE:
// Geli�mi� Popüler Konular Modifikasyonu by d-gan //
echo '
<div id="d-gan" class="yui-navset">
<ul class="yui-nav">
<li><a href="#tab1"><em>Son Mesajlar</em></a></li>
<li class="selected"><a href="#tab2"><em>Populer Bölümler</em></a></li>
<li><a href="#tab3"><em>En �ok Okunan Konular</em></a></li>
<li><a href="#tab3"><em>Son Cevaplanan Konular</em></a></li>
</ul>
<div class="yui-content">';
echo '<div id="tab1">';
// This is the "Recent Posts"
if (!empty($settings['number_recent_posts']))
{
// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
<div class="smalltext">
', $txt[234], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt[235], ' (', $context['latest_post']['time'], ')<br />
</div>';
}
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table class="windowbg2" cellspacing="1" width="100%" cellpadding="0" border="0">
';
/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td valign="top" width="29%">', $post['board']['link'], '</td>
<td valign="top" width="27%"><a href="', $post['href'],'">', $post['short_subject'], '</td>
<td valign="top" width="15%">', $post['poster']['link'], '</td>
<td aling="right" valign="top" width="29%"><div align="right">', $post['time'], '</div></td>
</tr>';
echo '
</table>';
}
}echo '</div>';
echo ' <div id="tab1"><table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_boards'] as $board)
echo '
<tr>
<td width="60%" valign="top">', $board['link'], '</td>
<td width="20%" align="left" valign="top">', $board['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $board['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $board['num_posts'], '</td>
</tr>';
echo '
</table></div>';
echo '<div id="tab2"><table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_topics_views'] as $topic)
echo '
<tr>
<td width="60%" valign="top">', $topic['link'], '</td>
<td width="20%" align="left" valign="top">', $topic['num_views'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $topic['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $topic['num_views'], '</td>
</tr>';
echo '
</table></div>';
echo '<div id="tab3"><table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_topics_replies'] as $topic)
echo '
<tr>
<td width="60%" valign="top">', $topic['link'], '</td>
<td width="20%" align="left" valign="top">', $topic['num_replies'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $topic['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $topic['num_replies'], '</td>
</tr>';
echo '
</table></div>
</div>
</div>
<script>
(function() {
var tabView = new YAHOO.widget.TabView(\'d-gan\');
YAHOO.log("The example has finished loading; as you interact with it, you\'ll see log messages appearing here.", "info", "example");
})();
</script>
<br /> ';
// Geli�mi� Popüler Konular Modifikasyonu by d-gan //
Boardindex.php
BUL:
// Remember the most recent topic for optimizing the recent posts feature.
$most_recent_topic = array(
'timestamp' => 0,
'ref' => null
);
SONRASINA EKLE
// Geli�mi� Popüler Konular Modifikasyonu by d-gan //
// Son cevaplanan konular //
$topic_reply_result = db_query("
SELECT m.subject, t.numReplies, t.ID_BOARD, t.ID_TOPIC, b.name
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MSG = t.ID_FIRST_MSG
AND $user_info[query_see_board]" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND t.ID_BOARD = b.ID_BOARD" . (!empty($topic_ids) ? "
AND t.ID_TOPIC IN (" . implode(', ', $topic_ids) . ")" : '') . "
ORDER BY t.numReplies DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_topics_replies'] = array();
$max_num_replies = 1;
while ($row_topic_reply = mysql_fetch_assoc($topic_reply_result))
{
censorText($row_topic_reply['subject']);
$context['top_topics_replies'][] = array(
'id' => $row_topic_reply['ID_TOPIC'],
'board' => array(
'id' => $row_topic_reply['ID_BOARD'],
'name' => $row_topic_reply['name'],
'href' => $scripturl . '?board=' . $row_topic_reply['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row_topic_reply['ID_BOARD'] . '.0">' . $row_topic_reply['name'] . '</a>'
),
'subject' => $row_topic_reply['subject'],
'num_replies' => $row_topic_reply['numReplies'],
'href' => $scripturl . '?topic=' . $row_topic_reply['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['ID_TOPIC'] . '.0">' . $row_topic_reply['subject'] . '</a>'
);
if ($max_num_replies < $row_topic_reply['numReplies'])
$max_num_replies = $row_topic_reply['numReplies'];
}
mysql_free_result($topic_reply_result);
foreach ($context['top_topics_replies'] as $i => $topic)
$context['top_topics_replies'][$i]['post_percent'] = round(($topic['num_replies'] * 100) / $max_num_replies);
// Son cevaplanan konular //
// En �ok Okunan Konular //
$topic_view_result = db_query("
SELECT m.subject, t.numViews, t.ID_BOARD, t.ID_TOPIC, b.name
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MSG = t.ID_FIRST_MSG
AND $user_info[query_see_board]" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND t.ID_BOARD = b.ID_BOARD" . (!empty($topic_ids) ? "
AND t.ID_TOPIC IN (" . implode(', ', $topic_ids) . ")" : '') . "
ORDER BY t.numViews DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_topics_views'] = array();
$max_num_views = 1;
while ($row_topic_views = mysql_fetch_assoc($topic_view_result))
{
censorText($row_topic_views['subject']);
$context['top_topics_views'][] = array(
'id' => $row_topic_views['ID_TOPIC'],
'board' => array(
'id' => $row_topic_views['ID_BOARD'],
'name' => $row_topic_views['name'],
'href' => $scripturl . '?board=' . $row_topic_views['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row_topic_views['ID_BOARD'] . '.0">' . $row_topic_views['name'] . '</a>'
),
'subject' => $row_topic_views['subject'],
'num_views' => $row_topic_views['numViews'],
'href' => $scripturl . '?topic=' . $row_topic_views['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['ID_TOPIC'] . '.0">' . $row_topic_views['subject'] . '</a>'
);
if ($max_num_views < $row_topic_views['numViews'])
$max_num_views = $row_topic_views['numViews'];
}
mysql_free_result($topic_view_result);
foreach ($context['top_topics_views'] as $i => $topic)
$context['top_topics_views'][$i]['post_percent'] = round(($topic['num_views'] * 100) / $max_num_views);
// En �ok Okunan Konular //
// Populer Bölümler //
$boards_result = db_query("
SELECT ID_BOARD, name, numPosts
FROM {$db_prefix}boards AS b
WHERE $user_info[query_see_board]" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
ORDER BY numPosts DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_boards'] = array();
$max_num_posts = 1;
while ($row_board = mysql_fetch_assoc($boards_result))
{
$context['top_boards'][] = array(
'id' => $row_board['ID_BOARD'],
'name' => $row_board['name'],
'num_posts' => $row_board['numPosts'],
'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['name'] . '</a>'
);
if ($max_num_posts < $row_board['numPosts'])
$max_num_posts = $row_board['numPosts'];
}
mysql_free_result($boards_result);
foreach ($context['top_boards'] as $i => $board)
$context['top_boards'][$i]['post_percent'] = round(($board['num_posts'] * 100) / $max_num_posts);
// Populer Bölümler //
// Geli�mi� Popüler Konular Modifikasyonu by d-gan //
devb0yax/NSDictionary populating to table view ( iPhone)
.h file:
@interface ResultsViewController : UITableViewController
{
NSMutableArray *m_list;
NSDictionary *localDict;
}
@property(nonatomic,retain) NSMutableArray *m_list;
@end
========================
.m file:
- (void)viewDidLoad {
[super viewDidLoad];
NSDictionary *tempDict;
AdInfo *shAdInfo = [AdInfo sharedAdInfo];
tempDict = shAdInfo.adInfoDict;
int nCountDict = [tempDict count];
NSLog(@"nCountDict: %d", nCountDict);
////////////////////////
NSMutableArray *myMutableArr = [[NSMutableArray alloc] init];
int ctr;
for(ctr = 1; ctr <= nCountDict; ctr++)
{
localDict = [tempDict objectForKey:[NSString stringWithFormat:@"%d", ctr]];
[myMutableArr addObject:localDict];
}
self.m_list = myMutableArr;
[myMutableArr release];
NSLog(@"m_list count: %d", [m_list count]);
}
.....
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSUInteger row = [indexPath row];
NSDictionary *newDict = [NSDictionary dictionaryWithDictionary:[m_list objectAtIndex:row]];
//NSLog(@"newDict desc: %@", [newDict description]);
NSString *rowString = [newDict objectForKey:@"text"];
cell.textLabel.text = rowString;
[rowString release];
return cell;
}
solgems/initialising and populating an array of Sprites ( Objective C)
for (int i = 0; i < 9; i++ ) {
//create a slot object with a label
//add the object to the slots array
//sprite
[slots addObject: [[[Slot alloc] initWithSprite:[CCSprite spriteWithFile:@"hole.png"]
withPos_x:count%3*cellWidth+offset_x
withPos_y:count/3*cellHeight+offset_y
isOccupied:NO] autorelease]];
//add the sprite to the layer
[self addChild: ((Slot*) [slots objectAtIndex:i]).sprite];
count++;
}
Himanshu Kaushik/Populating Dataset from multiple Dataadapter ( C#)
SqlConnection custConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind;");
SqlDataAdapter custDA = new SqlDataAdapter("SELECT * FROM Customers", custConn);
OleDbConnection orderConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=c:\\Program Files\\Microsoft Office\\Office\\Samples\\northwind.mdb;");
OleDbDataAdapter orderDA = new OleDbDataAdapter("SELECT * FROM Orders", orderConn);
custConn.Open();
orderConn.Open();
DataSet custDS = new DataSet();
custDA.Fill(custDS, "Customers");
orderDA.Fill(custDS, "Orders");
custConn.Close();
orderConn.Close();
DataRelation custOrderRel = custDS.Relations.Add("CustOrders",
custDS.Tables["Customers"].Columns["CustomerID"],
custDS.Tables["Orders"].Columns["CustomerID"]);
foreach (DataRow pRow in custDS.Tables["Customers"].Rows)
{
Console.WriteLine(pRow["CustomerID"]);
foreach (DataRow cRow in pRow.GetChildRows(custOrderRel))
Console.WriteLine("\t" + cRow["OrderID"]);
}
Populating Dataset from multiple Dataadapter
David Carter/HQL ISQLQuery Query Populating a Datatable ( C#)
public DataTable CreatePageFlexBulkMailDataTable(int subscriberID, int campaignID)
{
StringBuilder s = new StringBuilder();
s.Append("Select cm.id as CampaignID, c.subscriber_id as SubscriberID, ");
s.Append("c.id as ContactID, null as CoContactID, c.last_name as LastName, c.first_name as FirstName, ");
s.Append("a.address_line_1 as AddressLine1, a.address_line_2 as AddressLine2, ");
s.Append("a.city as City, a.state as State, a.zip as Zip, c.mailing_label as Label, ");
s.Append("DATENAME(MM, c.date_of_birth) + ' ' + CAST(DAY(c.date_of_birth) AS VARCHAR(2)) as BirthDate, ");
s.Append("c.salutation as Salutation, cm.default_personal_message as PersonalMessage, ");
s.Append("DATENAME(MM, c.review_date) + ' ' + CAST(DAY(c.review_date) AS VARCHAR(2)) as ReviewDate, ");
s.Append("'' as ArmExpirationDate, '' as ArmInterestRate ");
s.Append("from contact c ");
s.Append("inner join campaign cm on cm.id = :campaignID ");
s.Append("inner join address a on c.address_id = a.id ");
s.Append("where c.subscriber_id = :subscriberID and c.include_bulkmail = 'true'");
ISQLQuery q = session.CreateSQLQuery(s.ToString());
q.AddScalar("CampaignID", NHibernateUtil.String);
q.AddScalar("SubscriberID", NHibernateUtil.String);
q.AddScalar("ContactID", NHibernateUtil.String);
q.AddScalar("CoContactID", NHibernateUtil.String);
q.AddScalar("LastName", NHibernateUtil.String);
q.AddScalar("FirstName", NHibernateUtil.String);
q.AddScalar("AddressLine1", NHibernateUtil.String);
q.AddScalar("AddressLine2", NHibernateUtil.String);
q.AddScalar("City", NHibernateUtil.String);
q.AddScalar("State", NHibernateUtil.String);
q.AddScalar("Zip", NHibernateUtil.String);
q.AddScalar("Label", NHibernateUtil.String);
q.AddScalar("BirthDate", NHibernateUtil.String);
q.AddScalar("Salutation", NHibernateUtil.String);
q.AddScalar("PersonalMessage", NHibernateUtil.String);
q.AddScalar("ReviewDate", NHibernateUtil.String);
q.AddScalar("ArmExpirationDate", NHibernateUtil.String);
q.AddScalar("ArmInterestRate", NHibernateUtil.String);
q.SetInt32("subscriberID", subscriberID);
q.SetInt32("campaignID", campaignID);
// Datatable
DataTable dt = new DataTable();
// query returns an IList of Object[] s
IList<object[]> oas = q.List<object[]>();
if (oas.Count > 0)
{
// Add Columns
dt.Columns.Add("CampaignID");
dt.Columns.Add("SubscriberID");
dt.Columns.Add("ContactID");
dt.Columns.Add("CoContactID");
dt.Columns.Add("LastName");
dt.Columns.Add("FirstName");
dt.Columns.Add("AddressLine1");
dt.Columns.Add("AddressLine2");
dt.Columns.Add("City");
dt.Columns.Add("State");
dt.Columns.Add("Zip");
dt.Columns.Add("Label");
dt.Columns.Add("BirthDate");
dt.Columns.Add("Salutation");
dt.Columns.Add("PersonalMessage");
dt.Columns.Add("ReviewDate");
dt.Columns.Add("ArmExpirationDate");
dt.Columns.Add("ArmInterestRate");
// Scroll threw object records and populate datarow
foreach (object[] o in oas)
{
DataRow dr;
dr = dt.NewRow();
dr[0] = (o[0] != null) ? o[0].ToString() : "";
dr[1] = (o[1] != null) ? o[1].ToString() : "";
dr[2] = (o[2] != null) ? o[2].ToString() : "";
dr[3] = (o[3] != null) ? o[3].ToString() : "";
dr[4] = (o[4] != null) ? o[4].ToString() : "";
dr[5] = (o[5] != null) ? o[5].ToString() : "";
dr[6] = (o[6] != null) ? o[6].ToString() : "";
dr[7] = (o[7] != null) ? o[7].ToString() : "";
dr[8] = (o[8] != null) ? o[8].ToString() : "";
dr[9] = (o[9] != null) ? o[9].ToString() : "";
dr[10] = (o[10] != null) ? o[10].ToString() : "";
dr[11] = (o[11] != null) ? o[11].ToString() : "";
dr[12] = (o[12] != null) ? o[12].ToString() : "";
dr[13] = (o[13] != null) ? o[13].ToString() : "";
dr[14] = (o[14] != null) ? o[14].ToString() : "";
dr[15] = (o[15] != null) ? o[15].ToString() : "";
dr[16] = (o[16] != null) ? o[16].ToString() : "";
dr[17] = (o[17] != null) ? o[17].ToString() : "";
dt.Rows.Add(dr);
}
}
return dt;
}
This is a large ISqlQuery in NHIbernate which populates a datatable