from main

September 8, 2008

from main.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Login
{
    public partial class frmMain : Form
    {
        string id;
        public frmMain()
        {
            InitializeComponent();
        }
        public frmMain(string user, string pass, string id)
        {
            InitializeComponent();
            textBox1.Text = user;
            textBox2.Text = pass;
            this.id = id;

        }
        private void button1_Click(object sender, EventArgs e)
        {
            Class1 newConnect = new Class1();
            newConnect.query_add("UPDATE loginTbl set Username = ‘"+textBox1.Text+"’, Password = ‘"+textBox2.Text+"’ WHERE UserID =’"+this.id+"’");
            MessageBox.Show("You have Successfully Updated Your Username and Password");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Class1 newConnect = new Class1();
            newConnect.query_add("DELETE from loginTbl WHERE UserID =’"+this.id+"’");
            MessageBox.Show("You have Successfully Deleted Your Username and Password");
        }
    }
}

class1

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace Login
{
    class Class1
    {
        private SqlDataReader _select;
        public SqlDataReader select
        {
            get
            {
                return _select;
            }
            set
            {
                _select = value;
            }
        }

        public void query_select(string query)
        {
            SqlConnection c = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Admin\Desktop\Login Midterm\Login Midterm\loginDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
            c.Open();
            SqlCommand q = new SqlCommand(query, c);
            SqlDataReader r = q.ExecuteReader();
            this.select = r;
        }
        public void query_add(string query)
        {
            SqlConnection c = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Admin\Desktop\Login Midterm\Login Midterm\loginDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
            c.Open();
            SqlCommand q = new SqlCommand();
            q.Connection = c;
            q.CommandText = query;
            q.ExecuteNonQuery();
            c.Close();
        }
    }
}

log.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Login
{
    public partial class frmLog : Form
    {
        public frmLog()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            Class1 newConnect = new Class1();
            newConnect.query_select("SELECT * FROM loginTbl WHERE Username like ‘"+textBox1.Text+"’ and Password like ‘"+textBox2.Text+"’");
            if (newConnect.select.HasRows == true)
            {
                newConnect.select.Read();
                string username = newConnect.select["Username"].ToString();
                string password = newConnect.select["Password"].ToString();
                string id = newConnect.select["UserID"].ToString();
                frmMain a = new frmMain(username,password,id);
                a.Show();
            }
            else
            {
                MessageBox.Show("Invalid Username and/or Password");
            }
        }
    }
}

foods security

September 1, 2008

Food security refers to the situation wherein all people, at all times, have access to sufficient, nutritious, safe, personally acceptable and culturally appropriate foods, produced in ways that are environmentally sound and socially just. Like most developing countrie, the Philippines considers food security as a priority for rural and economic development. However, this issue has been tied up with poverty, particularly in rural areas where 70% of our populations resides, making it an urgent problem. To boost food security in the Philippines, the government came up with a two-pronged approach to ensure the contury’s food security and imporve the production of our crops and the productivity of our agricultural workers, and combat the problem of hunger and malnutrition espcecially among the poor.