示例#1
0
        private void lvDoctor_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListView lsv = sender as ListView;

            if (lsv.SelectedItems.Count == 1)
            {
                ListViewItem item  = lsv.SelectedItems[0];
                int          index = Convert.ToInt32(item.Text);
                doctorSelected = (Models.Doctor)Doctor.listDoctor[index];
            }
        }
示例#2
0
        public void CreateDataDoctor()
        {
            // tạo ra các Doctor
            Models.Doctor d1 = new Models.Doctor("0001", "Võ Văn Tín", "HCM City", "Male");
            Models.Doctor d2 = new Models.Doctor("0002", "Trần Văn Học", "Đà Nẵng City", "Male");
            Models.Doctor d3 = new Models.Doctor("0003", "Kiều Hồng Oanh", "Hà Nội City", "Female");
            Models.Doctor d4 = new Models.Doctor("0004", "Jack C.Richards", "Sigapore", "Female");

            // add vào list
            listDoctor.Add(d1);
            listDoctor.Add(d2);
            listDoctor.Add(d3);
            listDoctor.Add(d4);
        }
        public static string LastIdDoctor(List <Models.Doctor> list)
        {
            string id = "";

            // 3 doctor thì last index 0, 1, 2 => Length - 1 = 3 - 1 = 2
            Models.Doctor temp = (Models.Doctor)list[list.Count() - 1];
            // lấy id cuối cùng trong bảng Doctor
            int lastId = Convert.ToInt32(temp.ID);

            // id = 10
            // => 0010 thêm 2 số 0
            // 4 - id.ToString().Length 5=> 1 ; 14 => 2; 154 => 3
            for (int i = 0; i < 4 - lastId.ToString().Length; i++)
            {
                id += "0";
            }
            return(id + (lastId + 1).ToString());
        }
示例#4
0
        private void button3_Click(object sender, EventArgs e)
        {
            AddDoctor formUpdate = new AddDoctor("Update");
            int       index      = Doctor.listDoctor.IndexOf(this.doctorSelected);

            AddDoctor.doctor.ID      = doctorSelected.ID;
            AddDoctor.doctor.Name    = doctorSelected.Name;
            AddDoctor.doctor.Address = doctorSelected.Address;
            AddDoctor.doctor.Gender  = doctorSelected.Gender;
            formUpdate.ShowDialog();

            Models.Doctor d = (Models.Doctor)listDoctor[index];
            d.ID             = AddDoctor.doctor.ID;
            d.Name           = AddDoctor.doctor.Name;
            d.Address        = AddDoctor.doctor.Address;
            d.Gender         = AddDoctor.doctor.Gender;
            AddDoctor.doctor = null;
            LoadDoctor();
            MessageBox.Show("Update successful");
        }
示例#5
0
        private void button2_Click(object sender, EventArgs e)
        {
            AddDoctor formAddDoctor = new AddDoctor("Add");

            formAddDoctor.ShowDialog();
            if (AddDoctor.doctor != null)
            {
                Models.Doctor d = new Models.Doctor(AddDoctor.doctor);


                if (string.IsNullOrEmpty(d.ID.ToString()) || string.IsNullOrEmpty(d.Address.ToString()) || string.IsNullOrEmpty(d.Name.ToString()) || string.IsNullOrEmpty(d.Gender.ToString()))
                {
                }
                else
                {
                    listDoctor.Add(d);
                    MessageBox.Show("Add successful");
                    LoadDoctor();
                }
            }
        }