Пример #1
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SingleContact sc = new SingleContact();

            sc.Show();
            this.Hide();
        }
Пример #2
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
     {
         cid = al[e.RowIndex].ToString();
         SingleContact sc = new SingleContact();
         sc.Show();
         this.Hide();
     }
 }
Пример #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            string        ci     = Contacts.cid;
            string        isEmer = "";
            SqlConnection con    = new SqlConnection();

            con.ConnectionString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Deepang\source\repos\OOSE Project\OOSE Project\DTC.mdf; Integrated Security = True";
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "SELECT EmergencyContact FROM CONTACTS WHERE Id = @cid1";
            cmd.Parameters.AddWithValue("@cid1", ci);
            cmd.Connection = con;
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                isEmer = rdr["EmergencyContact"].ToString();
            }
            rdr.Close();
            con.Close();
            cmd.CommandText = "UPDATE CONTACTS SET EmergencyContact = @emer WHERE Id = @cid";
            cmd.Parameters.AddWithValue("@cid", ci);
            if (isEmer.Equals("No        "))
            {
                cmd.Parameters.AddWithValue("@emer", "Yes");
            }
            if (isEmer.Equals("Yes       "))
            {
                cmd.Parameters.AddWithValue("@emer", "No");
            }
            cmd.Connection = con;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            SingleContact sc = new SingleContact();

            sc.Show();
            this.Hide();
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        field = listBox1.SelectedItem.ToString();
            string        ci    = Contacts.cid;
            string        n     = textBox1.Text;
            SqlConnection con   = new SqlConnection();

            con.ConnectionString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Deepang\source\repos\OOSE Project\OOSE Project\DTC.mdf; Integrated Security = True";
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "UPDATE CONTACTS SET " + field + " = @new WHERE Id = @cid";
            cmd.Parameters.AddWithValue("@cid", ci);
            cmd.Parameters.AddWithValue("@new", n);
            cmd.Connection = con;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            SingleContact sc = new SingleContact();

            sc.Show();
            this.Hide();
        }