public void UpdateAntenna(Antenna antenna) { try { SqlConnection cn = new SqlConnection(cnStr); cn.Open(); SqlCommand sqlCommand = new SqlCommand("updateAntenna", cn); sqlCommand.CommandType = CommandType.StoredProcedure; ArrayList param = new ArrayList(); param.Add(new SqlParameter("@Name", antenna.Name)); param.Add(new SqlParameter("@Type", antenna.Type)); param.Add(new SqlParameter("@MaxGain", antenna.MaxGain)); param.Add(new SqlParameter("@Polarization", antenna.Polarization)); param.Add(new SqlParameter("@ReceiverThreshold", antenna.RecieveThrehold)); param.Add(new SqlParameter("@TransmisionLoss", antenna.TransmissionLoss)); param.Add(new SqlParameter("@VSWR", antenna.VSWR)); param.Add(new SqlParameter("@Temperature", antenna.Temperature)); param.Add(new SqlParameter("@Radius", antenna.Radius)); param.Add(new SqlParameter("@BlockageRadius", antenna.BlockageRadius)); param.Add(new SqlParameter("@ApetureDistribution", antenna.ApertureDistribution)); param.Add(new SqlParameter("@EdgeTeper", antenna.EdgeTeper)); param.Add(new SqlParameter("@Length", antenna.Length)); param.Add(new SqlParameter("@Pitch", antenna.Pitch)); sqlCommand.Parameters.AddRange((SqlParameter[])param.ToArray(typeof(SqlParameter))); sqlCommand.ExecuteNonQuery(); } catch (SqlException ex) { LogFileManager.ObjLog.error(ex.Message); throw ex; } }
public Antenna GetAntenna(string name) { SqlConnection cn = new SqlConnection(cnStr); Antenna antenna = null; try { cn.Open(); SqlCommand sqlCommand = new SqlCommand("getAntenna", cn); sqlCommand.CommandType = CommandType.StoredProcedure; //add params SqlParameter param = new SqlParameter(); param.ParameterName = "@Name"; param.Value = name; param.SqlDbType = SqlDbType.NVarChar; param.Direction = ParameterDirection.Input; sqlCommand.Parameters.Add(param); SqlDataReader myDataReader = sqlCommand.ExecuteReader(); if (myDataReader.Read()) { string type = myDataReader.GetString(1); double maxGain = myDataReader.GetDouble(2); double receiverThreshold = myDataReader.GetDouble(4); double transmissionLoss = myDataReader.GetDouble(5); double vswr = myDataReader.GetDouble(6); double temperature = myDataReader.GetDouble(7); string polarization = null; if (!myDataReader.IsDBNull(3)) { polarization = myDataReader.GetString(3); } double?radius = null; if (!myDataReader.IsDBNull(8)) { radius = myDataReader.GetDouble(8); } double?blockageRadius = null; if (!myDataReader.IsDBNull(9)) { blockageRadius = myDataReader.GetDouble(9); } string apertureDistribution = null; if (!myDataReader.IsDBNull(10)) { apertureDistribution = myDataReader.GetString(10); } double?edgeTeper = null; if (!myDataReader.IsDBNull(11)) { edgeTeper = myDataReader.GetDouble(11); } double?length = null; if (!myDataReader.IsDBNull(12)) { length = myDataReader.GetDouble(12); } double?pitch = null; if (!myDataReader.IsDBNull(13)) { pitch = myDataReader.GetDouble(13); } antenna = new Antenna(name, type, maxGain, receiverThreshold, transmissionLoss, vswr, temperature, polarization, radius, blockageRadius, apertureDistribution, edgeTeper, length, pitch); } return(antenna); } catch (SqlException ex) { LogFileManager.ObjLog.error(ex.Message); return(null); throw ex; } finally { cn.Close(); } }