Anda di halaman 1dari 6

DANH SACH THỂ THAO

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BAI1_SQL
{
public partial class danhsachthethao : Form
{
public danhsachthethao()
{
InitializeComponent();
}

private void danhsachthethao_Load(object sender, EventArgs e)


{
txtdate.Text = DateTime.Now.ToString("dd/MM/yyyy");
txthour.Text = DateTime.Now.ToString("hh:mm:ss tt");
//
this.cbohoten.Items.Add("Nguyễn Hữu Trọng");
this.cbohoten.Items.Add("Nguyễn Tấn Tài");
this.cbohoten.Items.Add("Nguyễn Trọng Lê");
this.cbohoten.Items.Add("Nguyễn Phú Trọng");
this.cbohoten.Items.Add("Nguyễn Tấn Đạt");

//
this.lstdanhsach.Items.Add("Bóng đá");
this.lstdanhsach.Items.Add("Bóng bàn");
this.lstdanhsach.Items.Add("Cầu lông");
this.lstdanhsach.Items.Add("Bóng bầu dục");
}

private void btnchuyenhet_Click(object sender, EventArgs e)


{

try
{
int count = lstdanhsach.Items.Count;
for (int i = 0; i < count; i++)
{
lstdanhsach.SelectedIndex = 0;
lstdachon.Items.Add(lstdanhsach.SelectedItem.ToString());
lstdanhsach.Items.Remove(lstdanhsach.SelectedItem.ToString());
}
}
catch(Exception)
{
MessageBox.Show("Bạn chưa chọn item?", "Thông báo");
}
}
private void btnchuyenindex_Click(object sender, EventArgs e)
{
try
{
int n = lstdanhsach.SelectedIndex;
string item = lstdanhsach.Items[n].ToString();
lstdachon.Items.Add(item);
lstdanhsach.Items.Remove(item);
}
catch(Exception)
{
MessageBox.Show("Bạn chưa chọn item?", "Thông báo");
}
}

private void btntralai_Click(object sender, EventArgs e)


{
try
{

int count = lstdachon.Items.Count;


for (int i = 0; i < count; i++)
{
lstdachon.SelectedIndex = 0;
lstdanhsach.Items.Add(lstdachon.SelectedItem.ToString());
lstdachon.Items.Remove(lstdachon.SelectedItem.ToString());
}
}
catch(Exception)
{
MessageBox.Show("Bạn chưa chọn item?", "Thông báo");
}
}

private void btntralaiindex_Click(object sender, EventArgs e)


{
try
{
int n = lstdachon.SelectedIndex;
string item = lstdachon.Items[n].ToString();
lstdanhsach.Items.Add(item);
lstdachon.Items.Remove(item);
}
catch(Exception)
{
MessageBox.Show("Bạn chưa chọn item?", "Thông báo");
}
}

private void btnnhap_Click(object sender, EventArgs e)


{
int n=lstdachon.Items.Count;
khungkq.Text = cbohoten.Text + "\r\n" + txtdate.Text + " " + txthour.Text +
"\r\n**Môn đã chọn:";
for(int i=0;i< n;i++)
{
lstdachon.SelectedIndex = i;
khungkq.Text += lstdachon.Text + ";";
}
}

private void btnreset_Click(object sender, EventArgs e)


{
this.lstdachon.Items.Clear();
this.khungkq.ResetText();
this.cbohoten.ResetText();
this.cbohoten.Focus();
this.lstdanhsach.Items.Add("Bóng đá");
this.lstdanhsach.Items.Add("Bóng bàn");
this.lstdanhsach.Items.Add("Cầu lông");
this.lstdanhsach.Items.Add("Bóng bầu dục");

}
}
}

