Exemplo n.º 1
0
        private void saveFamily(PERSONCARD personcard, Model1 model)
        {
            decimal max = model.FAMILY_MEMBER.Max(m => m.PK_MEMBER_FAMILY);

            foreach (var familyMember in model.FAMILY_MEMBER.Where(m => m.PK_PERSONCARD == personcard.PK_PERSONCARD))
            {
                model.FAMILY_MEMBER.Remove(familyMember);
            }

            for (int i = 0; i < dataGridView_family.Rows.Count - 1; i++)
            {
                String        name   = dataGridView_family.Rows[i].Cells[0].Value.ToString();
                FAMILY_MEMBER member = new FAMILY_MEMBER();
                member.PK_MEMBER_FAMILY = ++max;
                member.SURNAME          = name.Split(' ')[0];
                member.NAME             = name.Split(' ')[1];
                member.MIDDLENAME       = name.Split(' ')[2];
                member.PERSONCARD       = personcard;
                member.BIRTHYEAR        = Convert.ToDateTime(dataGridView_family.Rows[i].Cells[1].Value);
                model.FAMILY_MEMBER.Add(member);
            }
        }
Exemplo n.º 2
0
 // Отобразить командировки работника
 private void showKomandirovki(PERSONCARD card)
 {
     dataGridView_comand.Rows.Clear();
     try
     {
         foreach (var trip in card.PERSONCARD_IN_TRIP)
         {
             dataGridView_comand.Rows.Add(
                 // Первичный ключ в скрытое поле, чтобы потом открыть подробную инфу
                 trip.PK,
                 trip.STARTDATE.Value.ToString("dd.MM.yyyy"),
                 trip.ENDDATE.Value.ToString("dd.MM.yyyy"),
                 trip.UPDTRIP.TRIP_ORG.Count != 0 ? trip.UPDTRIP.TRIP_ORG.First().PLACE_TRIP.NAME : "",
                 trip.GOAL
                 );
         }
     }
     catch (Exception e)
     {
         // ну нет и нет, чего бубнить то
     }
 }
Exemplo n.º 3
0
 private void button_run_Click(object sender, EventArgs e)
 {
     using (StreamWriter writer = new StreamWriter(File.Create(Path.Combine(System.IO.Directory.GetCurrentDirectory(), "report.txt"))))
     {
         Model1 model = new Model1();
         writer.WriteLine("Общество с ограниченной ответственностью {0}", model.OUR_ORG.FirstOrDefault().NAME);
         writer.WriteLine(model.OUR_ORG.FirstOrDefault().ADDRESS);
         writer.WriteLine("тел. 8(822)13-80-22");
         writer.WriteLine("ИНН {0}, ОГРН {1}\n", model.OUR_ORG.FirstOrDefault().INN, model.OUR_ORG.FirstOrDefault().OGRN);
         writer.WriteLine("от {0}г.", DateTime.Now.ToString().Substring(0, 10));                 //todo дату в текущий момент времени
         writer.WriteLine("СПРАВКА");
         PERSONCARD finded = model.PERSONCARD.FirstOrDefault(p => (p.NAME == comboBox_nameValue.Text &&
                                                                   p.SURNAME == comboBox_surnameValue.Text &&
                                                                   p.MIDDLENAME == comboBox_middlenameValue.Text));
         if (finded == null)
         {
             MessageBox.Show("Сотрудник с указанными ФИО не найден!");
         }
         else
         {
             STR_SHTAT_RASP some_tariff = model.STR_SHTAT_RASP.Where(p => p.PK_PODRAZDEL == finded.TABEL.PK_PODRAZDEL).FirstOrDefault();
             Decimal?       end_tariff  = some_tariff.TARIFF + some_tariff.NADBAVKA1;
             //Decimal? some_stub = finded.TABEL.PK_PODRAZDEL;
             writer.Write("{0} {1} {2}, {3} г.р., ", finded.SURNAME, finded.NAME, finded.MIDDLENAME, finded.BIRTHDATE.ToString().Substring(0, 10));
             writer.WriteLine("работает в ООО {0} в должности ", model.OUR_ORG.FirstOrDefault().NAME);
             writer.WriteLine("{0} с {1} г. ", finded.JOB_POSITION.NAME, finded.DATECREATE.ToString().Substring(0, 10));
             writer.Write("по настоящее время, имеет оклад {0} рублей в месяц.", end_tariff);
             //writer.Write("по настоящее время, имеет оклад {0} рублей в месяц. {1}", end_tariff, some_stub);
             MessageBox.Show("Справка создана!");
             writer.Close();
         }
         using (FileStream fs = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "report.txt")))
         {
             PrintForm ownedForm = new PrintForm();
             ownedForm.Show();
         }
     }
 }
Exemplo n.º 4
0
        private void saveLanguage(PERSONCARD personcard, Model1 model)
        {
            decimal max = model.UNION_LANGUAGE_PERSONCARD.Max(u => u.PK_UNION);

            foreach (var lang in model.UNION_LANGUAGE_PERSONCARD.Where(m => m.PK_PERSONCARD == personcard.PK_PERSONCARD)
                     )
            {
                model.UNION_LANGUAGE_PERSONCARD.Remove(lang);
            }

            for (int i = 0; i < dataGridView_languages.Rows.Count - 1; i++)
            {
                var row  = dataGridView_languages.Rows[i];
                var lang = new UNION_LANGUAGE_PERSONCARD();
                lang.PK_UNION   = ++max;
                lang.PERSONCARD = personcard;
                string name = row.Cells[0].Value.ToString();
                string lvl  = row.Cells[1].Value.ToString();
                lang.LANGUAGE     = model.LANGUAGE.First(l => l.NAME == name);
                lang.LANGUAGE_LVL = model.LANGUAGE_LVL.First(l => l.NAME == lvl);
                model.UNION_LANGUAGE_PERSONCARD.Add(lang);
            }
        }
Exemplo n.º 5
0
        private void saveEducation(PERSONCARD personcard, Model1 model)
        {
            decimal max = model.ONE_EDU.Max(e => e.PK_ONE_EDU);

            foreach (var edu in model.ONE_EDU.Where(m => m.PK_PERSONCARD == personcard.PK_PERSONCARD))
            {
                model.ONE_EDU.Remove(edu);
            }

            for (int i = 0; i < dataGridView_education.Rows.Count - 1; i++)
            {
                var     row = dataGridView_education.Rows[i];
                ONE_EDU edu = new ONE_EDU();
                edu.PK_ONE_EDU = ++max;
                edu.NUMDOC     = row.Cells[0].Value.ToString();
                edu.ENDDATE    = Convert.ToDateTime(row.Cells[4].Value);
                edu.PERSONCARD = personcard;
                String type = row.Cells[1].Value.ToString(), place = row.Cells[2].Value.ToString(), specialyty = row.Cells[3].Value.ToString();
                edu.TYPE_EDU  = model.TYPE_EDU.First(t => t.NAME == type);
                edu.PLACE_EDU = model.PLACE_EDU.First(t => t.NAME == place);
                edu.SPECIALTY = model.SPECIALTY.First(s => s.NAME == specialyty);
                model.ONE_EDU.Add(edu);
            }
        }
Exemplo n.º 6
0
        private void saveData()
        {
            try
            {
                Model1     model = new Model1();
                PERSONCARD personcard;
                if (id != -1)
                {
                    personcard = model.PERSONCARD.First(x => x.PK_PERSONCARD == id);
                }
                else
                {
                    personcard = new PERSONCARD();
                }

                personcard.NAME       = textBox_name.Text;
                personcard.SURNAME    = textBox_secondName.Text;
                personcard.ALPHABET   = personcard.SURNAME[0].ToString();
                personcard.MIDDLENAME = textBox_otch.Text;
                personcard.MOBTEL     = textBox_telephone.Text;
                personcard.DOPTEL     = textBox_telephone2.Text;

                personcard.DATECREATE = DateTime.Now;

                personcard.GENDER = model.GENDER.First(g => g.NAME == comboBox_gender.Text);

                personcard.GRAZDAN = model.GRAZDAN.First(g => g.NAME == comboBox_grazdan.Text);

                personcard.SERPASSPORT            = textBox_passportSerial.Text;
                personcard.NUMPASSPORT            = textBox_passportNumber.Text;
                personcard.PLACE_VIDACHI_PASSPORT = richTextBox_vidan.Text;
                personcard.PASSPORTGETDATE        = Convert.ToDateTime(dateTimePicker_dateVidan.Text);

                personcard.BIRTHDATE  = Convert.ToDateTime(dateTimePicker_birthday.Text);
                personcard.PLACEBIRTH = richTextBox_birthdayPlace.Text;

                personcard.PLACELIVE     = richTextBox_livingPlace.Text;
                personcard.PLACEREGISTER = richTextBox_livingPlaceFact.Text;

                personcard.INN   = textBox_inn.Text;
                personcard.SNILS = textBox_strah.Text;

                personcard.MARTIAL_STATUS = model.MARTIAL_STATUS.First(m => m.NAME == comboBobx_brak.Text);

                if (comboBox_profession.Text != "")
                {
                    personcard.PROFESSION = model.PROFESSION.First(p => p.NAME == comboBox_profession.Text);
                }

                saveFamily(personcard, model);
                saveEducation(personcard, model);
                saveLanguage(personcard, model);

                try
                {
                    if (id == -1)
                    {
                        personcard.PK_PERSONCARD = model.PERSONCARD.Max(p => p.PK_PERSONCARD) + 1;
                        model.PERSONCARD.Add(personcard);
                    }

                    personcard.TABEL_NUM = personcard.PK_PERSONCARD;
                    model.SaveChanges();
                    id = Convert.ToInt64(personcard.PK_PERSONCARD);
                    button3.Enabled          = true;
                    textBox_tabelNumber.Text = personcard.TABEL_NUM.ToString();
                }
                catch (Exception e)
                {
                    DialogResult dialog = MessageBox.Show(
                        "Непредвиденная ошибка при сохранении личной карточки " + e.ToString(), "Ошибка",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                }
            }
            catch (Exception e)
            {
                DialogResult dialog = MessageBox.Show(
                    "Ошибка при заполнении данных", "Ошибка",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            }
        }