Example #1
0
 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 btnEdit_Click(object sender, EventArgs e)
 {
     if (txtName.Text == "")
     {
         MessageBox.Show("名稱不得為空白");
     }
     else if (txtName.Text == selectedDetail.Name)
     {
         MessageBox.Show("若欲修改,請輸入一個新的名稱");
     }
     else
     {
         selectedDetail.Name = txtName.Text;
         bll.Update(selectedDetail);
         MessageBox.Show("已修改類別名稱");
         ShowWorkoutCat();
     }
 }