có bài tập này muốn hỏi mọi người là sao cái textbox Diem trung binh, Luong, Hoc ham hoc vi cua mình khi debug no ko chạy nhỉ ? các textbox khác chạy bình thường, code đây trong đó class person là add thêm vào nhá.
form1
Mã:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace QuanLiNhanSu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
initPosition();
}
// Khoi tao gia tri cho comboBox1
public void initPosition()
{
comboBox1.Items.Add("GIAO VIEN");
comboBox1.Items.Add("SINH VIEN");
comboBox1.Items.Add("NHAN VIEN");
comboBox1.SelectedIndex = 0;
}
//Bắt su kien nut Them
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
Person addedPerson = new Person(textBox1.Text, comboBox1.Text, dateTimePicker1.Value, textBox2.Text, textBox3.Text, textBox4.Text);
listBox1.Items.Add(addedPerson);
textBox1.Clear();
}
}
//Bắt sự kiện nút xoá
private void button2_Click(object sender, EventArgs e)
{
int selectedIndex = listBox1.SelectedIndex;
if (selectedIndex >= 0)
{
MessageBox.Show("Da xoa : " + listBox1.Items[selectedIndex] + "\"");
listBox1.Items.RemoveAt(selectedIndex);
}
}
//Xử lý sự kiện khi click chọn trên listBox để hiển thị thông tin
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
richTextBox1.Clear();
int selectedIndex = listBox1.SelectedIndex;
//check if there is an items is select
if (selectedIndex >= 0)
{
Person selectedPerson = (Person)listBox1.Items[selectedIndex];
richTextBox1.Text += "Ho va Ten : " + selectedPerson.Name + "
" +
"Chuc vu : " + selectedPerson.Position + "
" +
"Ngay Thang Nam Sinh : " + selectedPerson.BirthDay.ToShortDateString() + "
"
+ "Diem trung binh : " + selectedPerson.Dtb + "
" + "Luong : " + selectedPerson.Luong
+ "
" + "Hoc ham hoc vi : " + selectedPerson.Hocvi + "
";
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
person class
Mã:
using System;
using System.Collections.Generic;
using System.Text;
namespace QuanLiNhanSu
{
class Person
{
private string name;
private string position;
private DateTime birthDay;
private float dtb;
private float luong;
private string hocvi;
public Person(string _name, string _position, DateTime _birthDay,float _dtb, float _luong, string _hocvi)
{
name = _name;
position = _position;
birthDay = _birthDay;
dtb = _dtb;
luong = _luong;
hocvi = _hocvi;
}
public override string ToString()
{
return name;
}
// Tao propeties
public string Name
{
get { return name; }
}
public string Position
{
get { return position; }
}
public string Hocvi
{
get { return hocvi; }
}
public DateTime BirthDay
{
get { return birthDay; }
}
public float Dtb
{
get { return dtb; }
}
public float Luong
{
get { return luong; }
}
// Khoi tao gia tri cho cmb_Position
}
}
Ngọc Bích xanh bản chất thuộc dòng đá đá hoa (jade). Và cẩm thạch là tên gọi chung của ngọc bích. Vì thực chất chúng thuộc dòng đá đa khoáng được hình thành từ chất Silicat dưới dạng dioxy. Ngọc bích...
Chia sẻ Vòng tay ngọc bích xanh là...