private void buttonSuaDM_Click(object sender, EventArgs e) { FormChungLoai fcl = new FormChungLoai(); if (listBoxDM.SelectedIndex != -1) { fcl.textBoxMaLoai1.Text = listBoxDM.SelectedItem.ToString().Split('-')[0]; fcl.textBoxTenLoai1.Text = listBoxDM.SelectedItem.ToString().Split('-')[1]; } if (fcl.ShowDialog() == DialogResult.OK) { ChungLoai cl = new ChungLoai(); cl.maLoai = fcl.textBoxMaLoai1.Text; cl.tenLoai = fcl.textBoxTenLoai1.Text; if (clbll.KiemTraTonTai(cl.maLoai) == true) { if (clbll.SuaChungLoai(cl) > 0) { MessageBox.Show("SỬa Thành công Danh mục"); LoadDanhMuc(); } } else { MessageBox.Show("Danh mục không tồn tại"); } } }
private void buttonThemDM_Click(object sender, EventArgs e) { FormChungLoai fcl = new FormChungLoai(); if (fcl.ShowDialog() == DialogResult.OK) { ChungLoai cl = new ChungLoai(); cl.maLoai = fcl.textBoxMaLoai1.Text; cl.tenLoai = fcl.textBoxTenLoai1.Text; if (clbll.KiemTraTonTai(cl.maLoai) == false) { if (clbll.ThemChungLoai(cl) > 0) { MessageBox.Show("Them Thành công Danh mục"); LoadDanhMuc(); } } else { MessageBox.Show("Da ton tai danh muc"); } } }