private void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtMa.Text) || string.IsNullOrEmpty(txtTen.Text) || string.IsNullOrEmpty(txtGiatien.Text) || cbHangSX.SelectedIndex <= 0) { MessageBox.Show("Vui lòng nhập đầy đủ thông tin!"); } else { if (MessageBox.Show("Bạn có chắc chắn muốn thêm mới dữ liệu?", "Hộp thoại thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK) { CellPhone cp = new CellPhone(); cp.ID = txtMa.Text; cp.Name = txtTen.Text; cp.MakerID = ((ItemComboBox)cbHangSX.SelectedItem).Value; Phone_Price pr = new Phone_Price(); pr.CellPhoneID = txtMa.Text; pr.Price = (double.Parse(txtGiatien.Text.ToString())); try { connection.Open(); connection.Insert(cp); connection.Insert(pr); connection.Close(); Form1_Load(sender, e); } catch (Exception err) { MessageBox.Show("Mã dữ liệu đã tồn tại không thể thêm mới"); } } } }