コード例 #1
0
        //Chemical Compatibility Helper method
        private DE_ChemCompatibility CreateChemRow(SqlDataReader results)
        {
            DE_ChemCompatibility row = new DE_ChemCompatibility();

            row.Id           = Convert.ToInt32(results["id"]);
            row.CreatedDate  = Convert.ToDateTime(results["created_date"]);
            row.DatadsetId   = Convert.ToInt32(results["dataset_id"]);
            row.Strain       = Convert.ToString(results["strain"]);
            row.Chemical     = Convert.ToString(results["chemical"]);
            row.Rep          = Convert.ToInt32(results["rep"]);
            row.RateDilution = Convert.ToString(results["rate_dilution"]);
            row.Notes        = Convert.ToString(results["notes"]);

            row.DilutionResults = new List <string>();

            row.DilutionResults.Add(Convert.ToString(results["dil_zero"]));
            row.DilutionResults.Add(Convert.ToString(results["dil_neg1"]));
            row.DilutionResults.Add(Convert.ToString(results["dil_neg2"]));
            row.DilutionResults.Add(Convert.ToString(results["dil_neg3"]));

            row.DilutionResults.Add(Convert.ToString(results["dil_neg4"]));
            row.DilutionResults.Add(Convert.ToString(results["dil_neg5"]));
            row.DilutionResults.Add(Convert.ToString(results["dil_neg6"]));
            row.DilutionResults.Add(Convert.ToString(results["dil_neg7"]));


            return(row);
        }
コード例 #2
0
        //Chemical Compatibility
        public bool Update1Row(DE_ChemCompatibility row)
        {
            int rowsUpdated = 0;

            //guard against null values
            if (row.Notes == null)
            {
                row.Notes = "";
            }
            for (int i = 0; i < row.DilutionResults.Count; i++)
            {
                if (row.DilutionResults[i] == null)
                {
                    row.DilutionResults[i] = "";
                }
            }
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    SqlCommand cmd;
                    conn.Open();
                    cmd = new SqlCommand("update chem_compatibility set notes = @notes, dil_zero = @dil0, dil_neg1 = @dil1, dil_neg2 = @dil2, dil_neg3 = @dil3, dil_neg4 = @dil4, dil_neg5 = @dil5, dil_neg6 = @dil6, dil_neg7 = @dil7 where id = @rowId;", conn);
                    cmd.Parameters.AddWithValue("@rowId", row.Id);
                    cmd.Parameters.AddWithValue("@notes", row.Notes);
                    cmd.Parameters.AddWithValue("@dil0", row.DilutionResults[0]);
                    cmd.Parameters.AddWithValue("@dil1", row.DilutionResults[1]);
                    cmd.Parameters.AddWithValue("@dil2", row.DilutionResults[2]);
                    cmd.Parameters.AddWithValue("@dil3", row.DilutionResults[3]);
                    cmd.Parameters.AddWithValue("@dil4", row.DilutionResults[4]);
                    cmd.Parameters.AddWithValue("@dil5", row.DilutionResults[5]);
                    cmd.Parameters.AddWithValue("@dil6", row.DilutionResults[6]);
                    cmd.Parameters.AddWithValue("@dil7", row.DilutionResults[7]);


                    rowsUpdated = cmd.ExecuteNonQuery();
                }
            }
            catch (SqlException ex)
            {
                throw;
            }



            return(rowsUpdated == 1);
        }