示例#1
0
        public bool importfrxml(string FileName)
        {
            myvariable.errcount = 0;
            string   regdate  = xml.importtext(FileName, "RegistrationDate", false);
            DateTime nulldate = Convert.ToDateTime("01/01/90");

            if (regdate != "" && Convert.ToDateTime(regdate) > Convert.ToDateTime("01/01/90"))
            {
                statuscomboBox.SelectedIndex = 0;
                regdatePicker.SelectedDate   = Convert.ToDateTime(regdate);
                if (!DateTime.TryParse(xml.importtext(FileName, "LeaseDuration", false), out nulldate))
                {
                    myvariable.errcount++;
                    MessageBox.Show((string)Application.Current.Resources["m_badleasedate"]);
                }
                termleasedatePicker.SelectedDate = nulldate;
            }
            else
            {
                statuscomboBox.SelectedIndex     = 1;
                regdatePicker.SelectedDate       = nulldate;
                termleasedatePicker.SelectedDate = nulldate;
            }
            string typeGrantor = xml.importtext(FileName, "typeGrantor", false);

            if (typeGrantor != "")
            {
                if (typeGrantor == "NaturalPerson")
                {
                    fizoryurcomboBox.SelectedIndex = 0;
                    lessortextBox.Text             = xml.importcontractorinf(FileName, "NaturalPerson_FullName", "Grantor", false);
                    inntextBox.Text      = xml.importcontractorinf(FileName, "NaturalPerson_TaxNumber", "Grantor", false);
                    passporttextBox.Text = xml.importcontractorinf(FileName, "NaturalPerson_Passport", "Grantor", false);
                    if (!DateTime.TryParse(xml.importcontractorinf(FileName, "NaturalPerson_PassportIssuedDate", "Grantor", false), out nulldate))
                    {
                        MessageBox.Show("неверный формат PassportIssuedDate");
                    }
                    vidandatePicker.SelectedDate = nulldate;
                    kemvidantextBox.Text         = xml.importcontractorinf(FileName, "NaturalPerson_IssuanceAuthority", "Grantor", false);
                    adresstextBox.Text           = xml.importcontractorinf(FileName, "NaturalPerson_Address", "Grantor", false);
                }
                else if (typeGrantor == "LegalEntity")
                {
                    fizoryurcomboBox.SelectedIndex = 1;
                    lessortextBox.Text             = xml.importcontractorinf(FileName, "LegalEntity_Name", "Grantor", false);
                    kodpredtextBox.Text            = xml.importcontractorinf(FileName, "LegalEntity_EDRPOU", "Grantor", false);
                    adresstextBox.Text             = xml.importcontractorinf(FileName, "LegalEntity_Address", "Grantor", false);
                }
            }
            string typeGrantee = xml.importtext(FileName, "typeGrantee", false);

            if (typeGrantee != "")
            {
                if (typeGrantee == "NaturalPerson")
                {
                    leaserfizoryurcomboBox.SelectedIndex = 0;
                    leasertextBox.Text         = xml.importcontractorinf(FileName, "NaturalPerson_FullName", "Grantee", false);
                    leaserinntextBox.Text      = xml.importcontractorinf(FileName, "NaturalPerson_TaxNumber", "Grantee", false);
                    leaserpassporttextBox.Text = xml.importcontractorinf(FileName, "NaturalPerson_Passport", "Grantee", false);
                    if (xml.importcontractorinf(FileName, "NaturalPerson_PassportIssuedDate", "Grantee", false) != "")
                    {
                        leaservidandatePicker.SelectedDate = Convert.ToDateTime(xml.importcontractorinf(FileName, "NaturalPerson_PassportIssuedDate", "Grantee", false));
                    }
                    else
                    {
                        leaservidandatePicker.SelectedDate = Convert.ToDateTime("01/01/53");
                    }
                    leaserkemvidantextBox.Text = xml.importcontractorinf(FileName, "NaturalPerson_IssuanceAuthority", "Grantee", false);
                    leaseradresstextBox.Text   = xml.importcontractorinf(FileName, "NaturalPerson_Address", "Grantee", false);
                }
                else if (typeGrantee == "LegalEntity")
                {
                    leaserfizoryurcomboBox.SelectedIndex = 1;
                    leasertextBox.Text        = xml.importcontractorinf(FileName, "LegalEntity_Name", "Grantee", false);
                    leaserkodpredtextBox.Text = xml.importcontractorinf(FileName, "LegalEntity_EDRPOU", "Grantee", false);
                    leaseradresstextBox.Text  = xml.importcontractorinf(FileName, "LegalEntity_Address", "Grantee", false);
                }
            }
            cadnumtextBox.Text = xml.importtext(FileName, "CadastralCode", false);
            sqtextBox.Text     = xml.importtext(FileName, "Size", false);
            koatuutextBox.Text = xml.importtext(FileName, "KOATUU", false);
            formownercomboBox.SelectedIndex = xml.importint(FileName, "OwnershipInfo", false);
            formusecomboBox.SelectedIndex   = xml.importint(FileName, "CategoryPurposeInfo", false);
            formunitcomboBox.SelectedIndex  = xml.importint(FileName, "LandCode", false);
            ck63.Clear();
            wgs84.Clear();
            ck63 = xml.importcoords(FileName, false);
            if (ck63 != null)
            {
                newcoords = true;
                ck63Entities.Reset(ck63);
                ck63View = (ListCollectionView)CollectionViewSource.GetDefaultView(ck63Entities);
                for (int i = 0; i < ck63.Count; i++)
                {
                    double[]   x   = { Convert.ToDouble(ck63[i].y.ToString().Replace(".", ",")) };
                    double[]   y   = { Convert.ToDouble(ck63[i].x.ToString().Replace(".", ",")) };
                    Projection src = new Projection(IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "CK63", "z" + x[0].ToString()[0]));
                    Projection dst = new Projection(@"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
                    Projection.Transform(src, dst, x, y, null);
                    wgs84.Add(new coordsformat()
                    {
                        x = y[0].ToString().Replace(",", "."), y = x[0].ToString().Replace(",", "."), rank = ck63[i].rank
                    });
                }
                wgs84Entities.Reset(wgs84);
                wgs84View = (ListCollectionView)CollectionViewSource.GetDefaultView(wgs84Entities);
            }
            if (myvariable.errcount > 0)
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        public bool importfrxml(string FileName)
        {
            myvariable.errcount = 0;
            myvariable.errstr   = "";
            string   regdate  = xml.importtext(FileName, "RegistrationDate", true);
            DateTime nulldate = Convert.ToDateTime("01/01/90");

            if (regdate != "" && Convert.ToDateTime(regdate) > Convert.ToDateTime("01/01/90"))
            {
                statuscomboBoxSelectedIndex = 0;
                regdatePickerSelectedDate   = Convert.ToDateTime(regdate);
                if (!DateTime.TryParse(xml.importtext(FileName, "LeaseDuration", true), out nulldate))
                {
                }
                termleasedatePickerSelectedDate = nulldate;
            }
            else
            {
                statuscomboBoxSelectedIndex     = 1;
                regdatePickerSelectedDate       = nulldate;
                termleasedatePickerSelectedDate = nulldate;
            }
            string typeGrantor = xml.importtext(FileName, "typeGrantor", true);

            if (typeGrantor != "")
            {
                if (typeGrantor == "NaturalPerson")
                {
                    fizoryurcomboBoxSelectedIndex = 0;
                    lessortextBoxText             = xml.importcontractorinf(FileName, "NaturalPerson_FullName", "Grantor", true);
                    inntextBoxText      = xml.importcontractorinf(FileName, "NaturalPerson_TaxNumber", "Grantor", true);
                    passporttextBoxText = xml.importcontractorinf(FileName, "NaturalPerson_Passport", "Grantor", true);
                    if (!DateTime.TryParse(xml.importcontractorinf(FileName, "NaturalPerson_PassportIssuedDate", "Grantor", true), out nulldate))
                    {
                        myvariable.errcount++;
                    }
                    vidandatePickerSelectedDate = nulldate;
                    kemvidantextBoxText         = xml.importcontractorinf(FileName, "NaturalPerson_IssuanceAuthority", "Grantor", true);
                    adresstextBoxText           = xml.importcontractorinf(FileName, "NaturalPerson_Address", "Grantor", true);
                }
                else if (typeGrantor == "LegalEntity")
                {
                    fizoryurcomboBoxSelectedIndex = 1;
                    lessortextBoxText             = xml.importcontractorinf(FileName, "LegalEntity_Name", "Grantor", true);
                    kodpredtextBoxText            = xml.importcontractorinf(FileName, "LegalEntity_EDRPOU", "Grantor", true);
                    adresstextBoxText             = xml.importcontractorinf(FileName, "LegalEntity_Address", "Grantor", true);
                }
            }
            string typeGrantee = xml.importtext(FileName, "typeGrantee", true);

            if (typeGrantee != "")
            {
                if (typeGrantee == "NaturalPerson")
                {
                    leaserfizoryurcomboBoxSelectedIndex = 0;
                    leasertextBoxText         = xml.importcontractorinf(FileName, "NaturalPerson_FullName", "Grantee", true);
                    leaserinntextBoxText      = xml.importcontractorinf(FileName, "NaturalPerson_TaxNumber", "Grantee", true);
                    leaserpassporttextBoxText = xml.importcontractorinf(FileName, "NaturalPerson_Passport", "Grantee", true);
                    if (xml.importcontractorinf(FileName, "NaturalPerson_PassportIssuedDate", "Grantee", true) != "")
                    {
                        leaservidandatePickerSelectedDate = Convert.ToDateTime(xml.importcontractorinf(FileName, "NaturalPerson_PassportIssuedDate", "Grantee", true));
                    }
                    else
                    {
                        leaservidandatePickerSelectedDate = Convert.ToDateTime("01/01/53");
                    }
                    leaserkemvidantextBoxText = xml.importcontractorinf(FileName, "NaturalPerson_IssuanceAuthority", "Grantee", true);
                    leaseradresstextBoxText   = xml.importcontractorinf(FileName, "NaturalPerson_Address", "Grantee", true);
                }
                else if (typeGrantee == "LegalEntity")
                {
                    leaserfizoryurcomboBoxSelectedIndex = 1;
                    leasertextBoxText        = xml.importcontractorinf(FileName, "LegalEntity_Name", "Grantee", true);
                    leaserkodpredtextBoxText = xml.importcontractorinf(FileName, "LegalEntity_EDRPOU", "Grantee", true);
                    leaseradresstextBoxText  = xml.importcontractorinf(FileName, "LegalEntity_Address", "Grantee", true);
                }
            }
            cadnumtextBoxText = xml.importtext(FileName, "CadastralCode", true);
            sqtextBoxText     = xml.importtext(FileName, "Size", true);
            koatuutextBoxText = xml.importtext(FileName, "KOATUU", true);
            formownercomboBoxSelectedIndex = xml.importint(FileName, "OwnershipInfo", true);
            formusecomboBoxSelectedIndex   = xml.importint(FileName, "CategoryPurposeInfo", true);
            formunitcomboBoxSelectedIndex  = xml.importint(FileName, "LandCode", true);
            ck63.Clear();
            wgs84.Clear();
            ck63 = xml.importcoords(FileName, true);
            if (ck63 != null)
            {
                for (int i = 0; i < ck63.Count; i++)
                {
                    double[]   x   = { Convert.ToDouble(ck63[i].y.ToString().Replace(".", ",")) };
                    double[]   y   = { Convert.ToDouble(ck63[i].x.ToString().Replace(".", ",")) };
                    Projection src = new Projection(IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "CK63", "z" + x[0].ToString()[0]));
                    Projection dst = new Projection(@"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
                    Projection.Transform(src, dst, x, y, null);
                    wgs84.Add(new coordsformat()
                    {
                        x = y[0].ToString().Replace(",", "."), y = x[0].ToString().Replace(",", "."), rank = ck63[i].rank
                    });
                }
            }
            string[] errstrs = myvariable.errstr.Split(':');
            if (myvariable.errcount > 0)
            {
                if (errstrs != null)
                {
                    int res = 0;
                    foreach (string param in errstrs)
                    {
                        if (IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "errlvl", param) != "0" && param != "")
                        {
                            res++;
                        }
                    }
                    if (res > 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                return(false);
            }
            return(true);
        }
示例#3
0
 public static ArrayList maxid()
 {
     try
     {
         using (var conn = new NpgsqlConnection("Server=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "server") + ";Port=" +
                                                IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "port") + ";User Id=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "user") +
                                                ";Password="******"\settings.ini", "DB", "pass") + ";Database=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "database") + ";"))
         {
             conn.Open();
             using (NpgsqlCommand comm = new NpgsqlCommand("SELECT MAX(ID) FROM contracts", conn))
             {
                 using (var reader = comm.ExecuteReader())
                 {
                     ArrayList lstSelect = new ArrayList();
                     while (reader.Read())
                     {
                         for (int i = 0; i < reader.FieldCount; i++)
                         {
                             lstSelect.Add(reader[i]);
                         }
                     }
                     conn.Close();
                     return(lstSelect);
                 }
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Errr on maxid!");
         return(null);
     }
 }
示例#4
0
 public static void update(string SQL)
 {
     try
     {
         using (var conn = new NpgsqlConnection("Server=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "server") + ";Port=" +
                                                IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "port") + ";User Id=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "user") +
                                                ";Password="******"\settings.ini", "DB", "pass") + ";Database=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "database") + ";"))
         {
             conn.Open();
             using (var cmd = new NpgsqlCommand())
             {
                 cmd.Connection  = conn;
                 cmd.CommandText = SQL;
                 cmd.ExecuteNonQuery();
                 conn.Close();
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Errr on update!");
     }
 }
示例#5
0
 public static List <coordsformat> selcoords(List <string> id, string table)
 {
     try
     {
         using (var conn = new NpgsqlConnection("Server=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "server") + ";Port=" +
                                                IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "port") + ";User Id=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "user") +
                                                ";Password="******"\settings.ini", "DB", "pass") + ";Database=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "database") + ";"))
         {
             conn.Open();
             using (var cmd = new NpgsqlCommand())
             {
                 cmd.Connection = conn;
                 List <coordsformat> lstSelect = new List <coordsformat>();
                 if (id.Count > 1)
                 {
                     cmd.CommandText = "SELECT* FROM " + table + " WHERE ID = '";
                     for (int l = 0; l < id.Count; l++)
                     {
                         if (l > 0)
                         {
                             cmd.CommandText = cmd.CommandText + "' or ID='" + id[l];
                         }
                         else
                         {
                             cmd.CommandText = cmd.CommandText + id[l];
                         }
                     }
                     cmd.CommandText = cmd.CommandText + "';";
                     using (var reader = cmd.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             for (int i = 0; i < reader.FieldCount / 4; i += 4)
                             {
                                 lstSelect.Add(new coordsformat()
                                 {
                                     id = Convert.ToInt32(reader[i]), x = reader[i + 1].ToString(), y = reader[i + 2].ToString(), rank = Convert.ToInt32(reader[i + 3])
                                 });
                             }
                         }
                     }
                     conn.Close();
                 }
                 else
                 {
                     cmd.CommandText = "SELECT * FROM " + table + " WHERE ID='" + id[0] + "';";
                     using (var reader = cmd.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             for (int i = 0; i < reader.FieldCount / 4; i += 4)
                             {
                                 lstSelect.Add(new coordsformat()
                                 {
                                     id = Convert.ToInt32(reader[i]), x = reader[i + 1].ToString(), y = reader[i + 2].ToString(), rank = Convert.ToInt32(reader[i + 3])
                                 });
                             }
                         }
                         conn.Close();
                     }
                 }
                 return(lstSelect);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Errr on select coords!");
         return(null);
     }
 }
示例#6
0
 public static ArrayList select(string SQL)
 {
     try
     {
         using (var conn = new NpgsqlConnection("Server=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "server") + ";Port=" +
                                                IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "port") + ";User Id=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "user") +
                                                ";Password="******"\settings.ini", "DB", "pass") + ";Database=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "database") + ";"))
         {
             conn.Open();
             using (var cmd = new NpgsqlCommand())
             {
                 cmd.Connection  = conn;
                 cmd.CommandText = SQL;
                 using (var reader = cmd.ExecuteReader())
                 {
                     ArrayList lstSelect = new ArrayList();
                     while (reader.Read())
                     {
                         for (int i = 0; i < reader.FieldCount; i++)
                         {
                             lstSelect.Add(reader[i]);
                         }
                     }
                     conn.Close();
                     return(lstSelect);
                 }
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Errr on select!");
         return(null);
     }
 }
示例#7
0
 public static List <contract> selcontr()
 {
     try
     {
         using (var conn = new NpgsqlConnection("Server=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "server") + ";Port=" +
                                                IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "port") + ";User Id=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "user") +
                                                ";Password="******"\settings.ini", "DB", "pass") + ";Database=" + IniFile.Read(AppDomain.CurrentDomain.BaseDirectory + @"\settings.ini", "DB", "database") + ";"))
         {
             conn.Open();
             using (var cmd = new NpgsqlCommand())
             {
                 cmd.Connection  = conn;
                 cmd.CommandText = "select * from contracts";
                 using (var reader = cmd.ExecuteReader())
                 {
                     List <contract> contracts = new List <contract>();
                     while (reader.Read())
                     {
                         contracts.Add(new contract
                         {
                             id = Convert.ToInt32(reader[0]),
                             contract_number   = Convert.ToString(reader[1]),
                             date_contract     = Convert.ToString(reader[2]),
                             lessor            = Convert.ToString(reader[3]),
                             cadastral_number  = Convert.ToString(reader[4]),
                             square            = Convert.ToString(reader[5]),
                             term_lease        = Convert.ToString(reader[6]),
                             registration_date = Convert.ToString(reader[7]),
                             contract_status   = Convert.ToString(reader[8]),
                             unit_number       = Convert.ToString(reader[9]),
                             notes             = Convert.ToString(reader[10]),
                             type_contract     = Convert.ToString(reader[11]),
                             area_number       = Convert.ToString(reader[12]),
                             form_owner        = Convert.ToString(reader[13]),
                             form_use          = Convert.ToString(reader[14]),
                             form_unit         = Convert.ToString(reader[15]),
                             koatuu            = Convert.ToString(reader[16]),
                             leaser            = Convert.ToString(reader[17]),
                             contractortype    = Convert.ToString(reader[18])
                         });
                     }
                     conn.Close();
                     return(contracts);
                 }
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Errr on select contract!");
         return(null);
     }
 }