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 fillInteractionsSubCategory(DatabaseDataContext db)
        {
            PharmacyChemical[] pharms = db.PharmacyChemicals.ToArray();
                for (int i = 0; i < pharms.Count(); i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (rad.Next() % 3 != 0)
                            break;
                        try
                        {

                                InteractionPharmacySubCategory tmpitem = new InteractionPharmacySubCategory();
                                tmpitem.chemicalName = pharms[i].chemicalName;
                                tmpitem.subCategoryName = pharms[rad.Next() % pharms.Count()].subCategoryName;
                                tmpitem.comment = randomText(rad.Next() % 100);
                                if ((from inter in db.InteractionPharmacySubCategories
                                     where (inter.chemicalName == tmpitem.chemicalName && inter.subCategoryName == tmpitem.subCategoryName)
                                     select
                                         inter.chemicalName).Count() < 1)
                                {

                                    db.InteractionPharmacySubCategories.InsertOnSubmit(tmpitem);
                                    db.SubmitChanges();

                                }

                        }
                        catch (Exception exp)
                        {
                            Response.Write(exp.Message);
                            Response.Write("<br>");
                            Response.Flush();
                        }
                    }

                }
        }