Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         private void button1_Click_1(object sender, EventArgs e)
         {
             try
             {
                 string sCauA = textBox1.Text;
                 string sCauB = textBox2.Text;
                 string sCauC = textBox3.Text;
                 string sCauD = textBox4.Text;
                 string sMaCH = textBox5.Text;
                 string sCauHoi = richTextBox1.Text;
                 string sCauDung = "";
                 string sCauDungLuu = "";
                 string sTrinhDo = comboBox1.Text;
                 if (richTextBox1.Text.ToString().Trim() == "" || textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false))
                 {
                     MessageBox.Show("Bạn đã sai làm thao tác", "Thông báo");
                 }
                 else
                 {
                     if (checkBox1.Checked == true)
                     {
                         sCauDung = "A";
                         sCauDungLuu += sCauDung;
                     }
                     if (checkBox2.Checked == true)
                     {
                         sCauDung = "B";
                         sCauDungLuu += sCauDung;
                     }
                     if (checkBox3.Checked == true)
                     {
                         sCauDung = "C";
                         sCauDungLuu += sCauDung;
                     }
                     if (checkBox4.Checked == true)
                     {
                         sCauDung = "D";
                         sCauDungLuu += sCauDung;
                     }

                     sqlcmd = new SqlCommand("update dapan set A='" + sCauA + "',B='" + sCauB + "',C='" + sCauC + "',D='" + sCauD + "',dapan='" + sCauDungLuu + "' where mach='" + sMaCH + "'", sqlcon);
                     sqlcmd.ExecuteNonQuery();
                     sqlcmd = new SqlCommand("update cauhoi set cauhoi='" + sCauHoi + "', trinhdo='" + sTrinhDo + "' where mach='" + sMaCH + "'", sqlcon);
                     sqlcmd.ExecuteNonQuery();
                     LoadDataToListView();
                     Bandau();
                 }
             }

             catch
             {
                 MessageBox.Show("Bạn đã sai làm thao tác", "Thông báo");
             }
         }