private void btn_Submit_Click(object sender, EventArgs e)
        {
            Global_Function_Varaible.Con_Open();

            SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM tbl_Login_Emp WHERE Username = '******' AND Password = '******'", Global_Function_Varaible.con);

            if (Convert.ToInt32(cmd.ExecuteScalar()) > 0)
            {
                MessageBox.Show("Login Successfull", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                Global_Function_Varaible.UName = tb_Username.Text;

                MDI_Employee_Details MObj = new MDI_Employee_Details();
                MObj.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Invalid Username or Password", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Global_Function_Varaible.Con_Close();

            tb_Username.Text = "";
            tb_Password.Text = "";
            tb_Username.Focus();
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            Global_Function_Varaible.Con_Open();

            if (tb_ID.Text != "" && tb_Name.Text != "")
            {
                SqlDataAdapter sda = new SqlDataAdapter("INSERT INTO tbl_Add_Qualification VALUES(" + tb_ID.Text + ",'" + tb_Name.Text + "')", Global_Function_Varaible.con);

                DataTable dt = new DataTable();

                sda.Fill(dt);

                MessageBox.Show("Data Added Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else
            {
                MessageBox.Show("1st Fill All The Fields", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Global_Function_Varaible.Con_Close();
            tb_ID.Text   = Convert.ToString(Auto_Increment());
            tb_Name.Text = "";
            tb_Name.Focus();
        }
Exemple #3
0
        private void frm_View_All_Employee_Load(object sender, EventArgs e)
        {
            Global_Function_Varaible.Con_Open();

            SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM tbl_Add_Emp", Global_Function_Varaible.con);

            DataTable dt = new DataTable();

            sda.Fill(dt);
            dgv_View_All_Emp.DataSource = dt;

            Global_Function_Varaible.Con_Close();
        }
        private void cmb_Qualification_SelectedIndexChanged(object sender, EventArgs e)
        {
            Global_Function_Varaible.Con_Open();

            SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM tbl_Add_Emp WHERE Qualification = '" + cmb_Qualification.Text + "'", Global_Function_Varaible.con);

            DataTable dt = new DataTable();

            sda.Fill(dt);

            dgv_View_All_Emp.DataSource = dt;

            Global_Function_Varaible.Con_Close();
        }
        int Auto_Increment()
        {
            int iCnt = 0;

            Global_Function_Varaible.Con_Open();

            SqlCommand cmd = new SqlCommand("SELECT COUNT(ID) FROM tbl_Add_Qualification", Global_Function_Varaible.con);

            iCnt = Convert.ToInt32(cmd.ExecuteScalar());

            iCnt = 101 + iCnt;

            Global_Function_Varaible.Con_Close();

            return(iCnt);
        }
        private void btn_Reset_Click(object sender, EventArgs e)
        {
            tb_ID.Text = "";
            cmb_Qualification.SelectedIndex = -1;

            Global_Function_Varaible.Con_Open();

            SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM tbl_Add_Emp", Global_Function_Varaible.con);

            DataTable dt = new DataTable();

            sda.Fill(dt);
            dgv_View_All_Emp.DataSource = dt;

            Global_Function_Varaible.Con_Close();
        }
        private void Add_Employee_Detail_Load(object sender, EventArgs e)
        {
            tb_Employee_ID.Text = Convert.ToString(Auto_Increment());

            Global_Function_Varaible.Con_Open();

            SqlCommand cmd = new SqlCommand("SELECT Name FROM tbl_Add_Qualification", Global_Function_Varaible.con);

            var obj = cmd.ExecuteReader();

            while (obj.Read())
            {
                cmb_Qualification.Items.Add(obj.GetString(obj.GetOrdinal("Name")));
            }

            Global_Function_Varaible.Con_Close();

            tb_Name.Focus();
        }
        private void frm_View_Emolyee_Detail_Dynamic_Load(object sender, EventArgs e)
        {
            Global_Function_Varaible.Con_Open();

            SqlCommand cmd = new SqlCommand("SELECT DISTINCT(Name) FROM tbl_Add_Qualification", Global_Function_Varaible.con);

            var obj = cmd.ExecuteReader();

            while (obj.Read())
            {
                cmb_Qualification.Items.Add(obj.GetString(obj.GetOrdinal("Name")));
            }

            obj.Dispose();

            SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM tbl_Add_Emp", Global_Function_Varaible.con);

            DataTable dt = new DataTable();

            sda.Fill(dt);
            dgv_View_All_Emp.DataSource = dt;

            Global_Function_Varaible.Con_Close();
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (tb_Name.Text != "" && tb_MobNo.Text != "" && cmb_Qualification.Text != "")
            {
                Global_Function_Varaible.Con_Open();

                SqlDataAdapter sda = new SqlDataAdapter("INSERT INTO tbl_Add_Emp VALUES(" + tb_Employee_ID.Text + ",'" + tb_Name.Text + "'," + tb_MobNo.Text + ",'" + dtp_DOB.Text + "','" + cmb_Qualification.Text + "')", Global_Function_Varaible.con);

                DataTable dt = new DataTable();

                sda.Fill(dt);

                MessageBox.Show("Record Filled Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                Global_Function_Varaible.Con_Close();
            }
            else
            {
                MessageBox.Show("1st Fill All The Fields", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Clear_Controls();
            tb_Employee_ID.Text = Convert.ToString(Auto_Increment());
            tb_Name.Focus();
        }