Button4
How do I use Button4
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
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
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: frmMain.cs
Copy
95 private void button4_Click(object sender, EventArgs e)
96 {
97 frmDienTenTS DIENTEN = new frmDienTenTS();
98 DIENTEN.ShowDialog();
99 }
File name: frmQuanLy_Admin.cs
Copy
31 private void button4_Click(object sender, EventArgs e)
32 {
33 this.Close();
34 }
File name: Lichsuthi.cs
Copy
209 private void button4_Click(object sender, EventArgs e)
210 {
211 if (MessageBox.Show("Bạn có muốn xóa thí sinh có mã thí sinh " + " " + tbmats.Text, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
212 {
213 sqlcmd = new SqlCommand("delete thisinhthi where mats='" + tbmats.Text + "'", sqlcon);
214 sqlcmd.ExecuteNonQuery();
215 loadtatca();
216 }
217 }
File name: Form1.cs
Copy
236 public void Button4_Click(System.Object sender, System.EventArgs e)
237 {
238
239 string strmessage = default(string);
240 DialogResult dgrResult;
241
242 strmessage = "Are you sure you want to save data?";
243 dgrResult = MessageBox.Show(strmessage, "Save data", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
244
245
246 if (dgrResult == System.Windows.Forms.DialogResult.Yes)
247 {
248
249 newgrade = gradeclass.DataModule.SaveItem();
250 }
251
252 }
File name: StaffInformation.cs
Copy
155 private void button4_Click(object sender, EventArgs e)
156 {
157 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
158 con.Open();
159 string gen = string.Empty;
160 if (radioButton1.Checked)
161 {
162 gen = "Male";
163 }
164 else
165 {
166 gen = "Female";
167 }
168 try
169 {
170 string str = " Update staff set name='" + textBox2.Text + "',gender='" + gen + "',position='" + textBox4.Text + "',salary='" + textBox5.Text + "',contact='" + textBox6.Text + "',address='" + textBox7.Text + "' where id='" + textBox1.Text + "'";
171
172 SqlCommand cmd = new SqlCommand(str, con);
173 cmd.ExecuteNonQuery();
174
175 string str1 = "select max(id) from staff;";
176
177 SqlCommand cmd1 = new SqlCommand(str1, con);
178 SqlDataReader dr = cmd1.ExecuteReader();
179 if (dr.Read())
180 {
181 MessageBox.Show("" + textBox2.Text + "'s Details is Updated Successfully.. ", "Important Message");
182 textBox2.Text = "";
183 textBox4.Text = "";
184 textBox5.Text = "";
185 textBox6.Text = "";
186 textBox7.Text = "";
187 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
188 {
189
190 string str2 = "SELECT * FROM staff";
191 SqlCommand cmd2 = new SqlCommand(str2, con1);
192 SqlDataAdapter da = new SqlDataAdapter(cmd2);
193 DataTable dt = new DataTable();
194 da.Fill(dt);
195 dataGridView1.DataSource = new BindingSource(dt, null);
196 }
197 }
198 }
199 catch (SqlException excep)
200 {
201 MessageBox.Show(excep.Message);
202 }
203 con.Close();
204 }
File name: frmSearchSach.cs
Copy
171 private void radioButton4_CheckedChanged(object sender, EventArgs e)
172 {
173 AutoCompleteChuyenNganh(2);
174 }
File name: frmCustomerOrders.cs
Copy
184 private void button4_Click(object sender, EventArgs e)
185 {
186 try
187 {
188 GroupBox4.Visible = true;
189 con = new SqlConnection(cs.DBConn);
190 con.Open();
191 cmd = new SqlCommand("SELECT RTRIM(invoiceNo) as [Order No],RTRIM(InvoiceDate) as [Order Date],RTRIM(Invoice_Info.CustomerID) as [Customer ID],RTRIM(CustomerName) as [Customer Name],RTRIM(SubTotal) as [SubTotal],RTRIM(VATPer) as [Vat+ST %],RTRIM(VATAmount) as [VAT+ST Amount],RTRIM(DiscountPer) as [Discount %],RTRIM(DiscountAmount) as [Discount Amount],RTRIM(GrandTotal) as [Grand Total],RTRIM(TotalPayment) as [Total Payment],RTRIM(PaymentDue) as [Payment Due],RTRIM(PaymentType) as [Payment Type],RTRIM(Status) as [Status],Remarks from Invoice_Info,Customer where Invoice_Info.CustomerID=Customer.CustomerID and Customer.CustomerID='" + txtCustomerID.Text + "' order by CustomerName,InvoiceDate", con);
192 SqlDataAdapter myDA = new SqlDataAdapter(cmd);
193 DataSet myDataSet = new DataSet();
194 myDA.Fill(myDataSet, "Invoice_Info");
195 myDA.Fill(myDataSet, "Customer");
196 DataGridView3.DataSource = myDataSet.Tables["Customer"].DefaultView;
197 DataGridView3.DataSource = myDataSet.Tables["Invoice_Info"].DefaultView;
198 Int64 sum = 0;
199 Int64 sum1 = 0;
200 Int64 sum2 = 0;
201
202 foreach (DataGridViewRow r in this.DataGridView3.Rows)
203 {
204 Int64 i = Convert.ToInt64(r.Cells[9].Value);
205 Int64 j = Convert.ToInt64(r.Cells[10].Value);
206 Int64 k = Convert.ToInt64(r.Cells[11].Value);
207 sum = sum + i;
208 sum1 = sum1 + j;
209 sum2 = sum2 + k;
210 }
211 TextBox6.Text = sum.ToString();
212 TextBox5.Text = sum1.ToString();
213 TextBox4.Text = sum2.ToString();
214
215 con.Close();
216 }
217 catch (Exception ex)
218 {
219 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
220 }
221 }
File name: frmOrder.cs
Copy
668 private void Button4_Click(object sender, EventArgs e)
669 {
670 this.Hide();
671 frmSalesRecord1 frm = new frmSalesRecord1();
672 frm.DataGridView1.DataSource = null;
673 frm.dtpInvoiceDateFrom.Text = DateTime.Today.ToString();
674 frm.dtpInvoiceDateTo.Text = DateTime.Today.ToString();
675 frm.GroupBox3.Visible = false;
676 frm.DataGridView3.DataSource = null;
677 frm.cmbCustomerName.Text = "";
678 frm.GroupBox4.Visible = false;
679 frm.DateTimePicker1.Text = DateTime.Today.ToString();
680 frm.DateTimePicker2.Text = DateTime.Today.ToString();
681 frm.DataGridView2.DataSource = null;
682 frm.GroupBox10.Visible = false;
683 frm.FillCombo();
684 frm.lblUser.Text = label6.Text;
685 frm.Show();
686 }
Button4 163 lượt xem
Gõ tìm kiếm nhanh...