private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                s.ConnOpen();
                string          query   = "select * from employee where  (EmpID = '" + int.Parse(comboBox1.Text.Trim()) + "')";
                MySqlCommand    command = new MySqlCommand(query, s.ConPass());
                MySqlDataReader dtread  = command.ExecuteReader();
                if (dtread.Read())
                {
                    txtName.Text = (dtread["Name"].ToString());
                    txtNIC.Text  = (dtread["NIC"].ToString());
                    if (dtread["Gender"].ToString() == "F")
                    {
                        radioMale.Checked   = false;
                        radioFemale.Checked = true;
                    }
                    else
                    {
                        radioMale.Checked   = true;
                        radioFemale.Checked = false;
                    }

                    txtCont1.Text        = (dtread["Contact1"].ToString());
                    txtCont2.Text        = (dtread["Contact2"].ToString());
                    txtAdd1.Text         = (dtread["No"].ToString());
                    txtAdd2.Text         = (dtread["Street"].ToString());
                    txtAdd3.Text         = (dtread["Town"].ToString());
                    comDepart.Text       = (dtread["Department"].ToString());
                    comDesig.Text        = (dtread["Designation"].ToString());
                    dateTimePicker2.Text = (dtread["JoinDate"].ToString());
                    textBox1.Text        = (dtread["Basic"].ToString());
                }
                else
                {
                    comboBox1.ResetText();
                    txtName.Clear();
                    txtNIC.Clear();
                    txtCont1.Clear();
                    txtCont2.Clear();
                    txtAdd1.Clear();
                    txtAdd2.Clear();
                    txtAdd3.Clear();
                    textBox1.Clear();
                    comDepart.ResetText();
                    comDesig.ResetText();
                    radioFemale.Checked = false;
                    radioMale.Checked   = false;
                    MessageBox.Show("No Data found..!");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Oops: Something went wrong with the DB Connection Please try again\n\n" + ex.Message);
            }
            s.ConnClose();
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            ConnectServer sr = new ConnectServer();

            try
            {
                string           qry = "select * from login where Designation='" + comLog.Text.Trim() + "' and UserName='******' and Password='******'";
                MySqlDataAdapter adp = new MySqlDataAdapter(qry, sr.ConPass());
                DataTable        dt  = new DataTable();
                adp.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    MessageBox.Show("Access Granted..!\n\n Welcome" + " " + txtUser.Text.Trim() + " " + "to the System");
                    this.Hide();
                    Home hom = new Home();
                    hom.Show();
                }
                else
                {
                    MessageBox.Show("Access Denied..\n Please Try Again..!");
                }
                comLog.ResetText();
                txtPass.Clear();
                txtUser.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Oops: Something went wrong with the DB Connection Please try again\n" + ex.Message);
            }
            sr.ConnClose();
        }
 public int EmpID() //generate new employee id and pass it to form
 {
     try
     {
         s.ConnOpen();
         MySqlCommand com = new MySqlCommand("select max(EmpID) from employee", s.ConPass());
         i = Convert.ToInt32(com.ExecuteScalar());
         s.ConnClose();
         i++;
     }
     catch (Exception ex)
     {
         MessageBox.Show("" + ex.Message);
     }
     return(i);
 }
        public bool empdetup(string a, string b, string c, string d, string e, string x)
        {
            string query = "update employee set Contact1='" + a + "',Contact2='" + b + "',No='" + c + "',Street='" + d + "',Town='" + e + "' where EmpID='" + x + "'";

            try
            {
                s.ConnOpen();
                MySqlCommand cmd = new MySqlCommand(query, s.ConPass());
                cmd.ExecuteNonQuery();
                val = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("error caught please contact the developers" + ex.Message);
            }
            s.ConnClose();
            return(val);
        }
Beispiel #5
0
        void FillComboID()
        {
            string query = "select * from employee where Designation='Labour'";

            command = new MySqlCommand(query, s.ConPass());
            MySqlDataReader dtread;

            try
            {
                s.ConnOpen();
                dtread = command.ExecuteReader();
                while (dtread.Read())
                {
                    comboBox1.Items.Add(dtread.GetString("EmpID"));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message);
            }
            s.ConnClose();
        }//fill combo empid
        void FillComboID()
        {
            string query = "select * from employee where (Designation='Admin'||Designation='Site supervisor'||Designation='Account Assistant'||Designation='Office Assistant')";

            command = new MySqlCommand(query, s.ConPass());
            MySqlDataReader dtread;

            try
            {
                s.ConnOpen();
                dtread = command.ExecuteReader();
                while (dtread.Read())
                {
                    comboBox1.Items.Add(dtread.GetString("EmpID"));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message);
            }
            s.ConnClose();
        }
Beispiel #7
0
        private void btnSign_Click(object sender, EventArgs e)//grant to database if everithing is fine
        {
            if (Passwordmatch() == true && CheckAdminPassword() == true)
            {
                try
                {
                    s.ConnOpen();
                    string       query = "insert into login (UserName,Password,Designation) values('" + txtUser.Text.Trim() + "','" + txtPass.Text.Trim() + "','" + comDes.Text.Trim() + "')";
                    MySqlCommand cmd   = new MySqlCommand(query, s.ConPass());
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("You have successfully registered..!");
                    Login log = new Login();
                    this.Hide();
                    log.Show();
                }

                catch (Exception ex)
                {
                    MessageBox.Show("error caught please contact the developers" + ex.Message);
                }
                s.ConnClose();
                txtUser.Clear();
                txtPass.Clear();
                txtPass1.Clear();
                comDes.ResetText();
                txtAdmin.Clear();
            }
            else if (Passwordmatch() == false && CheckAdminPassword() == false)
            {
                MessageBox.Show("Both Admin and Your Password are incorrect");
                txtPass.Clear();
                txtPass1.Clear();
                txtAdmin.Clear();
            }
            else if (CheckAdminPassword() == false)
            {
                MessageBox.Show("Admin password incorrect");
                txtAdmin.Clear();
            }
            else if (Passwordmatch() == false)
            {
                MessageBox.Show("Passwords Doesn't match");
                txtPass.Clear();
                txtPass1.Clear();
            }
        }
Beispiel #8
0
        public DataTable GetList()//grid view function
        {
            DataTable dt    = new DataTable();
            string    query = "Select e.EmpID,s.Name, e.OTHours, e.Days, e.Allow From Attendance e JOIN Employee s on e.EmpID = s.EmpID";

            try
            {
                s.ConnOpen();
                MySqlCommand    command = new MySqlCommand(query, s.ConPass());
                MySqlDataReader red     = command.ExecuteReader();
                dt.Load(red);
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message);
            }
            s.ConnClose();

            return(dt);
        }
        void FillComboID()//this will fill comobox with existing ids
        {
            s.ConnOpen();
            string query = "select * from employee";

            command = new MySqlCommand(query, s.ConPass());
            MySqlDataReader dtread;

            try
            {
                dtread = command.ExecuteReader();
                while (dtread.Read())
                {
                    string sID = dtread.GetString("EmpID");
                    comboBox1.Items.Add(sID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message);
            }
            s.ConnClose();
        }
Beispiel #10
0
        void FillComboID()//fill combobox with available ids
        {
            string query = "select * from employee";

            command = new MySqlCommand(query, s.ConPass());
            MySqlDataReader dtread;

            try
            {
                s.ConnOpen();
                dtread = command.ExecuteReader();
                while (dtread.Read())
                {
                    comboBox2.Items.Add(dtread.GetString("EmpID"));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message);
            }
            s.ConnClose();
        }