Monday, January 22, 2007

I Am So Bored

Since the recent toll hike, Mr. Andrew only comes every Thursdays… fetching me for cell. We will try to make it for Friday prayer meetings though. (Resolution: Attending at least ONCE every month :D) Scary! I think I’m slowly picking up the behaviours of a housewife a.k.a auntie. Am starting to cook, am collecting plastic containers, am ironing clothes more often and actively shop for discounted bed sheets! Die. Age is really catching up.

I am so bored.

Every time when it comes to lunch, we really have problem deciding where to eat. Hence, someone suggested building one simple lunch generator to do the picking. Lol, since i'm so free...here's something light. Try it if you share the same dilemma, just make sure u enter records to the db with relevant distance, don’t want to ular too long -,-" Have tried using App.Config to store all info. So much neater.


My Config:
<>
<>
< name="MainConnectionString" connectionstring="Network Library=DBMSSOCN;Data Source=localhost;Initial Catalog=RandomDb;User ID=randomDb;Password=randomDb" providername="System.Data.SqlClient">
< /connectionStrings>
< /configuration>

My Handler:
using System;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RandomLunchSelector
{
public partial class Form1 : Form
{
private Hashtable hash;

public Form1()
{
InitializeComponent();
}

private void GetSet(int isExpensive)
{
try
{
string conStr = ConfigurationManager.ConnectionStrings
["MainConnectionString"].ToString();

SqlConnection connection = new SqlConnection(conStr);
connection.Open();

string sql = "Select * from Lunch where isExpensive =" +isExpensive;
SqlCommand command = new SqlCommand(sql, connection);
SqlDataReader reader = command.ExecuteReader();
hash = new Hashtable();
int i = 1;

while (reader.Read())
{
hash.Add(i, reader["place"]);
i++;
}

connection.Close();
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.StackTrace);
}
}
private void Go()
{
Random random = new Random();
int maxItem = hash.Count;
int result = random.Next()% maxItem+1;
textBox1.Text = hash[result].ToString();
}
private void button1_Click(object sender, EventArgs e)
{
bool salaryIn = checkBox1.Checked;
int isExpensive =0;
if (salaryIn == true) isExpensive = 1;
GetSet(isExpensive);
Go();
}}}


A very simple but useful app to help us find our lunch destinations! Save the brain juice and let geeky acer boy do the picking :)

Labels: ,

4 Comments:

At 2:34 PM , Anonymous Anonymous said...

You sounded as if housewives are a discarded lot! No way girl, they are actually "home engineers". Name may sound 'janggih" but in real life housewives are money savers as well. All hubbies - present and future - should treasure all home engineers. Of course, skip the nagging traits (if its their habit)

 
At 3:57 PM , Blogger sugar.glider said...

Haha, my apologies to all housewives. I just feel older, coz some1 made a comment that i'm becoming like an auntie :D

 
At 11:18 PM , Blogger sugar.glider said...

YB, listen or not? Home engineers ok. You better treasure your wife next time. And let's all start saving... amen.

 
At 12:35 AM , Blogger sugar.glider said...

(Faint)very good family man you are! It's time it's time...

YB: Hey Ah Seong, come help papa take notebook.

YB KID: Sorry la pa, i'm busy playing 12 inch men. Can you take it yourself?

YB: * Grumble grumble...What's cooking honey?

YB Wife: Fried cucumber with onions.

YB: MMM... my favourite! Thank you wifey, i want you to know that i appreciate all home engineers. You are the best.

YB Wife: How was your day?

YB: My boss kept complaining about how stressful he is. I replied him:
"You got pressure, i also got pressure!"

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home