Exemplo n.º 1
0
        private void buttonadd_Click(object sender, EventArgs e)
        {
            openminiformadddoctor(new Adddoctor());
            Adddoctor formAddDoctor = new Adddoctor("add");

            formAddDoctor.ShowDialog();
            if (Adddoctor.doctor != null)
            {
                Doctorcs d = new Doctorcs(Adddoctor.doctor);
                // value type: int, double, char, string, boolean
                // reference type: Doctor, Patient, ...

                //AddDoctor.doctor; trong bộ nhớ address : 123
                //d trong bộ nhớ address: 234
                //d= AddDoctor.doctor; address của d = address của AddDoctor.doctor;

                if (string.IsNullOrEmpty(d.id.ToString()) || string.IsNullOrEmpty(d.phone.ToString()) || string.IsNullOrEmpty(d.name.ToString()) || string.IsNullOrEmpty(d.gender.ToString()))
                {
                    // không có gì thay đổi vì thông tin nhập vào không đầy dủ
                }
                else
                {
                    listDoctor.Add(d);
                    MessageBox.Show("Add successful");
                    LoadDoctor();
                }
            }
        }
Exemplo n.º 2
0
        private void listViewdoctor_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 = (Doctorcs)Doctor.listDoctor[index];
            }
        }
Exemplo n.º 3
0
        public void CreateDataDoctor()
        {
            // tạo ra các Doctor
            Doctorcs d1 = new Doctorcs("0001", "Doctor 1", "1234565789", "123 Greenwich U");



            Doctorcs d2 = new Doctorcs("0002", "Doctor 2", "1234565789", "123 Greenwich U");
            Doctorcs d3 = new Doctorcs("0003", "Doctor 3", "1234565789", "123 Greenwich U");
            Doctorcs d4 = new Doctorcs("0004", "Doctor 4", "1234565789", "123 Greenwich U");

            // add vào list
            listDoctor.Add(d1);
            listDoctor.Add(d2);
            listDoctor.Add(d3);
            listDoctor.Add(d4);
        }
Exemplo n.º 4
0
        private void buttonupdate_Click(object sender, EventArgs e)
        {
            openminiformadddoctor(new Adddoctor());
            Adddoctor formUpdate = new Adddoctor("Update");
            int       index      = Doctor.listDoctor.IndexOf(this.doctorSelected);

            Adddoctor.doctor.id     = doctorSelected.id;
            Adddoctor.doctor.name   = doctorSelected.name;
            Adddoctor.doctor.phone  = doctorSelected.phone;
            Adddoctor.doctor.gender = doctorSelected.gender;
            formUpdate.ShowDialog();

            Doctorcs d = (Doctorcs)listDoctor[index];

            d.id             = Adddoctor.doctor.id;
            d.name           = Adddoctor.doctor.name;
            d.gender         = Adddoctor.doctor.gender;
            d.phone          = Adddoctor.doctor.phone;
            Adddoctor.doctor = null;
            LoadDoctor();
            MessageBox.Show("Update successful");
        }