Exemple #1
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 #2
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);
                    }
                }
            }
        }