예제 #1
0
        private void btnSignUp_Click(object sender, EventArgs e)
        {
            Ngay n = new Ngay();

            if (n.KiemTraHopLe(cbDate, cbMonth, cbYear) == 1)
            {
                acc = new AccessData();
                string gender = "";
                string birth  = "";
                if (this.rdMale.Checked == true)
                {
                    gender = "Male";
                }
                else
                {
                    if (this.rdFemale.Checked == true)
                    {
                        gender = "Female";
                    }
                }
                //
                birth = cbDate.SelectedItem.ToString() + "/" + cbMonth.SelectedItem.ToString() + "/" + cbYear.SelectedItem.ToString();
                //
                string sql = "INSERT INTO USER_INFO VALUES('" + txtUsername.Text + "', '" + txtPassword.Text + "', '" + txtCPassword.Text + "', '" + txtEmail.Text + "', '" + txtAddress.Text + "', '" + gender + "', '" + birth + "','" + txtOccupation.Text + "')";
                acc.ExcuteNonQuery(sql);
                MessageBox.Show("Đăng Ký Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearTextBox();
            }
            else
            {
                cbDate.Text  = "Date:";
                cbMonth.Text = "Month:";
                cbYear.Text  = "Year:";
            }
        }
예제 #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Ngay n = new Ngay();
                if (n.KiemTraHopLe(cbDate, cbMonth, cbYear) == 1)
                {
                    AccessData acc = new AccessData();

                    string username = frm1.TxtUsername.Text;
                    string gender   = "";

                    if (this.rdMale.Checked == true)
                    {
                        gender = "Male";
                    }
                    else
                    {
                        if (this.rdFemale.Checked == true)
                        {
                            gender = "Female";
                        }
                    }
                    string birth = "";
                    birth = cbDate.SelectedItem.ToString() + "/" + cbMonth.SelectedItem.ToString() + "/" + cbYear.SelectedItem.ToString();

                    string sql = "UPDATE USER_INFO SET PASSWORD='******',CPASSWORD='******',EMAIL='" + txtEmail.Text + "',ADDRESS='" + txtAddress.Text + "',GENDER='" + gender + "',BIRTHDAY='" + birth + "',OCCUPATION='" + txtOccupation.Text + "' WHERE USERNAME ='******'";
                    acc.ExcuteNonQuery(sql);
                    MessageBox.Show("Update Successfully !!!");
                    this.Refresh();
                }
                else
                {
                    cbDate.Text  = "Date:";
                    cbMonth.Text = "Month:";
                    cbYear.Text  = "Year:";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error !!!");
            }
        }