Esempio n. 1
0
        public bool PersonExist(Person newPerson)
        {
            MySqlConnection conn = new MySqlConnection(MyConnection.connectionString);
            MySqlCommand comm = new MySqlCommand();
            MySqlDataReader reader = null;
            String strQuery = null;

            //default
            bool value = false;

            strQuery = "SELECT * FROM tblPerson WHERE Firstname='" + this.Firstname + "' AND Middlename='" + this.Middlename + "' AND Lastname='" + this.Lastname + "'";

            try
            {
                conn.Open();
                comm.Connection = conn;
                comm.CommandText = strQuery;
                reader = comm.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        value = true;
                    }
                    reader.Close();
                    value = true;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, SystemVariable.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                value = false;
            }
            conn.Close();
            return value;
        }
Esempio n. 2
0
        public int GetPersonIDByName(Person newPerson)
        {
            MySqlConnection conn = new MySqlConnection(MyConnection.connectionString);
            MySqlCommand comm = new MySqlCommand();
            MySqlDataReader reader = null;
            String strQuery = null;

            //default
            int value = 0;

            strQuery = "SELECT PersonID FROM tblPerson WHERE Firstname='" + this.Firstname + "' OR Middlename='" + this.Middlename + "' AND Lastname='" + this.Lastname + "'";

            try
            {
                conn.Open();
                comm.Connection = conn;
                comm.CommandText = strQuery;
                reader = comm.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        value = Convert.ToInt16(reader.GetValue(0).ToString());
                    }
                    reader.Close();
                    return value;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, SystemVariable.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                value = 0;
            }
            conn.Close();
            return value;
        }
Esempio n. 3
0
        private void lstPersonInfo_DoubleClick(object sender, EventArgs e)
        {
            Person newPersonInfo = new Person();
            Baptismal newBaptismalInfo = new Baptismal();
            Marriage newMarriageInfo = new Marriage();

            String strAddress = null;
            String strPresentAdd = null;
            String strBaptismalID = null;
            String strGender = null;
            List<String> strListParents = new List<String>();

            iPersonID = Convert.ToInt16(lstPersonInfo.SelectedItems[0].Text);
            lblPersonID.Text = lstPersonInfo.SelectedItems[0].Text;
            strGender = newPersonInfo.GetPersonGenderByID(iPersonID);

            strBaptismalID = newBaptismalInfo.GetBaptismalIDByPersonID(iPersonID);
            newBaptismalInfo.SetBaptismalInfo(strBaptismalID);
            newPersonInfo.SetPersonInfo(iPersonID);

            txtFirstname.Text = lstPersonInfo.SelectedItems[0].SubItems[1].Text;
            txtMiddlename.Text = lstPersonInfo.Items[0].SubItems[2].Text;
            txtLastname.Text = lstPersonInfo.Items[0].SubItems[3].Text;

            dtBirthdate.Text = newPersonInfo.Birthdate;
            cboGender.Text = newPersonInfo.Gender;
            cboCivil.Text = newPersonInfo.Status;
            dtDateofDeath.Text = newBaptismalInfo.DateofBaptism;
            int iFatherID = newParent.GetPersonIDByParentsID(newPerson.GetParentIDByPersonID(iPersonID, "ParentIDForFather"));
            int iMotherID = newParent.GetPersonIDByParentsID(newPerson.GetParentIDByPersonID(iPersonID, "ParentIDForMother"));
            strListParents.Add(newPerson.GetPersonNameByID(iMotherID));
            strListParents.Add(newPerson.GetPersonNameByID(iFatherID));
            this.PopulateParentsComboBox(strListParents);

            lblSpouseID.Text = Convert.ToString(newMarriageInfo.GetSpouseIDByPersonID(iPersonID, strGender));
            txtSpouse.Text = newPersonInfo.GetPersonNameByID(Convert.ToInt16(lblSpouseID.Text));

            strAddress = newPersonInfo.Birthplace;
            String[] temp = strAddress.Split(',');
            if (temp.Length == 3)
            {
                txtBarangay.Text = temp[0];
                cboBirthTown.Text = temp[1].Trim();
                cboBirthProvince.Text = temp[2].Trim();
            }
            else if (temp.Length == 2)
            {
                cboBirthTown.Text = temp[0];
                cboBirthProvince.Text = temp[1].Trim();
            }
            else cboBirthProvince.Text = temp[0];

            strPresentAdd = newBaptismalInfo.Resident;
            String[] temp_add = strPresentAdd.Split(',');
            if (temp_add.Length == 3)
            {
                txtPresentBarangay.Text = temp_add[0];
                cboTown.Text = temp_add[1].Trim();
                cboProvince.Text = temp_add[2].Trim();
            }
            else if (temp.Length == 2)
            {
                cboTown.Text = temp_add[0];
                cboProvince.Text = temp_add[1].Trim();
            }
            else cboProvince.Text = temp_add[0];

            lstPersonInfo.Visible = false;
            this.ChangeTextboxStyle(txtFirstname);
            this.ChangeTextboxStyle(txtLastname);
        }
Esempio n. 4
0
        public void AddNew(Person newPerson)
        {
            MySqlCommand comm = new MySqlCommand();
            MySqlConnection conn = new MySqlConnection(MyConnection.connectionString);
            String strQuery = null;

            try
            {
                conn.Open();
                //strQuery = "INSERT INTO tblPerson(Lastname,Middlename,Firstname,Birthdate,BirthPlace,Gender,Status,ClusterID,ParentIDForFather,ParentIDForMother) VALUES" +
                //           " ('" + this.Lastname + "','" + this.Middlename + "','" + this.Firstname + "','" + this.Birthdate + "','" + this.Birthplace + "','" +
                //           this.Gender + "','" + this.Status + "','" + this.ClusterID + "','" + this.ParentIDForFather + "','" + this.ParentIDForMother + "')";

                strQuery = "INSERT INTO tblPerson(Lastname,Middlename,Firstname,Birthdate,BirthPlace,Gender,Status,ClusterID) VALUES" +
                           " ('" + this.Lastname + "','" + this.Middlename + "','" + this.Firstname + "','" + this.Birthdate + "','" + this.Birthplace + "','" +
                           this.Gender + "','" + this.Status + "','" + this.ClusterID + "')";

                comm.Connection = conn;
                comm.CommandText = strQuery;
                comm.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PMIS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            conn.Close();
        }
Esempio n. 5
0
        private int GetParentID()
        {
            Person newParent = new Person();

            String strParentName = "";
            strParentName = cboParentName.Text;
            String[] temp_name = strParentName.Split(' ');
            if (temp_name.Length == 3)
            {
                newParent.Firstname = temp_name[0];
                newParent.Lastname = temp_name[2];
            }
            else
            {
                newParent.Firstname = temp_name[0];
                newParent.Lastname = temp_name[1];
            }

            return newParent.GetPersonIDByName(newParent);
        }