예제 #1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (txtTitle.Text == "")
            {
                MessageBox.Show("Title is empty", "Empty Title", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else if (txtContent.Text == "")
            {
                MessageBox.Show("Content is empty Cannot create note", "Empty Content",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                DataTable dt           = getUserIdByUserName.getUserId(username);
                int       userId       = int.Parse(dt.Rows[0][0].ToString());
                int       categoryId   = (int)cmbCategory.SelectedValue;
                string    noteTitle    = txtTitle.Text;
                string    noteCategory = cmbCategory.Text;
                string    noteContent  = txtContent.Text;
                notebll.insertNoteInfo(userId, categoryId, noteTitle, noteCategory, noteContent);
                MessageBox.Show("Note Added Successfully");
                txtTitle.Clear();
                txtContent.Clear();


                this.Hide();
                StickyNotes stickyNotes = new StickyNotes(username);
                stickyNotes.ShowDialog();
                this.Close();
            }
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Hide();
            StickyNotes stickyNote = new StickyNotes(username);

            stickyNote.ShowDialog();
            this.Close();
        }
        private void btnUpdateAccount_Click(object sender, EventArgs e)
        {
            if (txtFname.Text == "" || txtLname.Text == "" || txtEmail.Text == "" ||
                txtUsername.Text == "" || txtPassword.Text == "" || txtConfirmPassword.Text == "")
            {
                MessageBox.Show("Please fill up all fields first");
                return;
            }
            if (!this.txtEmail.Text.Contains('@') || !this.txtEmail.Text.Contains('.'))
            {
                MessageBox.Show("Please Enter A Valid Email", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (rdoMale.Checked == false && rdoFemale.Checked == false && rdoOther.Checked == false)
            {
                MessageBox.Show("Please select your gender");
                return;
            }
            else if (txtPassword.Text.Length < 5)
            {
                MessageBox.Show("password length must be five character");
                return;
            }
            else if (txtPassword.Text != txtConfirmPassword.Text)
            {
                MessageBox.Show("Password mismatch");
                return;
            }
            string fname  = txtFname.Text;
            string lname  = txtLname.Text;
            string gender = "";

            if (rdoMale.Checked)
            {
                gender = rdoMale.Text;
            }
            else if (rdoFemale.Checked)
            {
                gender = rdoFemale.Text;
            }
            else if (rdoOther.Checked)
            {
                gender = rdoOther.Text;
            }
            string dob             = datePicker.Text;;
            string email           = txtEmail.Text;
            string Uname           = txtUsername.Text;
            string password        = txtPassword.Text;
            string confirmpassword = txtConfirmPassword.Text;

            acbll.updateAccountSetting(userId, fname, lname, gender, dob, email, Uname, password, confirmpassword);
            this.username = txtUsername.Text;
            MessageBox.Show("Account updated successfully");
            StickyNotes stickyNotes = new StickyNotes(this.username);

            stickyNotes.ShowDialog();
            this.Close();
        }
예제 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataTable dt     = categorybll.getUserId(username);
            int       userId = int.Parse(dt.Rows[0][0].ToString());

            if (!string.IsNullOrEmpty(txtCategory.Text.Trim()))
            {
                string categoryName    = txtCategory.Text;
                bool   isCategoryExist = categorybll.checkCategory(userId, categoryName);
                if (isCategoryExist)
                {
                    MessageBox.Show("Category name already exist");
                    return;
                }
                else if (txtCategory.Text == "")
                {
                    MessageBox.Show("Enter category name first");
                }
                else if (btnSave.Text == "Save")
                {
                    string category = txtCategory.Text;
                    categorybll.addCetegory(userId, category);
                    dataGridView1.DataSource = categorybll.showCategory(userId);
                    MessageBox.Show("Category added");
                    txtCategory.Clear();
                    StickyNotes stickyNote = new StickyNotes(this.username);
                    this.Hide();
                    stickyNote.ShowDialog();
                    this.Close();
                }
                else if (btnSave.Text == "Update")
                {
                    string category = txtCategory.Text;
                    categorybll.updateCategory(categoryid, category);
                    dataGridView1.DataSource = categorybll.showCategory(userId);
                    MessageBox.Show("Updated Successfully");
                    txtCategory.Text = "";
                }
            }
        }