// submit protected void btnSubmit_click(Object sender, EventArgs e) { PrimaryAntibody antibody = new PrimaryAntibody(); antibody.labID = int.Parse(ddlLabID.SelectedValue); antibody.lotNumber = txtLotNumber.Text; antibody.name = txtName.Text; antibody.clone = txtClone.Text; if (rbMono.Checked) { antibody.type = "Monoclonal"; } else { antibody.type = "Polyclonal"; } antibody.hostSpecies = ddlHostSpecies.SelectedValue; if (ddlHostSpecies.SelectedValue != "Other") { antibody.hostSpecies = ddlHostSpecies.SelectedValue; } else { antibody.hostSpecies = txthostSpecies.Text; } String reactiveSpecies = ""; int i = 0; foreach (ListItem li in ddlReactiveSpecies.Items) { if (li.Selected == true) { if (i > 0) { reactiveSpecies += ","; } reactiveSpecies += li.Value; i++; } } antibody.reactiveSpecies = reactiveSpecies; antibody.concentration = txtConcentration.Text; antibody.workingDilution = txtWorkingDilution.Text; antibody.isotype = txtIsotype.Text; antibody.antigen = txtAntigen.Text; antibody.applications = txtApplication.Text; if (ddlFluorophore.SelectedValue != "Other") { antibody.fluorophore = ddlFluorophore.SelectedValue; } else { antibody.fluorophore = fluorophoreOther.Text; } antibody.protocolHREF = protocolHREF.Value; if (myConn.addPrimaryAntibody(antibody)) { Response.Redirect("Antibodies.aspx"); } }
// Save changes of object protected void btnSave_click(Object sender, EventArgs e) { PrimaryAntibody temp = new PrimaryAntibody(); temp.id = int.Parse(txtid.Value); temp.antigen = txtantigen.Text; temp.applications = txtapplications.Text; temp.clone = txtclone.Text; temp.concentration = txtconcentration.Text; if (ddlfluorophore.SelectedValue != "Other") { temp.fluorophore = ddlfluorophore.SelectedValue; } else { temp.fluorophore = txtfluorophore.Text; } if (ddlhostSpecies.SelectedValue != "Other") { temp.hostSpecies = ddlhostSpecies.SelectedValue; } else { temp.hostSpecies = txthostSpecies.Text; } temp.isotype = txtisotype.Text; temp.lotNumber = txtlotNumber.Text; temp.labID = int.Parse(ddllabID.SelectedValue); temp.name = txtname.Text; String reactiveSpecies = ""; int i = 0; foreach (ListItem li in ddlreactiveSpecies.Items) { if (li.Selected == true) { if (i > 0) { reactiveSpecies += ","; } reactiveSpecies += li.Value; i++; } } temp.reactiveSpecies = reactiveSpecies; temp.workingDilution = txtworkingDilution.Text; if (rbmonoclonal.Checked) { temp.type = "Monoclonal"; } else { temp.type = "Polyclonal"; } myConn.updatePrimaryAntibody(temp); gvAntibodies.DataBind(); }
/// <summary> /// Inserts the provided PrimaryAntibody object as a new record into the database /// </summary> /// <param name="temp">PrimaryAntibody object to be added to the database</param> /// <returns>True if add is successful, false otherwise</returns> public Boolean addPrimaryAntibody(PrimaryAntibody temp) { conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO dbo.PrimaryAntibody VALUES(" + temp.labID + ",'" + temp.lotNumber + "','" + temp.name + "','" + temp.type + "','" + temp.clone + "','" + temp.hostSpecies + "','" + temp.reactiveSpecies + "','" + temp.concentration + "','" + temp.workingDilution + "','" + temp.applications + "','" + temp.isotype + "','" + temp.antigen + "','" + temp.fluorophore + "','" + temp.protocolHREF + "','" + temp.specSheetHREF + "');", conn); cmd.CommandType = CommandType.Text; int i = cmd.ExecuteNonQuery(); Console.WriteLine(i); conn.Close(); if (i > 0) return true; else return false; }
/// <summary> /// Gets every Primary Antibody record in the database, saves each one in a new Primary Antibody object, and puts it in an ArrayList. /// </summary> /// <returns>ArrayList of Primary Antibody objects</returns> public ArrayList getAllPrimaryAntibodies() { conn.Open(); ArrayList temp = new ArrayList(); SqlCommand cmd = new SqlCommand("dbo.getPrimaryAntibodyRecords", conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { PrimaryAntibody tempPrimaryAntibody = new PrimaryAntibody(Convert.ToInt32(rdr.GetValue(0)), Convert.ToInt32(rdr.GetValue(1)), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString(), rdr.GetValue(8).ToString(), rdr.GetValue(9).ToString(), rdr.GetValue(10).ToString(), rdr.GetValue(11).ToString(), rdr.GetValue(12).ToString(), rdr.GetValue(13).ToString(), rdr.GetValue(14).ToString(), rdr.GetValue(15).ToString(), rdr.GetValue(17).ToString()); temp.Add(tempPrimaryAntibody); } conn.Close(); return(temp); }
/// <summary> /// Gets the PrimaryAntibody denoted by the provided ID /// </summary> /// <param name="id">ID of the PrimaryAntibody to be located</param> /// <returns>PrimaryAntibody object if found, null if not</returns> public PrimaryAntibody getPrimaryAntibodyByID(int id) { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM PrimaryAntibody WHERE ID=" + id + ";", conn); SqlDataReader rdr = cmd.ExecuteReader(); PrimaryAntibody temp; if (rdr.Read()) { temp = new PrimaryAntibody(Convert.ToInt32(rdr.GetValue(0)), Convert.ToInt32(rdr.GetValue(1)), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString(), rdr.GetValue(8).ToString(), rdr.GetValue(9).ToString(), rdr.GetValue(10).ToString(), rdr.GetValue(11).ToString(), rdr.GetValue(12).ToString(), rdr.GetValue(13).ToString(), rdr.GetValue(14).ToString(), rdr.GetValue(15).ToString(), null); } else { temp = null; } conn.Close(); return(temp); }
/// <summary> /// Inserts the provided PrimaryAntibody object as a new record into the database /// </summary> /// <param name="temp">PrimaryAntibody object to be added to the database</param> /// <returns>True if add is successful, false otherwise</returns> public Boolean addPrimaryAntibody(PrimaryAntibody temp) { conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO dbo.PrimaryAntibody VALUES(" + temp.labID + ",'" + temp.lotNumber + "','" + temp.name + "','" + temp.type + "','" + temp.clone + "','" + temp.hostSpecies + "','" + temp.reactiveSpecies + "','" + temp.concentration + "','" + temp.workingDilution + "','" + temp.applications + "','" + temp.isotype + "','" + temp.antigen + "','" + temp.fluorophore + "','" + temp.protocolHREF + "','" + temp.specSheetHREF + "');", conn); cmd.CommandType = CommandType.Text; int i = cmd.ExecuteNonQuery(); Console.WriteLine(i); conn.Close(); if (i > 0) { return(true); } else { return(false); } }
/// <summary> /// Updates the primary antibody record with the matching ID /// </summary> /// <param name="temp">PrimaryAntibody object to be written to the database</param> public Boolean updatePrimaryAntibody(PrimaryAntibody temp) { conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE dbo.PrimaryAntibody SET LabID='" + temp.labID + "', LotNumber='" + temp.lotNumber + "', AntibodyName='" + temp.name + "', Type='" + temp.type + "', Clone='" + temp.clone + "', HostSpecies='" + temp.hostSpecies + "', ReactiveSpecies='" + temp.reactiveSpecies + "', Concentration='" + temp.concentration + "', WorkingDilution='" + temp.workingDilution + "', Applications='" + temp.applications + "', AntibodyIsotype='" + temp.isotype + "', Antigen='" + temp.antigen + "', Fluorophore='" + temp.fluorophore + "', ProtocolAttachments='" + temp.protocolHREF + "', SpecSheet='" + temp.specSheetHREF + "' WHERE ID=" + temp.id + ";", conn); Console.WriteLine(cmd); cmd.CommandType = CommandType.Text; int i = cmd.ExecuteNonQuery(); conn.Close(); if (i > 0) { return(true); } else { return(false); } }
/// <summary> /// Updates the primary antibody record with the matching ID /// </summary> /// <param name="temp">PrimaryAntibody object to be written to the database</param> public Boolean updatePrimaryAntibody(PrimaryAntibody temp) { conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE dbo.PrimaryAntibody SET LabID='" + temp.labID + "', LotNumber='" + temp.lotNumber + "', AntibodyName='" + temp.name + "', Type='" + temp.type + "', Clone='" + temp.clone + "', HostSpecies='" + temp.hostSpecies + "', ReactiveSpecies='" + temp.reactiveSpecies + "', Concentration='" + temp.concentration + "', WorkingDilution='" + temp.workingDilution + "', Applications='" + temp.applications + "', AntibodyIsotype='" + temp.isotype + "', Antigen='" + temp.antigen + "', Fluorophore='" + temp.fluorophore + "', ProtocolAttachments='" + temp.protocolHREF + "', SpecSheet='" + temp.specSheetHREF + "' WHERE ID=" + temp.id + ";", conn); Console.WriteLine(cmd); cmd.CommandType = CommandType.Text; int i = cmd.ExecuteNonQuery(); conn.Close(); if (i > 0) return true; else return false; }
/// <summary> /// Gets the PrimaryAntibody denoted by the provided ID /// </summary> /// <param name="id">ID of the PrimaryAntibody to be located</param> /// <returns>PrimaryAntibody object if found, null if not</returns> public PrimaryAntibody getPrimaryAntibodyByID(int id) { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM PrimaryAntibody WHERE ID=" + id + ";", conn); SqlDataReader rdr = cmd.ExecuteReader(); PrimaryAntibody temp; if (rdr.Read()) temp = new PrimaryAntibody(Convert.ToInt32(rdr.GetValue(0)), Convert.ToInt32(rdr.GetValue(1)), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString(), rdr.GetValue(8).ToString(), rdr.GetValue(9).ToString(), rdr.GetValue(10).ToString(), rdr.GetValue(11).ToString(), rdr.GetValue(12).ToString(), rdr.GetValue(13).ToString(), rdr.GetValue(14).ToString(), rdr.GetValue(15).ToString(), null); else temp = null; conn.Close(); return temp; }
/// <summary> /// Gets every Primary Antibody record in the database, saves each one in a new Primary Antibody object, and puts it in an ArrayList. /// </summary> /// <returns>ArrayList of Primary Antibody objects</returns> public ArrayList getAllPrimaryAntibodies() { conn.Open(); ArrayList temp = new ArrayList(); SqlCommand cmd = new SqlCommand("dbo.getPrimaryAntibodyRecords", conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { PrimaryAntibody tempPrimaryAntibody = new PrimaryAntibody(Convert.ToInt32(rdr.GetValue(0)), Convert.ToInt32(rdr.GetValue(1)), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString(), rdr.GetValue(8).ToString(), rdr.GetValue(9).ToString(), rdr.GetValue(10).ToString(), rdr.GetValue(11).ToString(), rdr.GetValue(12).ToString(), rdr.GetValue(13).ToString(), rdr.GetValue(14).ToString(), rdr.GetValue(15).ToString(), rdr.GetValue(17).ToString()); temp.Add(tempPrimaryAntibody); } conn.Close(); return temp; }
/// <summary> /// Compares the ID of the current PrimaryAntibody object to that of a provided PrimaryAntibody /// </summary> /// <param enzymeName="temp">PrimaryAntibody object to be compared to.</param> /// <returns>True if the ID's are equal (meaning the antibodies are the same), false otherwise.</returns> public Boolean Equals(PrimaryAntibody temp) { return(this.id == temp.id); }
protected void createPDF(Stream output) { //PrimaryAntibody tempAntibody = myConn.getPrimaryAntibodyByID(Convert.ToInt16(Request.QueryString["id"])); PrimaryAntibody tempAntibody = myConn.getPrimaryAntibodyByID(int.Parse(txtid.Value)); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=primary_antibody_" + tempAntibody.id + ".pdf"); iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER, 72, 72, 72, 72); PdfWriter writer = PdfWriter.GetInstance(document, Response.OutputStream); document.Open(); //Page title and spacing iTextSharp.text.Chunk pageTitle = new iTextSharp.text.Chunk("Primary Antibody Record", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 20)); document.Add(pageTitle); iTextSharp.text.Paragraph spacing = new iTextSharp.text.Paragraph(" "); document.Add(spacing); //Name iTextSharp.text.Paragraph tempParagraph = new iTextSharp.text.Paragraph(); iTextSharp.text.Chunk tempLabel = new iTextSharp.text.Chunk("Name: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); iTextSharp.text.Chunk tempValue = new iTextSharp.text.Chunk(tempAntibody.name, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Type tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Type: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.type, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Clone tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Clone: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.clone, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Host Species tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Host Species: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.hostSpecies, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Reactive Species tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Reactive Species: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.reactiveSpecies, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Concentration tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Concentration: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.concentration, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Working Dilution tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Working Dilution: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.workingDilution, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Applications tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Applications: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.applications, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Isotype tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Isotype: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.isotype, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Antigen tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Antigen: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.antigen, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); //Fluorophore tempParagraph = new iTextSharp.text.Paragraph(); tempLabel = new iTextSharp.text.Chunk("Fluorophore: ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempValue = new iTextSharp.text.Chunk(tempAntibody.fluorophore, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10)); tempParagraph.Add(tempLabel); tempParagraph.Add(tempValue); document.Add(tempParagraph); document.Close(); }
/// <summary> /// Compares the ID of the current PrimaryAntibody object to that of a provided PrimaryAntibody /// </summary> /// <param enzymeName="temp">PrimaryAntibody object to be compared to.</param> /// <returns>True if the ID's are equal (meaning the antibodies are the same), false otherwise.</returns> public Boolean Equals(PrimaryAntibody temp) { return this.id == temp.id; }