DÃY SỐ TÍNH TỔNG


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BAI1_SQL
{
public partial class daysotinhtong : Form
{
public daysotinhtong()
{
InitializeComponent();
}
private void daysotinhtong_Load(object sender, EventArgs e)
{

}
int tongchan = 0;
int tongle = 0;
int tongday = 0;
private void btnnhap_Click(object sender, EventArgs e)
{
int x = Convert.ToInt32(txtnhapso.Text);
txtdayso.Text += x.ToString().Trim()+" ";
tongday += x;
txttongso.Text = tongday.ToString();
if(x%2==0)
{
tongchan += x;
txttongchan.Text = tongchan.ToString();
}
else
{
tongle += x;
txttongle.Text = tongle.ToString();
}

private void btntieptuc_Click(object sender, EventArgs e)


{
txtdayso.ResetText();
txtnhapso.ResetText();
txttongso.ResetText();
txttongchan.ResetText();
txttongle.ResetText();
txtnhapso.Focus();
tongday = 0;
tongle = 0;
tongchan = 0;
}

private void btnthoat_Click(object sender, EventArgs e)


{
DialogResult traloi = MessageBox.Show("Bạn có muốn thoát không?", "Thông
báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
if (traloi == DialogResult.OK)
this.Close();
}
}
}

DỊCH VỤ KHÁM BỆNH

private void Form1_Load(object sender, EventArgs e)


{
this.lstdichvu.Items.Add("Siêu âm");
this.lstdichvu.Items.Add("Thử máu");
this.lstdichvu.Items.Add("Nội soi");
this.lstdichvu.Items.Add("X-Quang");

private void lstdachondv_SelectedIndexChanged(object sender, EventArgs e)


{

private void lstdichvu_SelectedIndexChanged(object sender, EventArgs e)


{
this.lstdachondv.Items.Add(lstdichvu.SelectedItem.ToString());
}
private void btnchon_Click(object sender, EventArgs e)
{
int i;
int n = lstdachondv.Items.Count;
khungkq.Text = "Họ tên:" + txthoten.Text+ "\r\nNgày sinh: " + txtngay.Text +
"/" + txtthang.Text + "/" + txtnam.Text + "\r\nDịch vụ đã chọn :";
for(i=0;i<=n-1;i++)
{
lstdachondv.SelectedIndex = i;
khungkq.Text += lstdachondv.Text + ",";
}
}

CÔNG TY DU LỊCH

private void congtydulich_Load(object sender, EventArgs e)


{
this.lstdiemdi.Items.Add("TP.HCM");
this.lstdiemdi.Items.Add("Đồng Tháp");
this.lstdiemdi.Items.Add("Hà Nội");
this.lstdiemdi.Items.Add("Cần Thơ");
//
this.lstdiemden.Items.Add("Hàn Quốc");
this.lstdiemden.Items.Add("Thái Lan");
this.lstdiemden.Items.Add("Úc");
this.lstdiemden.Items.Add("Lào");

private void btnnhap_Click(object sender, EventArgs e)


{
if (txtkhachhang.Text == "" && txtdiachi.Text == "")
{
errorProvider1.SetError(txtkhachhang, "Chưa nhập khách hàng");
errorProvider1.SetError(txtdiachi, "Chưa nhập địa chỉ");
}
else
{
khungketqua.Text = "Khách hàng : " + txtkhachhang.Text + "\r\nNgày sinh :
" + txtngaysinh.Text + "\r\nĐịa chỉ : " + txtdiachi.Text + "\r\nĐịa điểm xuất phát : " +
lstdiemdi.SelectedItem + "\r\nĐịa điểm đến :" + lstdiemden.SelectedItem + "\r\nTổng số
ngày đi :" + txttongngay.Text;
}
}

private void txttongngay_TextChanged(object sender, EventArgs e)


{

private void time_ngayden_ValueChanged(object sender, EventArgs e)


{
txttongngay.Text = Convert.ToInt32((time_ngayden.Value -
time_ngaydi.Value).TotalDays).ToString();
}

private void btnReset_Click(object sender, EventArgs e)


{
this.txtkhachhang.ResetText();
this.txtdiachi.ResetText();
this.khungketqua.ResetText();
this.txtkhachhang.Focus();

private void btnthoat_Click(object sender, EventArgs e)


{
DialogResult traloi = MessageBox.Show("Bạn có chắc thoát không ?","Thông
báo",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
if (traloi == DialogResult.OK)
this.Close();

Anda mungkin juga menyukai