protected void btnSubmit_Click(object sender, EventArgs e) { DatabaseDataContext db = new DatabaseDataContext(); if (InterChemicalName2 != "") { InteractionPharmacyPharmacy tmpItem = new InteractionPharmacyPharmacy(); tmpItem.pharmacyname1 = InterChemicalName; tmpItem.pharmacyname2 = InterChemicalName2; tmpItem.comment = txtInterComment.Text; db.InteractionPharmacyPharmacies.InsertOnSubmit(tmpItem); } else if (InterSubCategoryName != null) { InteractionPharmacySubCategory tmpItem = new InteractionPharmacySubCategory(); tmpItem.chemicalName = InterChemicalName; tmpItem.subCategoryName = InterSubCategoryName; tmpItem.comment = txtInterComment.Text; db.InteractionPharmacySubCategories.InsertOnSubmit(tmpItem); } db.SubmitChanges(); Response.Redirect(Util.UrlRewriting.encodeUrl("updateInteraction.aspx?chemicalName="+InterChemicalName)); }
private void fillInteractionsPharmacy(DatabaseDataContext db) { PharmacyChemical[] pharms = db.PharmacyChemicals.ToArray(); for (int i = 0; i < pharms.Count(); i++) { for (int j = 0; j < 30; j++) { if (rad.Next() % 20 == 0) break; InteractionPharmacyPharmacy tmpitem = new InteractionPharmacyPharmacy(); try { tmpitem.pharmacyname1 = pharms[i].chemicalName; tmpitem.pharmacyname2 = pharms[rad.Next() % pharms.Count()].chemicalName; tmpitem.comment = randomText(rad.Next() % 100); if ((from inter in db.InteractionPharmacyPharmacies where ((inter.pharmacyname1 == tmpitem.pharmacyname1 && inter.pharmacyname2 == tmpitem.pharmacyname2) || (inter.pharmacyname2 == tmpitem.pharmacyname1 && inter.pharmacyname1 == tmpitem.pharmacyname2)) select inter.pharmacyname1).Count() < 1) { db.InteractionPharmacyPharmacies.InsertOnSubmit(tmpitem); db.SubmitChanges(); } } catch (Exception exp) { Response.Write(exp.Message); Response.Write("<br>"); Response.Flush(); } } } }