private void btSave_Click(object sender, EventArgs e) { if (!ValidateData()) { return; } string productCode = txtProductCode.Text; string productType = cbBoxProductType.Text; string brand = cbBoxBrand.Text; decimal inputPrice = decimal.Parse(txtInputPrice.Text); decimal price = decimal.Parse(txtPrice.Text); decimal price2 = 0; decimal.TryParse(txtPrice2.Text, out price2); decimal price3 = 0; decimal.TryParse(txtPrice3.Text, out price3); decimal price4 = 0; decimal.TryParse(txtPrice4.Text, out price4); string note = txtNote.Text; int prodId = 0; using (TransactionScope tran = new TransactionScope()) { int.TryParse(prodTableAdapter.InsertProdReturnId(productCode, brand, inputPrice, price, price2, price3, price4, productType, note).ToString(), out prodId); if (prodId != 0) { foreach (object item in chkListBoxSize.CheckedItems) { productTableAdapter.InsertProductReturnId(item.ToString(), price, inputPrice, price2, price3, price4, prodId); } } tran.Complete(); } DialogResult result = MessageBox.Show("Tạo mã hàng thành công, bạn có muốn tạo mã hàng mới?", "Tạo mã hàng thành công", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == System.Windows.Forms.DialogResult.OK) { ClearData(); } else { this.Close(); } }