private void btnAdd_Click(object sender, EventArgs e) { try { Generic g = new Generic(); Formulation f = new Formulation(); Dosage d = new Dosage(); Manufacturer m = new Manufacturer(); int quantity = Convert.ToInt32(txtQuantity.Text); double unitPrice = Convert.ToDouble(txtUnitPrice.Text); double sellingPrice = Convert.ToDouble(txtSellingPrice.Text); DateTime expireDate = Convert.ToDateTime(cboExpireDate.Text); expireDate.ToString("yyy-MM-dd"); g = generic.Get(cboGenericName.Text); f = formulation.Get(cboFormulationType.Text); d = dosage.Get(cboDosageAmount.Text); m = manufacturer.Get(cboManufacturer.Text); if (!String.IsNullOrWhiteSpace(txtBrandName.Text) && !String.IsNullOrWhiteSpace(cboGenericName.Text) && !String.IsNullOrWhiteSpace(cboFormulationType.Text) && !String.IsNullOrWhiteSpace(cboDosageAmount.Text) && !String.IsNullOrWhiteSpace(cboExpireDate.Text) && !String.IsNullOrWhiteSpace(txtQuantity.Text) && !String.IsNullOrWhiteSpace(txtUnitPrice.Text) && !String.IsNullOrWhiteSpace(txtSellingPrice.Text)) { Medicine med = new Medicine(); med.BrandName = txtBrandName.Text; med.GenericId = g.Id; med.FormulationId = f.Id; med.DosageId = d.Id; med.ManufacturerId = m.Id; med.UnitPrice = unitPrice; med.SellingPrice = sellingPrice; med.Qty = quantity; med.ExpireDate = expireDate; int row = medicine.Insert(med); if (row > 0) { lblMessage.Visible = true; } Console.WriteLine(g.Id); Console.WriteLine(f.Id); Console.WriteLine(d.Id); Console.WriteLine(m.Id); Console.WriteLine(quantity); Console.WriteLine(unitPrice); Console.WriteLine(sellingPrice); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }