Student Information system in C# Task

May 31, 2013

Student Information system in C# Task

Develop an application that meets following screens and validation requirements
1.      Each forms’ and controls’ Text or Name properties should be set with meaningful values (no form1, textBox1 etc.).

2.      There is an initial Entry Screen that takes student registration Id and Name as input and uses a Submit         button to accept input and Exit button to exit the application.
a.      Perform validation on registration Id (5 digit)
b.      Perform validation on name (no blank values accepted)

3.      Upon Submit, a Main screen opens up and displays user name with following message:
"Hello <user name>! Welcome to the Student Information Center.
a.      Provide 3 options (buttons or picture boxes) for user to navigate to “Read Student Information” screen, “Add Student Information” screen and “Email Subscription Screen”.
b.      Provide a 4th option to Exit: Ask user if they really want to exit using a message box when user tries to exit.

4.      Read information screen should use MenuStrip to select following types of information to read: Alerts, Events, News. You can simply display or hide 3 different types of labels with information upon selection.

5.      Add information screen should use ToolStrip to select following types of information to add: Alerts, Events, News. You can simply display different set of controls upon selection.

6.      Email Subscription screen should have following fields to enter data:
a.      Registration Id (pre-filled what was passed from the first screen)
b.      Student Name (pre-filled what was passed from the first screen)
c.       Email Address (validate email address format)

7.      On return from each of the three screens, pass back some data to indicate that you visited such and such screens and display it on Main screen.


Code

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

namespace _22mar
{
    public partial class Entry_form : Form
    {
        public Entry_form()
        {
            InitializeComponent();
        }

        private void exit1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void submit1_Click(object sender, EventArgs e)
        {
        
            string nam = mk2.Text;
            string reg = mk1.Text;
            Main_panel mp = new Main_panel(nam,reg);
           
            mp.ShowDialog();
        }

        private void mk2_Validating(object sender, CancelEventArgs e)
        {
            if (mk2.Text.Length ==0)
                e.Cancel = true
        }

        private void Entry_form_Load(object sender, EventArgs e)
        {

        }

        private void Entry_form_FormClosing(object sender, FormClosingEventArgs e)
        {
             DialogResult result;
            result= MessageBox.Show("Are you sure you want exit the application", "Done?",MessageBoxButtons.YesNo);
            if (DialogResult.No==result)
                e.Cancel=true;
           
        }
    }
}



Read_Form:

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

namespace _22mar
{
    public partial class Read_Form : Form
    {
        public Read_Form()
        {
            InitializeComponent();
        }

        private void ok1_Click(object sender, EventArgs e)
        {
            this.Close();
           
        }

        private void readNewsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lbnews.Visible = true;
            lbalerts.Visible = false;
            lbevent.Visible = false;
        }

        private void readAlertsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lbalerts.Visible = true;
            lbevent.Visible = false;
            lbnews.Visible = false;
        }

        private void readEventsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lbevent.Visible = true;
            lbnews.Visible = false;
            lbalerts.Visible = false;
        }
    }
}

Add_form

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

namespace _22mar
{
    public partial class add_form : Form
    {
        public add_form()
        {
            InitializeComponent();
        }

        private void toolStripLabel2_Click(object sender, EventArgs e)
        {
            table_news.Visible = true;
            table_alerts.Visible = false;
            table_events.Visible = false;
        }

        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            table_news.Visible = false;
            table_alerts.Visible = true;
            table_events.Visible = false;
        }

        private void toolStripLabel3_Click(object sender, EventArgs e)
        {
            table_news.Visible = false;
            table_alerts.Visible = false;
            table_events.Visible = true;
        }

        private void ok2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

ID_Form

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

namespace _22mar
{
    public partial class ID_form : Form
    {
        public ID_form(string nam, string reg)
        {
            InitializeComponent();
            textBox1.Text = reg;
            textBox2.Text=nam;

           
        }

        private void ID_form_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_Validating(object sender, CancelEventArgs e)
        {
            //try
            //{
            //    MailAddress mail = new MailAddress(textBox3.Text);
            //    e.Cancel = true;
            //}
            //catch(FormatException)
            //{
            //    e.Cancel = true;
            //}
            if (IsValidEmailAddress(textBox3.Text) == false)
            {
                e.Cancel = true;
            }
        }
        public static bool IsValidEmailAddress(string sEmail)
        {
            if (sEmail == null)
            {
                return false;
            }

            int nFirstAT = sEmail.IndexOf('@');
            int nLastAT = sEmail.LastIndexOf('@');

            if ((nFirstAT > 0) && (nLastAT == nFirstAT) &&
            (nFirstAT < (sEmail.Length - 9)))
            {
                // address is ok regarding the single @ sign
                return true;
            }
            else
            {
                return false;
            }
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void ok3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

Main_Panel

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

namespace _22mar
{
    public partial class Main_panel : Form
    {
        public Main_panel(string nam, string reg)
        {
            InitializeComponent();
            lbname.Text = nam;
            lbreg.Text = reg;
         
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void read_Click(object sender, EventArgs e)
        {
            Read_Form rd = new Read_Form();
            rd.Show();
            label2.Text = "";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            add_form ad = new add_form();
            ad.Show();
            label2.Text = "Update Successful!!";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            ID_form idf = new ID_form(lbname.Text,lbreg.Text);
            label2.Text = "";
            idf.ShowDialog();
           
        }
    }
}

Screen Shots










You Might Also Like

1 comments

Popular Posts

Like us on Facebook

Flickr Images