TextBox5
How do I use Text Box5
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: frmCapNhat.cs
Copy
38 private void Bandau()
39 {
40 checkBox1.Checked = false;
41 checkBox2.Checked = false;
42 checkBox3.Checked = false;
43 checkBox4.Checked = false;
44 textBox1.Text = "";
45 textBox2.Text = "";
46 textBox3.Text = "";
47 textBox4.Text = "";
48 textBox5.Text = "";
49 richTextBox1.Text = "";
50 }
File name: frmCapNhat.cs
Copy
54 private void listView1_SelectedIndexChanged(object sender, EventArgs e)
55 {
56 bool bdapan = false;
57 for (int i = 0; i < listView1.Items.Count; i++)
58 {
59 if (listView1.Items[i].Selected)
60 {
61 textBox5.Text = listView1.Items[i].SubItems[0].Text;
62 textBox1.Text = listView1.Items[i].SubItems[2].Text;
63 textBox2.Text = listView1.Items[i].SubItems[3].Text;
64 textBox3.Text = listView1.Items[i].SubItems[4].Text;
65 textBox4.Text = listView1.Items[i].SubItems[5].Text;
66 richTextBox1.Text = listView1.Items[i].SubItems[1].Text;
67 string t = listView1.Items[i].SubItems[6].Text.ToString().Trim();
68 if (t.Length >= 2)
69 {
70 for (int ii = 0; ii < t.Length; ii++)
71 {
72 t2 = t[0].ToString();
73 if (t[1].ToString() == "")
74 {
75 t1 = "NULL";
76 }
77 else
78 {
79 t1 = t[1].ToString();
80 }
81 }
82 }
83 else
84 {
85 t2 = t;
86 t1 = "NULL";
87 }
88 Macdinh();
89 if (t1 == "A")
90 {
91 checkBox1.Checked = true;
92 }
93 if (t1 == "B")
94 {
95 checkBox2.Checked = true;
96 }
97 if (t1 == "C")
98 {
99 checkBox3.Checked = true;
100 }
101 if (t1 == "D")
102 {
103 checkBox4.Checked = true;
104 }
105
106 if (t2 == "A")
107 {
108 checkBox1.Checked = true;
109 }
110 if (t2 == "B")
111 {
112 checkBox2.Checked = true;
113 }
114 if (t2 == "C")
115 {
116 checkBox3.Checked = true;
117 }
118 if (t2 == "D")
119 {
120 checkBox4.Checked = true;
121 }
122 bdapan = true;
123 }
124 if (bdapan == false)
125 {
126 Bandau();
127 }
128 }
129
130 }
File name: frmCapNhat.cs
Copy
176 private void btLog_Click(object sender, EventArgs e)
177 {
178 Bandau();
179 button4.Enabled = true;
180 textBox5.Text = SDienMaTuDong(textBox1.Text, sqlcmd, sqlcon);
181 }
File name: frmCapNhat.cs
Copy
183 private void button1_Click_1(object sender, EventArgs e)
184 {
185 try
186 {
187 string sCauA = textBox1.Text;
188 string sCauB = textBox2.Text;
189 string sCauC = textBox3.Text;
190 string sCauD = textBox4.Text;
191 string sMaCH = textBox5.Text;
192 string sCauHoi = richTextBox1.Text;
193 string sCauDung = "";
194 string sCauDungLuu = "";
195 string sTrinhDo = comboBox1.Text;
196 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))
197 {
198 MessageBox.Show("Bạn đã sai làm thao tác", "Thông báo");
199 }
200 else
201 {
202 if (checkBox1.Checked == true)
203 {
204 sCauDung = "A";
205 sCauDungLuu += sCauDung;
206 }
207 if (checkBox2.Checked == true)
208 {
209 sCauDung = "B";
210 sCauDungLuu += sCauDung;
211 }
212 if (checkBox3.Checked == true)
213 {
214 sCauDung = "C";
215 sCauDungLuu += sCauDung;
216 }
217 if (checkBox4.Checked == true)
218 {
219 sCauDung = "D";
220 sCauDungLuu += sCauDung;
221 }
222
223 sqlcmd = new SqlCommand("update dapan set A='" + sCauA + "',B='" + sCauB + "',C='" + sCauC + "',D='" + sCauD + "',dapan='" + sCauDungLuu + "' where mach='" + sMaCH + "'", sqlcon);
224 sqlcmd.ExecuteNonQuery();
225 sqlcmd = new SqlCommand("update cauhoi set cauhoi='" + sCauHoi + "', trinhdo='" + sTrinhDo + "' where mach='" + sMaCH + "'", sqlcon);
226 sqlcmd.ExecuteNonQuery();
227 LoadDataToListView();
228 Bandau();
229 }
230 }
231
232 catch
233 {
234 MessageBox.Show("Bạn đã sai làm thao tác", "Thông báo");
235 }
236 }
File name: frmCapNhat.cs
Copy
238 private void button2_Click(object sender, EventArgs e)
239 {
240 if (richTextBox1.Text == "")
241 {
242 MessageBox.Show("Vui lòng chọn câu hỏi", "Thông báo");
243 }
244 else
245 {
246 string sCauHoi = richTextBox1.Text;
247 if (MessageBox.Show("Bạn có muốn xóa câu hỏi" + " " + sCauHoi, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
248 {
249 string sMaCH = textBox5.Text;
250 sqlcmd = new SqlCommand("delete cauhoi where mach='" + sMaCH + "'", sqlcon);
251 sqlcmd.ExecuteNonQuery();
252 sqlcmd = new SqlCommand("delete dapan where mach='" + sMaCH + "'", sqlcon);
253 sqlcmd.ExecuteNonQuery();
254 LoadDataToListView();
255 }
256 Bandau();
257 }
258 }
File name: frmCapNhat.cs
Copy
311 private void button4_Click(object sender, EventArgs e)
312 {
313 if (richTextBox1.Text == "" || textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false))
314 {
315 MessageBox.Show("Bạn chưa thêm đầy đủ thông tin", "Thông báo");
316 }
317 else
318 {
319 try
320 {
321
322 string sCauA = textBox1.Text;
323 string sCauB = textBox2.Text;
324 string sCauC = textBox3.Text;
325 string sCauD = textBox4.Text;
326 string sMaCH = textBox5.Text;
327 string sCauHoi = richTextBox1.Text;
328 string sCauDung = "";
329 string sCauDungLuu = "";
330 string sTrinhDo = comboBox1.Text;
331 if (checkBox1.Checked == true)
332 {
333 sCauDung = "A";
334 sCauDungLuu += sCauDung;
335 }
336 if (checkBox2.Checked == true)
337 {
338 sCauDung = "B";
339 sCauDungLuu += sCauDung;
340 }
341 if (checkBox3.Checked == true)
342 {
343 sCauDung = "C";
344 sCauDungLuu += sCauDung;
345 }
346 if (checkBox4.Checked == true)
347 {
348 sCauDung = "D";
349 sCauDungLuu += sCauDung;
350 }
351
352 sqlcmd = new SqlCommand("insert into dapan values('" + sMaCH + "','" + sCauA + "','" + sCauB + "','" + sCauC + "','" + sCauD + "','" + sCauDungLuu + "') ", sqlcon);
353 sqlcmd.ExecuteNonQuery();
354 sqlcmd = new SqlCommand("insert into cauhoi values('" + sMaCH + "','" + sCauHoi + "','" + sTrinhDo + "') ", sqlcon);
355 sqlcmd.ExecuteNonQuery();
356 LoadDataToListView();
357 button4.Enabled = false;
358 }
359 //roi hen;de bi coi lai thu de cHOAky thu chay thu hen ok
360 catch
361 {
362 MessageBox.Show("Bạn đã thao tác sai");
363 }
364 }
365 }
File name: frmQuanLySinhVien.cs
Copy
67 private void btnthem_Click(object sender, EventArgs e)
68 {
69 try
70 {
71 string mats = textBox1.Text;
72 string hoten = textBox2.Text;
73 string ngaysinh = textBox3.Text;
74 string gioitinh = textBox4.Text;
75 string quequan = textBox5.Text;
76 string sodt = textBox6.Text;
77 string email = textBox7.Text;
78
79 string strSQL = "insert SINHVIEN values('" + mats + "','" + hoten + "','" + ngaysinh + "','" + gioitinh + "','" + quequan + "','" + sodt + "','" + email + "')";
80 sqlcmd = new SqlCommand(strSQL, sqlcon);
81 sqlcmd.ExecuteNonQuery();
82 MessageBox.Show("B?n dã dang ký thành công");
83 load();
84 }
85 catch
86 {
87 MessageBox.Show("Trùng mã sinh viên !!!");
88 }
89
90 }
File name: frmQuanLySinhVien.cs
Copy
97 private void btnsua_Click(object sender, EventArgs e)
98 {
99 try
100 {
101 string mats = textBox1.Text;
102 string hoten = textBox2.Text;
103 string ngaysinh = textBox3.Text;
104 string gioitinh = textBox4.Text;
105 string quequan = textBox5.Text;
106 string sodt = textBox6.Text;
107 string email = textBox7.Text;
108 sqlcmd = new SqlCommand("update sinhvien set mats='" + mats + "',hoten='" + hoten + "',ngaysinh='" + ngaysinh + "',gioitinh='" + gioitinh + "',quequan='" + quequan + "',sodienthoai='" + sodt + "',email'" + email + "' ", sqlcon);
109 sqlcmd.ExecuteNonQuery();
110
111 load();
112 }
113 catch
114 {
115 MessageBox.Show("Loi");
116 }
117 }
File name: frmQuanLySinhVien.cs
Copy
128 private void listView1_SelectedIndexChanged(object sender, EventArgs e)
129 {
130 for (int i = 0; i < listView1.Items.Count; i++)
131 if (listView1.Items[i].Selected)
132 {
133 textBox1.Text = listView1.Items[i].SubItems[0].Text;
134 textBox2.Text = listView1.Items[i].SubItems[1].Text;
135 textBox3.Text = listView1.Items[i].SubItems[2].Text;
136 textBox4.Text = listView1.Items[i].SubItems[3].Text;
137 textBox5.Text = listView1.Items[i].SubItems[4].Text;
138 textBox6.Text = listView1.Items[i].SubItems[5].Text;
139 textBox7.Text = listView1.Items[i].SubItems[6].Text;
140
141 }
142 }
File name: Form1.cs
Copy
58 public void Button1_Click(System.Object sender, System.EventArgs e)
59 {
60 int a = default(int);
61 decimal b = new decimal();
62
63 if (Information.IsNumeric(TextBox3.Text))
64 {
65 if (int.Parse(TextBox3.Text) <= 20 )
66 {
67 a = (int) ((double.Parse(TextBox3.Text) * 100) / 20);
68 TextBox4.Text = a.ToString();
69 b = (decimal) (a * 0.1);
70 TextBox5.Text = b.ToString();
71 }
72 else
73 {
74 MessageBox.Show("Please Enter value equal to 20 and below!");
75 }
76 }
77 if (Information.IsNumeric(TextBox6.Text))
78 {
79
80 if (int.Parse(TextBox6.Text) <= 50 )
81 {
82 int c = default(int);
83 decimal d = new decimal();
84 c = (int) ((double.Parse(TextBox6.Text) * 100) / 50);
85 TextBox7.Text = c.ToString();
86 d = (decimal) (c * 0.1);
87 TextBox8.Text = d.ToString();
88
89 }
90 else
91 {
92 MessageBox.Show("Please Enter value equal to 50 and below!");
93
94
95 }
96 }
97
98 if (Information.IsNumeric(TextBox9.Text))
99 {
100 if (int.Parse(TextBox9.Text) <= 50 )
101 {
102 int g = default(int);
103 decimal f = new decimal();
104 g = (int) ((double.Parse(TextBox9.Text) * 100) / 50);
105 TextBox10.Text = g.ToString();
106 f = (decimal) (g * 0.2);
107 TextBox11.Text = f.ToString();
108
109 }
110 else
111 {
112 MessageBox.Show("Please Enter value equal to 50 and below!");
113
114
115 }
116 }
117 if (Information.IsNumeric(TextBox12.Text))
118 {
119 if (int.Parse(TextBox12.Text) <= 100 )
120 {
121 int g = default(int);
122 decimal f = new decimal();
123 g = (int) ((double.Parse(TextBox12.Text) * 100) / 100);
124 TextBox13.Text = g.ToString();
125 f = (decimal) (g * 0.3);
126 TextBox14.Text = f.ToString();
127
128 }
129 else
130 {
131 MessageBox.Show("Please Enter value equal to 100 and below!");
132
133
134 }
135 }
136
137 if (Information.IsNumeric(TextBox15.Text))
138 {
139 if (int.Parse(TextBox15.Text) <= 100 )
140 {
141 int j = default(int);
142 decimal f1 = new decimal();
143 j = (int) ((double.Parse(TextBox15.Text) * 100) / 100);
144 TextBox16.Text = j.ToString();
145 f1 = (decimal) (j * 0.3);
146 TextBox17.Text = f1.ToString();
147
148 }
149 else
150 {
151 MessageBox.Show("Please Enter value equal to 100 and below!");
152
153
154 }
155 }
156
157 decimal adal = new decimal();
158 adal = (decimal) (Conversion.Val(TextBox5.Text) + Conversion.Val(TextBox8.Text) + Conversion.Val(TextBox11.Text) + Conversion.Val(TextBox14.Text) + Conversion.Val(TextBox17.Text));
159
160 TextBox18.Text = adal.ToString();
161
162 if (Conversion.Val(TextBox18.Text) <= 74)
163 {
164
165 TextBox19.Text = "Failed";
166 TextBox19.ForeColor = Color.Red;
167 }
168 else
169 {
170 TextBox19.Text = "Passed";
171 TextBox19.ForeColor = Color.Black;
172
173
174 }
175
176
177 }
TextBox5 119 lượt xem
Gõ tìm kiếm nhanh...