Пример #1
0
        //delete contact
        public void deletecnc(contacts cnc1)
        {
            string connString;

            connString = ConfigurationManager.ConnectionStrings["Dbcon"].ConnectionString;
            // create Sqlconnection object
            SqlConnection sqlConnection = new SqlConnection(connString);

            try
            {
                sqlConnection.Open();

                SqlCommand cmd = new SqlCommand("Delete contacts  Where ID=@ID)", sqlConnection);

                cmd.Connection  = sqlConnection;
                cmd.CommandText = "delete from  CasConfirmer where ID='" + cnc1.Id + "' ";
                cmd.ExecuteNonQuery();


                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #2
0
        //ADD contacts
        public void addcontact(contacts cnc1)
        {
            SqlCommand cmd = new SqlCommand();
            string     connString;

            connString = ConfigurationManager.ConnectionStrings["Dbcon"].ConnectionString;
            SqlConnection sqlConnection = new SqlConnection(connString);

            try
            {
                sqlConnection.Open();

                cmd.Connection  = sqlConnection;
                cmd.CommandText = "insert into contacts (ID,NAME,CIN,PhoneNumber,Adresse,Etatsante,NeveauRisqueColor) values('" + cnc1.Id + "','" + cnc1.Nom + "','" + cnc1.CIN1 + "','" + cnc1.PhoneNumber1 + "','" + cnc1.Adresse + "','" + cnc1.Etatsante + "','" + cnc1.NeveauRisque1 + "') ";
                cmd.ExecuteNonQuery();

                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #3
0
        //update contacts
        public void updatecontact(contacts cnc1)
        {
            SqlCommand cmd = new SqlCommand();
            string     connString;

            connString = ConfigurationManager.ConnectionStrings["Dbcon"].ConnectionString;
            SqlConnection sqlConnection = new SqlConnection(connString);

            try
            {
                sqlConnection.Open();

                cmd.Connection  = sqlConnection;
                cmd.CommandText = "update contacts set NAME='" + cnc1.Nom + "',CIN='" + cnc1.CIN1 + "',PhoneNumber='" + cnc1.PhoneNumber1 + "',Adresse='" + cnc1.PhoneNumber1 + "',Etatsante='" + cnc1.Etatsante + "',NeveauRisqueColor='" + cnc1.NeveauRisque1 + "')";
                cmd.ExecuteNonQuery();


                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }