コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var    v          = cbMonth.SelectedItem as Level;
            int    _month     = v.Number;
            string _birthdate = _month + "/" + cbDay.Text + "/" + cbYear.Text;

            bool _status = true;

            if (cbStatus.SelectedIndex == 1)
            {
                _status = true;
            }
            else
            {
                _status = false;
            }

            if (option == 1)
            {
                DialogResult rs = MessageBox.Show("Do You Want To Add This Information?", "Confirmation", MessageBoxButtons.YesNo);
                if (rs == DialogResult.Yes)
                {
                    Client client = new Client(0, txtCOCNo.Text, txtFirstname.Text, txtMiddlename.Text, txtLastname.Text, DateTime.Today.ToString(), txtStreet.Text, txtBarangay.Text, txtCity.Text, int.Parse(txtZipcode.Text), txtCompany.Text, txtPosition.Text, cbGender.Text.ToString(), cbCivilStatus.Text.ToString(), cbBloodtype.Text, txtGroup.Text, double.Parse(txtAmount.Text), _status, _birthdate, txtMobile.Text, txtPhone.Text, int.Parse(txtUnits.Text));
                    client.AddNew();
                }

                tabPage1.Enabled          = false;
                tabControl1.SelectedIndex = 1;
            }
            else
            {
                DialogResult rs = MessageBox.Show("Do You Want To Edit This Information?", "Confirmation", MessageBoxButtons.YesNo);
                if (rs == DialogResult.Yes)
                {
                    Client client = new Client(id, txtCOCNo.Text, txtFirstname.Text, txtMiddlename.Text, txtLastname.Text, DateTime.Today.ToString(), txtStreet.Text, txtBarangay.Text, txtCity.Text, int.Parse(txtZipcode.Text), txtCompany.Text, txtPosition.Text, cbGender.Text.ToString(), cbCivilStatus.Text.ToString(), cbBloodtype.Text, txtGroup.Text, double.Parse(txtAmount.Text), _status, _birthdate, txtMobile.Text, txtPhone.Text, int.Parse(txtUnits.Text));
                    client.Edit();
                }
            }
        }