private void btnsave_Click(object sender, EventArgs e)
 {
     if (maskedTextBox1.Text == "" || comboBox1.Text == "")
     {
         Verification.Input();
     }
     else
     {
         try
         {
             SqlCommand cmd = new SqlCommand();
             cmd.Connection  = DbConnection.con;
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.CommandText = "Academic";
             DbConnection.con.Open();
             cmd.Parameters.AddWithValue("@year", maskedTextBox1.Text);
             cmd.Parameters.AddWithValue("@semester", comboBox1.Text);
             cmd.ExecuteNonQuery();
             DbConnection.con.Close();
             Verification.Save();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void Change()
 {
     DbConnection.checkConnection();
     if (textBoxCurrent.Text == "" || textBoxnew.Text == "" || textBoxrepass.Text == "")
     {
         Verification.Input();
     }
     else if (textBoxnew.Text != textBoxrepass.Text)
     {
         Verification.PasswordMatch();
     }
     else
     {
         try
         {
             DbConnection.con.Open();
             SqlCommand    cmd = new SqlCommand("SELECT Password FROM Admin WHERE Password='******';", DbConnection.con);
             SqlDataReader read;
             read = cmd.ExecuteReader();
             if (read.Read())
             {
                 DbConnection.checkConnection();
                 DbConnection.con.Open();
                 SqlCommand change = new SqlCommand();
                 change.Connection  = DbConnection.con;
                 change.CommandType = CommandType.StoredProcedure;
                 change.CommandText = "UpdatePassword";
                 change.Parameters.AddWithValue("@password", textBoxnew.Text);
                 change.ExecuteNonQuery();
                 DbConnection.con.Close();
                 Verification.Update();
             }
             else
             {
                 MessageBox.Show("Invalid Current password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 DbConnection.con.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemple #3
0
        private void btnupdate_Click(object sender, EventArgs e)
        {
            if (IdUpdate.Text == "")
            {
                MessageBox.Show("Please select Row that you want update", "Selection error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                Gender();
                Account();
                if (textBoxName.Text == "" || TextBoxcnic.Text == "" || textBoxaddress.Text == "" || textBoxcity.Text == "" || textBoxmail.Text == "" || textBoxphone.Text == "" || comboBoxjobType.Text == "" || comboBoxempType.Text == "")
                {
                    Verification.Input();
                }
                //else if (imageLocation == "")
                //{
                //    Verification.Picture();
                //}
                else if (gender == "")
                {
                    Verification.Gender();
                }
                else if (account == "")
                {
                    Verification.AccountStatus();
                }
                else
                {
                    try
                    {
                        if (DbConnection.con.State != ConnectionState.Open)
                        {
                            DbConnection.con.Open();
                        }

                        //byte[] image = null;
                        //FileStream fs = new FileStream(imageLocation, FileMode.Open, FileAccess.Read);
                        //BinaryReader br = new BinaryReader(fs);
                        //image = br.ReadBytes((int)fs.Length);
                        //////////////////////////////////////////////////////////////////////////////
                        SqlCommand cmd = new SqlCommand();

                        cmd.Connection  = DbConnection.con;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "EmpUpdate";
                        cmd.Parameters.AddWithValue("@name", textBoxName.Text);
                        //cmd.Parameters.AddWithValue("@cnic", TextBoxcnic.Text);
                        cmd.Parameters.AddWithValue("@cnic1", IdUpdate.Text);
                        //cmd.Parameters.AddWithValue("@gender", gender);
                        cmd.Parameters.AddWithValue("@address", textBoxaddress.Text);
                        cmd.Parameters.AddWithValue("@city", textBoxcity.Text);
                        cmd.Parameters.AddWithValue("@accountStatus", account);
                        cmd.Parameters.AddWithValue("@email", textBoxmail.Text);
                        cmd.Parameters.AddWithValue("@mobile", textBoxphone.Text);
                        cmd.Parameters.AddWithValue("@dob", dateTimedob.Text);
                        cmd.Parameters.AddWithValue("@joinDate", dateTimejoin.Text);
                        cmd.Parameters.AddWithValue("@jobType", comboBoxjobType.Text);
                        cmd.Parameters.AddWithValue("@empType", comboBoxempType.Text);
                        //cmd.Parameters.Add(new SqlParameter("@picture", image));
                        //cmd.Parameters.Add(new SqlParameter("@picture", image));
                        cmd.ExecuteNonQuery();
                        Verification.Update();
                        DbConnection.con.Close();
                        gridView();
                        Reset();
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemple #4
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (prints.Count != 0)
            {
                foreach (Byte[] b in prints)
                {
                    saveprints(b);
                }
            }
            else
            {
                MessageBox.Show("Please Enter Your Finger Prints");
            }

            Gender();
            Account();
            if (textBoxName.Text == "" || TextBoxcnic.Text == "" || textBoxaddress.Text == "" || textBoxcity.Text == "" || textBoxmail.Text == "" || textBoxphone.Text == "" || comboBoxjobType.Text == "" || comboBoxempType.Text == "")
            {
                Verification.Input();
            }
            else if (imageLocation == "")
            {
                Verification.Picture();
            }
            else if (gender == "")
            {
                Verification.Gender();
            }
            else if (account == "")
            {
                Verification.AccountStatus();
            }
            else
            {
                SqlCommand   cmdChk = new SqlCommand("select EmpCNIC from EmpRegistration where EmpCNIC='" + TextBoxcnic.Text + "';", DbConnection.con);
                SqlParameter param  = new SqlParameter();
                if (DbConnection.con.State != ConnectionState.Open)
                {
                    DbConnection.con.Open();
                }
                param.Value = this.TextBoxcnic.Text;
                cmdChk.Parameters.Add(param);
                SqlDataReader read = cmdChk.ExecuteReader();
                if (read.HasRows)
                {
                    DbConnection.con.Close();
                    Verification.Duplicate();
                }
                else
                {
                    try
                    {
                        DbConnection.con.Close();
                        if (DbConnection.con.State != ConnectionState.Open)
                        {
                            DbConnection.con.Open();
                        }
                        byte[]       image = null;
                        FileStream   fs    = new FileStream(imageLocation, FileMode.Open, FileAccess.Read);
                        BinaryReader br    = new BinaryReader(fs);
                        image = br.ReadBytes((int)fs.Length);
                        //////////////////////////////////////////////////////////////////////////////
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = DbConnection.con;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "Registration";
                        cmd.Parameters.AddWithValue("@name", textBoxName.Text.TrimEnd());
                        cmd.Parameters.AddWithValue("@cnic", TextBoxcnic.Text);
                        cmd.Parameters.AddWithValue("@gender", gender);
                        cmd.Parameters.AddWithValue("@address", textBoxaddress.Text);
                        cmd.Parameters.AddWithValue("@city", textBoxcity.Text);
                        cmd.Parameters.AddWithValue("@accountStatus", account);
                        cmd.Parameters.AddWithValue("@email", textBoxmail.Text);
                        cmd.Parameters.AddWithValue("@mobile", textBoxphone.Text);
                        cmd.Parameters.AddWithValue("@dob", dateTimedob.Text);
                        cmd.Parameters.AddWithValue("@joinDate", dateTimejoin.Text);
                        cmd.Parameters.AddWithValue("@jobType", comboBoxjobType.Text);
                        cmd.Parameters.AddWithValue("@empType", comboBoxempType.Text);
                        //cmd.Parameters.Add(new SqlParameter("@picture", image));
                        cmd.Parameters.Add(new SqlParameter("@picture", image));
                        cmd.Parameters.Add(new SqlParameter("@finger", image));
                        cmd.ExecuteNonQuery();
                        Verification.Save();
                        DbConnection.con.Close();
                        gridView();
                        Reset();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }