Example #1
0
 public WorkerCard()
 {
     InitializeComponent();
     initializeComboBoxes();
     wi               = new WorkerInfo();
     newworker        = true;
     newworkersaved   = false;
     newpositionsaved = false;
     tbCardNum.Text   = okDB.getAvailableCardId().ToString();
 }
Example #2
0
        public WorkerCard(string cardid)
        {
            InitializeComponent();
            initializeComboBoxes();
            newworker = false;
            wi        = okDB.getWorker(cardid);

            //common info
            tbFio.Text      = wi.commonInfo.fio;
            tbTabelNum.Text = wi.tabelId;
            tbCardNum.Text  = wi.cardId;
            if (wi.commonInfo.birthDate < dpBirthDate.MinDate || wi.commonInfo.birthDate > dpBirthDate.MaxDate)
            {
                dpBirthDate.Value = DateTime.Now;
            }
            else
            {
                dpBirthDate.Value = wi.commonInfo.birthDate;
            }
            cbProfsojuz.Checked = wi.commonInfo.profsojuz;
            tbNationality.Text  = wi.commonInfo.nationality;
            tbPassportNum.Text  = wi.commonInfo.passportNum;
            tbPersonalNum.Text  = wi.commonInfo.personalNum;
            tbVidan.Text        = wi.commonInfo.passportFrom;
            if (wi.commonInfo.passportDateFrom < dpPassportFrom.MinDate || wi.commonInfo.passportDateFrom > dpPassportFrom.MaxDate)
            {
                dpPassportFrom.Value = DateTime.Now;
            }
            else
            {
                dpPassportFrom.Value = wi.commonInfo.passportDateFrom;
            }
            if (wi.commonInfo.passportDateTo < dpPassportTo.MinDate || wi.commonInfo.passportDateTo > dpPassportTo.MaxDate)
            {
                dpPassportTo.Value = DateTime.Now;
            }
            else
            {
                dpPassportTo.Value = wi.commonInfo.passportDateTo;
            }
            tbBirthCountry.Text   = wi.commonInfo.birthCountry;
            tbBirthDistrict.Text  = wi.commonInfo.birthDistrict;
            tbBirthRegion.Text    = wi.commonInfo.birthRegion;
            tbBirthPlace.Text     = wi.commonInfo.birthPlace;
            tbLivingCountry.Text  = wi.commonInfo.livingCountry;
            tbLivingDistrict.Text = wi.commonInfo.livingDistrict;
            tbLivingRegion.Text   = wi.commonInfo.livingRegion;
            tbLivingPlace.Text    = wi.commonInfo.livingPlace;
            tbLivingAdress.Text   = wi.commonInfo.livingAdress;
            tbLivingPhone.Text    = wi.commonInfo.livingPhone;
            tbMobilePhone.Text    = wi.commonInfo.mobilePhone;
            for (int i = 0; i < cbGender.Items.Count; i++)
            {
                if (cbGender.Items[i].ToString().Equals(wi.commonInfo.gender))
                {
                    cbGender.SelectedIndex = i;
                    break;
                }
            }
            for (int i = 0; i < cbFamilyStatus.Items.Count; i++)
            {
                if (cbFamilyStatus.Items[i].ToString().Equals(wi.commonInfo.familyStatus))
                {
                    cbFamilyStatus.SelectedIndex = i;
                    break;
                }
            }

            //family
            dgvFamily.Rows.Clear();
            for (int i = 0; i < wi.family.Count; i++)
            {
                dgvFamily.Rows.Add(wi.family[i].connection, wi.family[i].fio, wi.family[i].birthDate.ToShortDateString(), wi.family[i].id);
            }
            if (wi.family.Count > 0)
            {
                dgvFamily.Rows[0].Selected = true;
            }

            //education
            dgvEducation.Rows.Clear();
            for (int i = 0; i < wi.education.Count; i++)
            {
                dgvEducation.Rows.Add(wi.education[i].id, wi.education[i].educationType, wi.education[i].eduPlace, wi.education[i].faculty, wi.education[i].specialization, wi.education[i].qualification, wi.education[i].diplomaNum, wi.education[i].diplomaDate.ToShortDateString());
            }
            if (wi.education.Count > 0)
            {
                dgvEducation.Rows[0].Selected = true;
            }

            //positon
            if (wi.position.startdate < dpStartDate.MinDate || wi.position.startdate > dpStartDate.MaxDate)
            {
                dpStartDate.Value = DateTime.Now;
            }
            else
            {
                dpStartDate.Value = wi.position.startdate;
            }
            tbOrderNum.Text = wi.position.ordernum;
            cbMat.Checked   = wi.position.mat;
            if (wi.position.currposfrom < dpCurrPosFrom.MinDate || wi.position.currposfrom > dpCurrPosFrom.MaxDate)
            {
                dpCurrPosFrom.Value = DateTime.Now;
            }
            else
            {
                dpCurrPosFrom.Value = wi.position.currposfrom;
            }
            tbCurrPosOrderNum.Text = wi.position.currposordernum;
            tbCurrOrderNum.Text    = wi.position.currordernum;
            if (wi.position.currorderfrom < dpCurrOrderFrom.MinDate || wi.position.currorderfrom > dpCurrOrderFrom.MaxDate)
            {
                dpCurrOrderFrom.Value = DateTime.Now;
            }
            else
            {
                dpCurrOrderFrom.Value = wi.position.currorderfrom;
            }
            if (wi.position.currorderto < dpCurrOrderTo.MinDate || wi.position.currorderto > dpCurrOrderTo.MaxDate)
            {
                dpCurrOrderTo.Value = DateTime.Now;
            }
            else
            {
                dpCurrOrderTo.Value = wi.position.currorderto;
            }
            for (int i = 0; i < cbDepartment.Items.Count; i++)
            {
                if (cbDepartment.Items[i].ToString().Equals(wi.position.department))
                {
                    cbDepartment.SelectedIndex = i;
                    break;
                }
            }
            for (int i = 0; i < cbPosition.Items.Count; i++)
            {
                if (cbPosition.Items[i].ToString().Equals(wi.position.position))
                {
                    cbPosition.SelectedIndex = i;
                    break;
                }
            }
        }