예제 #1
0
        /// <summary>
        /// Nếu chọn can thì phải cập nhật lại chi.
        /// </summary>
        /// <param name="combobox"></param>
        /// <param name="comboboxToUpdate"></param>
        private void CapNhatChi(ComboBox combobox, ComboBox comboboxToUpdate)
        {
            ThienCan selectedCan = ThienCan.All[combobox.SelectedIndex];
            DiaChi   firstChi    = CanChi.GetChiDauTienHopLe(selectedCan);

            if (comboboxToUpdate.SelectedIndex < 0)
            {
                comboboxToUpdate.SelectedIndex = firstChi.Id - 1;
            }
            else
            {
                DiaChi currentChi = DiaChi.All[comboboxToUpdate.SelectedIndex];
                // Cập nhật chi nếu khác loại âm dương.
                if (currentChi.Duong != firstChi.Duong)
                {
                    comboboxToUpdate.SelectedIndex = firstChi.Id - 1;
                }
            }
        }