C# Classic Login Form With Admin and User Windows Application | School Management System


This is a free project that I create for people that first with c# language with source code it have SQL Server and Visual Studio project (2015).

Requirement 

  • Sql Sever 2014 Management Studio Installed
  • Microsoft Visual Studio Professionals 2015
  • C# Languages
Source Code 


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

namespace SMS_Management_System
{
    public partial class Frm_Security : Form
    {
        public Frm_Security()
        {
            InitializeComponent();
        }

        private void btclose_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btlogin_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=SONYVAIO\SQLEXPRESS;Initial Catalog=SMSManagement;Integrated Security=true;");
            SqlCommand cmd = new SqlCommand("SELECT * FROM tbllogin WHERE ln_user='" + txtuser.Text + "'and ln_pass = '" + txtpass.Text + "'", con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            string cmdItem = cbtype.SelectedItem.ToString();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["ln_usertype"].ToString() == cmdItem)
                    {
                        MessageBox.Show("You are login as " + dt.Rows[i][5]);
                        if(cbtype.SelectedIndex == 0)
                        {
                            Frm_Home home = new Frm_Home();
                            home.Show();
                            this.Hide();
                        }else
                        {
                            Frm_Home_User home2 = new Frm_Home_User();
                            home2.Hide();
                            home2.Show();
                            
                        }
                    }
                }
            }else
            {
                MessageBox.Show("Error");
            }
        }
    }
} 


Download Project C# School Management System

1 Comments

Post a Comment

Post a Comment

Previous Post Next Post