public int GetLastid()
        {
            System.Data.SqlClient.SqlDataReader Myreader;
            int Newid;

            sqlCommand.CommandText = "SELECT @@IDENTITY as Newid";
            Myreader = sqlCommand.ExecuteReader();
            Myreader.Read();
            Newid = Conversions.ToInteger(Myreader["NewID"]);
            Myreader.Close();
            return(Newid);
        }
Beispiel #2
0
        public string ReadCodesForRegion(int regionId)
        {
            var strTemp = new StringBuilder();

            System.Data.SqlClient.SqlDataReader Myreader;
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.AddWithValue("@ID", regionId);
            sqlCommand.CommandText = "Select code FROM STATIONS WHERE region_id = @ID";
            Myreader = sqlCommand.ExecuteReader();
            while (Myreader.Read())
            {
                strTemp.Append(Myreader["code"].ToString());
            }
            Myreader.Close();
            return(strTemp.ToString());
        }
Beispiel #3
0
        public string GetRegion(int stationId)
        {
            string strTemp = "";

            System.Data.SqlClient.SqlDataReader Myreader;
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.AddWithValue("@ID", stationId);
            sqlCommand.CommandText = "Select value FROM STATIONS LEFT JOIN REGIONS On REGIONS.ID = STATIONS.region_id WHERE stations.id = @ID";
            Myreader = sqlCommand.ExecuteReader();
            Myreader.Read();
            if (Myreader.HasRows)
            {
                strTemp = Myreader["value"].ToString();
            }
            Myreader.Close();
            return(strTemp);
        }
        public bool CanDelete(object id)
        {
            System.Data.SqlClient.SqlDataReader Myreader;
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.AddWithValue("@ID", id);
            sqlCommand.CommandText = "SELECT id FROM CALLS WHERE priority_id = @ID";
            Myreader = sqlCommand.ExecuteReader();
            Myreader.Read();
            if (Myreader.HasRows)
            {
                Myreader.Close();
                return(false);
            }

            Myreader.Close();
            return(true);
        }