コード例 #1
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);
        }
コード例 #2
0
ファイル: Marriage.cs プロジェクト: hammerj01/Kasilak-PMS
        public void AddNew(Marriage newMarriage)
        {
            MySqlCommand comm = new MySqlCommand();
            MySqlConnection conn = new MySqlConnection(MyConnection.connectionString);
            String strQuery = null;

            try
            {
                conn.Open();
                strQuery = "INSERT INTO tblMarriage(MarriageID,PersonID_Husband,PersonID_Wife,BookID,MinisterNo,ParentsIDForMotherHusband,ParentsIDForFatherHusband," +
                           "ParentsIDForMotherWife,ParentsIDForFatherWife,LicenseNo,DateofMarriage,DateofBaptism,PlaceofBaptism,Annotation,PlaceofMarriage) VALUES" +
                           " ('" + this.MarriageID + "','" + this.PersonIDHusband + "','" + this.PersonIDWife + "','" + this.BookID + "','" + this.MinisterNo + "','" + this.ParentsIDForMotherHusband + "'," +
                           "'" + this.ParentsIDForFatherHusband + "','" + this.ParentsIDForMotherWife + "','" + this.ParentsIDForFatherWife + "','" + this.LicenseNo + "','" + this.DateofMarriage + "'," +
                           "'" + this.DateofBaptism + "','" + this.PlaceofBaptism + "','" + this.Annotation + "','" + this.PlaceofMarriage + "')";

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

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, SystemVariable.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            conn.Close();
        }