private void btAdd_Click(object sender, EventArgs e) { string id = txtID.Text; string name = txtName.Text; string supplier = (cbSupplier.SelectedItem as Supplier).ID; string category = (cbCategory.SelectedItem as Category).ID; float p_in = float.Parse(txtPIn.Text); float p_out = float.Parse(txtPOut.Text); string img = System.IO.Path.GetFileName(openFileDialog1.FileName); string cmt = rtbCmt.Text; DataProcess dt = new DataProcess(); if (dt.AddProduct(id, name, supplier, category, p_in, p_out, img, cmt) == true) { string path = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10); System.IO.File.Copy(openFileDialog1.FileName, path + "\\image\\" + img); MessageBox.Show("Add successful product"); LoadData(); } else { MessageBox.Show("Error!!!!"); } }