Exemplo n.º 1
0
 private void AddPersonToLists(Person p)
 {
     _notFilteredPersons.Add(p);
     if (!PersonInFilter(p)) return;
     personsList.Items.Add(p);
     personsList.SelectedItem = p;
 }
Exemplo n.º 2
0
 public bool RemovePerson(Person p)
 {
     if (Persons.IndexOf(p.Id) != -1)
     {
         Persons.Remove(p.Id);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 public bool AddPerson(Person p)
 {
     if (Persons.IndexOf(p.Id) == -1)
     {
         Persons.Add(p.Id);
         FillPersonInfoFromPacket(p);
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 public void EditPerson(Person person, Packet templatePacket = null)
 {
     _person = person;
     if (templatePacket != null)
         if (templatePacket.TemplatePerson != null)
             _person.MergeBlanks(templatePacket.TemplatePerson);
     FormMode = Mode.Edit;
     btnClose.Visible = false;
     saveDialogResult = DialogResult.OK;
 }
Exemplo n.º 5
0
 private void editTemplate_Click(object sender, EventArgs e)
 {
     var form = new PersonForm { AutoSavePerson = false};
     var person = new Person();
     person.Merge(linkedPacket.TemplatePerson, true);
     var allPersons = PersonStorage.Instance.LoadAll();
     form.InitCombos(allPersons);
     form.EditPerson(person);
     if (form.ShowDialog() != DialogResult.OK) return;
     linkedPacket.TemplatePerson.Merge(person);
 }
Exemplo n.º 6
0
        private void scan_Click(object sender, EventArgs e)
        {
            if (Scanner.Instance.Valid)
            {
                if (!Scanner.Instance.HasScanner)
                    Scanner.Instance.InitTwain();
                if (!Scanner.Instance.HasScanner)
                {
                    MessageBox.Show(Resources.NoScanners);
                    return;
                }
                var ops = new BackgroundOptions
                              {
                                  IsBackground = true,
                                  IsAutoClose = true,
                                  AutoCloseDelay = 10
                              };

                Scanner.Instance.Init(ops);
                if (Scanner.Instance.Success)
                {
                    _person = Scanner.Instance.FillPerson(_person);
                    //if (scannedPerson != null)
                    //{
                        //_person.Merge(scannedPerson);
                        _linker.MoveDataFromObject();
                    //}
                }
            }
        }
Exemplo n.º 7
0
 private void CreateNewPerson()
 {
     _person = new Person();
     if (_templatePacket != null)
         if (_templatePacket.TemplatePerson != null)
             _person.Merge(_templatePacket.TemplatePerson);
 }
Exemplo n.º 8
0
 private void createPerson_Click(object sender, EventArgs e)
 {
     var form = new PersonForm();
     var allPersons = personsList.Items.Cast<Person>().ToList();
     form.InitCombos(allPersons);
     form.PersonCreated += (o, args) =>
                               {
                                   var newPerson = new Person();
                                   newPerson.Merge(o as Person);
                                   AddPersonToLists(newPerson);
                                   PersonStorage.Instance.Save(newPerson);
                                   if (!createToPacket.Checked) return;
                                   if (_currentPacket == null) CreateNewPacket();
                                   if (_currentPacket == null) return;
                                   _currentPacket.AddPerson(newPerson);
                                   currentPacketList.Items.Add(newPerson);
                                   PacketStorage.Instance.Save(_currentPacket);
                                   PersonStorage.Instance.Save(newPerson);
                               };
     form.CreatePerson(_currentPacket);
     form.ShowDialog();
 }
Exemplo n.º 9
0
 private void removeFromPacket_Click(object sender, EventArgs e)
 {
     if (_currentPacket == null)
         CreateNewPacket();
     if (_currentPacket == null)
         return;
     var items = new Person[currentPacketList.SelectedItems.Count];
     currentPacketList.SelectedItems.CopyTo(items, 0);
     foreach (var p in items)
     {
         var i = _currentPacket.IndexOfPerson(p);
         _currentPacket.Persons.RemoveAt(i);
         currentPacketList.Items.Remove(p);
     }
     PacketStorage.Instance.Save(_currentPacket);
 }
Exemplo n.º 10
0
 private bool PersonInFilter(Person p)
 {
     var filter = personFilter.Text;
     return string.IsNullOrEmpty(filter) || p.FilterOk(filter);
 }
Exemplo n.º 11
0
 private static string GenerateFileName(Person person)
 {
     if (person.hdr_kscreated == "") person.hdr_kscreated = "MIN";
     return person.hdr_kscreated + person.hdr_regnom + ".xml";
 }
Exemplo n.º 12
0
        internal void Merge(Packet otherPacket)
        {
            var tempId = Id;
            var fieldInfos = GetType().GetFields();
            foreach (var info in fieldInfos)
            {
                var val = info.GetValue(otherPacket);
                if (val == null) continue;

                if (info.FieldType == typeof(Person))
                {
                    var otherPerson = (Person) val;
                    var newPerson = new Person();
                    newPerson.Merge(otherPerson, true);
                    info.SetValue(this, newPerson);
                    continue;
                }

                if (string.IsNullOrEmpty(val.ToString())) continue;
                info.SetValue(this, val);
            }
            Id = tempId;
        }
Exemplo n.º 13
0
 internal int IndexOfPerson(Person p)
 {
     return Persons.IndexOf(p.Id);
 }
Exemplo n.º 14
0
 private void FillPersonInfoFromPacket(Person p)
 {
     p.VisaStartDate = TemplatePerson.VisaStartDate;
     p.VisaEndDate = TemplatePerson.VisaEndDate;
     p.VoucherNumber = TemplatePerson.VoucherNumber;
     p.VoucherValidFrom = TemplatePerson.VoucherValidFrom;
     p.VoucherValidTo = TemplatePerson.VoucherValidTo;
 }
Exemplo n.º 15
0
        private static RootLoadOsf GetRoot(Person person)
        {
            var root = new RootLoadOsf();
            root.msgHeader.msgHeaderRow.mh_datvav = DateTime.Now.ToString("yyyy-MM-dd");
            root.msgHeader.msgHeaderRow.mh_kscreated = person.hdr_kscreated;                // ***
            root.msgHeader.msgHeaderRow.mh_regnom = person.hdr_regnom;                      // ***
            root.msgHeader.msgHeaderRow.mh_usera = person.hdr_user;                         // ***
            root.msgHeader.msgHeaderRow.mh_vfsrefno = person.Id;

            root.lcuz.lcuzRow.vid_zp = person.DocumentType == DocType.ForeignerPassport ? "C" : "P";
            root.lcuz.lcuzRow.nac_bel = ConvertCountry(person.DocumentIssuedBy);
            root.lcuz.lcuzRow.nac_pasp = person.DocumentNumber;
            root.lcuz.lcuzRow.pasp_val = ConvertDate(person.DocumentValidDate, "yyyy-MM-dd");
            root.lcuz.lcuzRow.graj = ConvertCountry(person.Citizenship);
            root.lcuz.lcuzRow.famil = person.Surname;
            root.lcuz.lcuzRow.imena = person.Name;
            root.lcuz.lcuzRow.dat_raj = ConvertDate(person.BirthDate, @"yyyy/MM/dd");
            root.lcuz.lcuzRow.pol = person.Sex == Sex.Male ? "M" : "F";
            root.lcuz.lcuzRow.dat_izd = person.DocumentIssuedDate != Person.NOT_VALID_DATE ? ConvertDate(person.DocumentIssuedDate, "yyyy-MM-dd") : "";

            root.lcDop.lcDopRow.ld_mrjdarj = ConvertCountry(person.BirthCountry);
            root.lcDop.lcDopRow.ld_mrjnm = person.BirthPlace;
            root.lcDop.lcDopRow.ld_mrjgraj = ConvertCountry(person.BirthCitizenship);
            root.lcDop.lcDopRow.ld_zenen = ConvertStatus(person.Status);
            root.lcDop.lcDopRow.ld_jit_darj = ConvertCountry(person.AddressCountry);    // ***
            root.lcDop.lcDopRow.ld_jit_nm = person.AddressCity;                         // ***
            root.lcDop.lcDopRow.ld_jit_ul = person.AddressStreet;                       // ***
            root.lcDop.lcDopRow.ld_jit_pk = person.AddressZipCode;                      // ***
            root.lcDop.lcDopRow.ld_tel = person.PhoneNumber;
            root.lcDop.lcDopRow.ld_jit_email = person.Email;                            // ***
            root.lcDop.lcDopRow.ld_rabota = person.WorkName;                            // ***
            root.lcDop.lcDopRow.ld_profkod = ConvertProfCode(person.ProfessionId);        // ***
            root.lcDop.lcDopRow.ld_profesia = person.Profession;
            root.lcDop.lcDopRow.ld_sl_darj = ConvertCountry(person.WorkCountry);        // ***
            root.lcDop.lcDopRow.ld_sl_nm = person.WorkCity;                             // ***
            root.lcDop.lcDopRow.ld_sl_ul = person.WorkAddress;                          // ***
            root.lcDop.lcDopRow.ld_sl_pk = person.WorkZip;                              // ***
            root.lcDop.lcDopRow.ld_sltel = person.WorkPhoneNumber;                      // ***
            root.lcDop.lcDopRow.ld_sl_fax = person.WorkFaxNumber;                       // ***
            root.lcDop.lcDopRow.ld_sl_email = person.WorkEmail;                         // ***

            root.basta.bastaRow.dc_famil = person.FatherSurname;                        // ***
            root.basta.bastaRow.dc_imena = person.FatherName;                           // ***

            root.maika.maikaRow.dc_famil = person.MotherSurname;                        // ***
            root.maika.maikaRow.dc_imena = person.MotherName;                           // ***

            //if (person.Status == Status.Married)
            //{
                root.sapruga.saprugaRow.sp_famil = person.SpouseSurname; // ***
                root.sapruga.saprugaRow.sp_famil2 = person.SpouseSurnameAtBirth; // ***
                root.sapruga.saprugaRow.sp_imena = person.SpouseName; // ***
                root.sapruga.saprugaRow.sp_datraj = ConvertDate(person.SpouseBirthDate); // ***
                root.sapruga.saprugaRow.sp_mrjdarj = ConvertCountry(person.SpouseBirthCountry); // ***
                root.sapruga.saprugaRow.sp_mrjnm = person.SpouseBirthCity;
            //}

            root.molba.molbaRow.dat_vli = ConvertDate(person.VisaStartDate, "yyyy-MM-dd");
            root.molba.molbaRow.dat_izl = ConvertDate(person.VisaEndDate, "yyyy-MM-dd");
            root.molba.molbaRow.vidvis = ConvertVisaType(person.VisaType);                                   // ***
            root.molba.molbaRow.brvl = ConvertEntries(person.NumberOfEntries);                              // ***
            root.molba.molbaRow.vidus = person.ProcessingSpeed ? "B" : "O";                             // ***
            root.molba.molbaRow.valvis = ConvertMultiVisaPeriod(person.MultiVisaPeriod);                            // ***
            root.molba.molbaRow.brdni = person.Duration;
            root.molba.molbaRow.cel = ConvertPurpose(person.Purpose);                       // ***
            root.molba.molbaRow.celdruga = person.OtherPurpose;                             // ***
            root.molba.molbaRow.mol_dat_vav = person.DateOfApply;  // ***
            root.molba.molbaRow.gratis = person.Gratis ? "Y" : "N";                         // ***
            root.molba.molbaRow.imavisa = person.TransitDestinationPermit ? "Y" : "N/A";                  // ***
            root.molba.molbaRow.cenamol = person.Fee;                                       // ***
            root.molba.molbaRow.cenacurr = person.FeeCurrency;                              // ***
            root.molba.molbaRow.maindest = person.DestinationCountry;                       // ***
            root.molba.molbaRow.maindestnm = person.DestinationCity;                        // ***
            root.molba.molbaRow.gkpp_darj = person.BorderOfFirstEntry;                      // ***
            root.molba.molbaRow.gkpp_text = person.BorderCheckpoint;                        // ***
            root.molba.molbaRow.marsrut = person.TransitRoute;                              // ***
            root.molba.molbaRow.Text_ini = person.VisaAdditionalInfo;                       // ***

            //if (person.Purpose != Purpose.OrganizedTourism)
            //{
                root.domakin.domakinRow.dm_vid = ConvertHosting(person.HostType); // ***
                root.domakin.domakinRow.nom_pok = person.InvitationNumber; // ***
                root.domakin.domakinRow.dom_graj = person.HostPersonCitizenship; // ***
                root.domakin.domakinRow.dom_famil = person.HostPersonSurname; // ***
                root.domakin.domakinRow.dom_ime = person.HostPersonName; // ***
                root.domakin.domakinRow.dom_egn = person.HostPersonID; // ***
                root.domakin.domakinRow.dom_darj = ConvertCountry(person.HostPersonCountry); // ***
                root.domakin.domakinRow.dom_nm = person.HostPersonCity; // ***
                root.domakin.domakinRow.dom_pk = person.HostPersonZipCode; // ***
                root.domakin.domakinRow.dom_adres = person.HostPersonAddress; // ***
                root.domakin.domakinRow.dom_tel = person.HostPersonPhone; // ***
                root.domakin.domakinRow.dom_fax = person.HostPersonFax; // ***
                root.domakin.domakinRow.dom_email = person.HostPersonEmail; // ***
                root.domakin.domakinRow.ved_ekpou = person.HostCompanyID; // ***
                root.domakin.domakinRow.ved_ime = person.HostHotelName;
                root.domakin.domakinRow.ved_darj = ConvertCountry(person.HostHotelCountry); // ***
                root.domakin.domakinRow.ved_nm = person.HostHotelCity; // ***
                root.domakin.domakinRow.ved_pk = person.HostHotelZipCode; // ***
                root.domakin.domakinRow.ved_adres = person.HostHotelAddress; // ***
                root.domakin.domakinRow.ved_tel = person.HostHotelPhone;
                root.domakin.domakinRow.ved_fax = person.HostHotelFax; // ***
                root.domakin.domakinRow.ved_email = person.HostHotelEmail; // ***
            //}
            //else
            //{
                root.voit.voitRow.vnom = person.VoucherNumber;
                root.voit.voitRow.voit_datot = ConvertDate(person.VoucherValidFrom, "yyyy-MM-dd");
                root.voit.voitRow.voit_datdo = ConvertDate(person.VoucherValidTo, "yyyy-MM-dd");
                root.voit.voitRow.vime = person.VoucherIssuedBy;
                root.voit.voitRow.bgime = person.HostCompanyName;
                root.voit.voitRow.bgadres = person.HostHotelName;
                root.voit.voitRow.tel = person.HostCompanyPhone;
            //}

            OldVisaRow oldVisa;
            if (person.Visa1Enabled)
            {
                oldVisa = new OldVisaRow
                              {
                                  ov_nacbel = person.Visa1Country,
                                  ov_vidvis = ConvertVisaType(person.Visa1Type),
                                  ov_visnom = person.Visa1Number,
                                  ov_dataot = ConvertDate(person.Visa1From, "yyyy-MM-dd"),
                                  ov_datado = ConvertDate(person.Visa1To, "yyyy-MM-dd"),
                                  ov_brvl = ConvertEntries(person.Visa1NumberOfEntries)
                              };

                root.oldVisa.oldVisaRows.Add(oldVisa);
            }
            if (person.Visa2Enabled)
            {
                oldVisa = new OldVisaRow
                {
                    ov_nacbel = person.Visa2Country,
                    ov_vidvis = ConvertVisaType(person.Visa2Type),
                    ov_visnom = person.Visa2Number,
                    ov_dataot = ConvertDate(person.Visa2From, "yyyy-MM-dd"),
                    ov_datado = ConvertDate(person.Visa2To, "yyyy-MM-dd"),
                    ov_brvl = ConvertEntries(person.Visa2NumberOfEntries)
                };

                root.oldVisa.oldVisaRows.Add(oldVisa);
            }
            if (person.Visa3Enabled)
            {
                oldVisa = new OldVisaRow
                {
                    ov_nacbel = person.Visa3Country,
                    ov_vidvis = ConvertVisaType(person.Visa3Type),
                    ov_visnom = person.Visa3Number,
                    ov_dataot = ConvertDate(person.Visa3From, "yyyy-MM-dd"),
                    ov_datado = ConvertDate(person.Visa3To, "yyyy-MM-dd"),
                    ov_brvl = ConvertEntries(person.Visa3NumberOfEntries)
                };

                root.oldVisa.oldVisaRows.Add(oldVisa);
            }

            if (person.Image != null)
            {
                root.images.imagesRow.im_width = person.Image.Width.ToString();
                root.images.imagesRow.im_height = person.Image.Height.ToString();
                root.images.imagesRow.im_image = ImageConverter.ConvertImageToBase64(person.Image, ImageFormat.Jpeg);
                root.images.imagesRow.im_imglen = root.images.imagesRow.im_image.Length.ToString();
            }

            return root;
        }
Exemplo n.º 16
0
 public void EditPerson(Person person)
 {
     _person = person;
 }
Exemplo n.º 17
0
 public Person MergeBlanks(Person person)
 {
     var tempId = Id;
     var fieldInfos = GetType().GetFields();
     foreach (var info in fieldInfos)
     {
         if (string.IsNullOrEmpty(info.GetValue(this).ToString()))
         {
             var val = info.GetValue(person);
             if (val == null) continue;
             if (string.IsNullOrEmpty(val.ToString())) continue;
             info.SetValue(this, val);
         }
     }
     _image = person._image;
     _thumbnail = person._thumbnail;
     Id = tempId;
     return this;
 }