private void btnEdit_Click(object sender, EventArgs e) { if (textBox2.Text == "") { MessageBox.Show("名稱不得為空白"); } else if (textBox2.Text == textBox1.Name) { MessageBox.Show("若欲修改,請輸入一個新的名稱"); } else if (bll.IsCategoryExist(textBox2.Text)) { MessageBox.Show("該類別名稱已存在"); } else { DialogResult DR = MessageBox.Show($"{textBox1.Text}將變更為{textBox2.Text}?", "確認訊息!", MessageBoxButtons.YesNo); if (DR == DialogResult.Yes) { detail.Name = textBox2.Text; bll.Update(detail); MessageBox.Show("已修改類別名稱"); frmWorkoutcat.ShowWorkoutCat(); this.Close(); } } }
private void btnAddCat_Click(object sender, EventArgs e) { WorkoutCategoryDetailDTO detail = new WorkoutCategoryDetailDTO(); if (txtName.Text == "") { MessageBox.Show("請輸入名稱"); } else if (bll.IsCategoryExist(txtName.Text)) { MessageBox.Show("該類別名稱已存在"); } else { detail.Name = txtName.Text; if (bll.Add(detail)) { MessageBox.Show("已新增運動類別"); ShowWorkoutCat(); txtName.Clear(); } } }