private void btOK_Click(object sender, EventArgs e) { if (txtMAHO.TextLength > 0 && txtNamechuho.TextLength > 0 && cbbthanhvien.SelectedIndex >= 0) { if (check1() == true) { hogiadinh a = new hogiadinh(); a.maho = Convert.ToInt32(txtMAHO.Text); a.tenchuho = txtNamechuho.Text.ToString(); a.sothanhvien = Convert.ToInt32(cbbthanhvien.SelectedItem); BLL_Hogiadinh.Instance().ADD(a); MessageBox.Show("dang ki thanh cong"); btEdit_Click(sender, e); } else { MessageBox.Show("Ma so gia dinh bi trung"); var l1 = BLL_Hogiadinh.Instance().GetAllHogiadinh(); string dem = "ma so : "; foreach (hogiadinh i in l1) { dem += " " + i.maho; } MessageBox.Show("khong duoc trung cac " + dem); } } }
public Boolean check1() { if (txtMAHO.Text.All(char.IsDigit) && BLL_Hogiadinh.Instance().GetHoGiaDinhByid(Convert.ToInt32(txtMAHO.Text)) == null) { return(true); } return(false); }