Beispiel #1
0
 //  Save changes of object
 protected void btnSave_click(Object sender, EventArgs e)
 {
     Vector temp = new Vector();
     temp.id = int.Parse(txtid.Value);
     temp.labID = int.Parse(ddllabID.SelectedValue);
     if (ddlantibioticResistance.SelectedValue != "Other")
     {
         temp.antibioticResistance = ddlantibioticResistance.SelectedValue;
     }
     else
     {
         temp.antibioticResistance = txtantibioticResistance.Text;
     }
     temp.multipleCloningSite = txtmultipleCloningSite.Text;
     temp.notes = txtnotes.Text;
     temp.promoter = txtpromter.Text;
     temp.specSheetHREF = txtspecSheetHREF.Value;
     temp.vectorName = txtvectorName.Text;
     temp.vectorSize = txtvectorSize.Text;
     myConn.updateVector(temp);
     gvVectors.DataBind();
 }
Beispiel #2
0
 //  submit
 protected void btnSubmit_click(Object sender, EventArgs e)
 {
     Vector vector = new Vector();
     if (ddlantibioticResistance.SelectedValue != "Other")
     {
         vector.antibioticResistance = ddlantibioticResistance.SelectedValue;
     }
     else
     {
         vector.antibioticResistance = txtantibioticResistance.Text;
     }
     vector.labID = int.Parse(ddlLabID.SelectedValue);
     vector.multipleCloningSite = txtmultipleCloningSite.Text;
     vector.notes = txtnotes.Text;
     vector.promoter = txtpromter.Text;
     vector.specSheetHREF = specSheetHREF.Value;
     vector.vectorName = txtvectorName.Text;
     vector.vectorSize = txtvectorSize.Text;
     if (myConn.addVector(vector))
     {
         Response.Redirect("Vectors.aspx");
     }
 }
Beispiel #3
0
 /// <summary>
 /// Updates the vector record with the specified ID
 /// </summary>
 /// <param name="temp">Vector object to be written to the database</param>
 public Boolean updateVector(Vector temp)
 {
     conn.Open();
     SqlCommand cmd = new SqlCommand("UPDATE dbo.Vector SET LabID='" + temp.labID + "', VectorName='" + temp.vectorName + "', MultipleCloningSite='" + temp.multipleCloningSite + "', AntibioticResistance='" + temp.antibioticResistance + "', VectorSize='" + temp.vectorSize + "', Promoter='" + temp.promoter + "', Note='" + temp.notes + "', SpecSheet='" + temp.specSheetHREF + "' WHERE ID=" + temp.id + ";", conn);
     cmd.CommandType = CommandType.Text;
     int i = cmd.ExecuteNonQuery();
     conn.Close();
     if (i > 0)
         return true;
     else
         return false;
 }
Beispiel #4
0
 /// <summary>
 /// Gets the Vector denoted by the provided ID
 /// </summary>
 /// <param name="id">ID of the Vector to be located</param>
 /// <returns>Vector object if found, null if not</returns>
 public Vector getVectorByID(int id)
 {
     conn.Open();
     SqlCommand cmd = new SqlCommand("SELECT * FROM Vector WHERE ID=" + id + ";", conn);
     SqlDataReader rdr = cmd.ExecuteReader();
     Vector temp;
     if (rdr.Read())
         temp = new Vector(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(), null);
     else
         temp = null;
     conn.Close();
     return temp;
 }
Beispiel #5
0
 /// <summary>
 /// Gets every Vector record in the database, saves each one in a new Vector object, and puts it in an ArrayList.
 /// </summary>
 /// <returns>ArrayList of Vector objects</returns>
 public ArrayList getAllVectors()
 {
     conn.Open();
     ArrayList temp = new ArrayList();
     SqlCommand cmd = new SqlCommand("dbo.getVectorRecords", conn);
     cmd.CommandType = CommandType.StoredProcedure;
     SqlDataReader rdr = cmd.ExecuteReader();
     while (rdr.Read())
     {
         Vector tempVector = new Vector(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(10).ToString());
         temp.Add(tempVector);
     }
     conn.Close();
     return temp;
 }
Beispiel #6
0
 /// <summary>
 /// Inserts the provided Vector object as a new record into the database
 /// </summary>
 /// <param name="temp">Vector object to be added to the database</param>
 /// <returns>True if add is successful, false otherwise</returns>
 public Boolean addVector(Vector temp)
 {
     conn.Open();
     SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Vector VALUES(" + temp.id + "," + temp.labID + ",'" + temp.vectorName + "','" + temp.multipleCloningSite + "','" + temp.antibioticResistance + "','" + temp.vectorSize + "','" + temp.promoter + "','" + temp.notes + "','" + temp.specSheetHREF + "');", conn);
     cmd.CommandType = CommandType.Text;
     int i = cmd.ExecuteNonQuery();
     conn.Close();
     if (i > 0)
         return true;
     else
         return false;
 }
Beispiel #7
0
 /// <summary>
 /// Compares the ID of the current Vector object to that of a provided Vector
 /// </summary>
 /// <param name="temp">Vector object to be compared to.</param>
 /// <returns>True if the ID's are equal (meaning the constructs are the same), false otherwise.</returns>
 public Boolean Equals(Vector temp)
 {
     return this.id == temp.id;
 }