private void btnSave_Click(object sender, EventArgs e)
        {
            Passport p = new Passport();

            p.number = passport_no.Text;
            p.place_of_issue = passport_issued_place.Text;
            p.post = passport_post.Text;
            p.rank = passport_rank.Text;
            p.setdate_of_issue(passport_issued_date.Value.Date);
            p.setdate_of_renewal(passport_renewal_date.Value.Date);

            if (passport_status_active.Checked) { p.status = true; }
            else { p.status = false; }

            bool state = PassportHandler.addPassport(p);

            if (state)
            {
                MessageBox.Show("Employee passport details added succesfully...!");

            }
            else
            {
                MessageBox.Show("Adding employee personal pasport failed...!");
            }
            //frmMain.getForm().Show();
        }
        public static Passport getPassport()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM passport WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;

                MySqlDataReader reader = cmd.ExecuteReader();

                Passport p = null;

                if (reader.Read())
                {
                    p = new Passport();

                    if (reader["status"].ToString() == "True") { p.status=true; }
                    else { p.status = false; }
                    p.p_id = int.Parse(reader["idpassport"].ToString());
                    p.rank = reader["rank"].ToString();
                    p.post = reader["post"].ToString();
                    p.number = reader["passport_no"].ToString();
                    p.place_of_issue = reader["place_of_issue"].ToString();

                    p.setdate_of_issue(Convert.ToDateTime(reader["date_of_issue"]));
                    p.setdate_of_renewal(Convert.ToDateTime(reader["date_of_renewal"]));

                }

                reader.Close();

                dbcon.closeConnection();

                return p;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
Exemplo n.º 3
0
        public void updatePassport()
        {
            Passport p = new Passport();

            p.p_id = this.p_id;
            p.number = this.passport_no.Text;
            p.place_of_issue = this.passport_issued_place.Text;
            p.post = this.passport_post.Text;
            p.rank = this.passport_rank.Text;
            p.setdate_of_issue(this.passport_issued_date.Value.Date);
            p.setdate_of_renewal(this.passport_renewal_date.Value.Date);

            if (this.passport_status_active.Checked) { p.status = true; }
            else { p.status = false; }

            bool state = PassportHandler.updatePassport(p);
            Console.Write(state + "\n");
        }