示例#1
0
文件: Form1.cs 项目: swalder44/AVGK
        private void button1_Click(object sender, EventArgs e)
        {
            var binding       = new BasicHttpBinding();
            var endpoint      = new EndpointAddress(new Uri(string.Format("http://{0}:5050/Service.asmx", "10.10.10.49"))); //Environment.MachineName))); //"192.168.20.30")));
            var serviceClient = new ServiceReference1.RASVSRClient(binding, endpoint);

            ServiceReference1.CheckRequestData request_send = new ServiceReference1.CheckRequestData()
            {
                AxlesCount     = ACc,                                //new int[] { 1, 2, 3 },
                AxlesInvervals = AIc,                                //new decimal[] { 1m, 2m, 3m },
                AxlesLoads     = ALc,                                //new decimal[] { 1m, 2m, 3m },
                CheckDate      = Convert.ToDateTime(DTc.ToString()), //DateTime.Now,
                CheckPointCode = CPCc.ToString(),                    //"001",
                Direction      = Dc,                                 //1,
                //Latitude = Convert.ToDecimal("123,5"),
                //Longitude = Convert.ToDecimal("127,5"),
                TotalWeight      = TWc,  //10m,
                VehicleRegNumber = GRZc, //"123ка77",
                TotalSize        = new ServiceReference1.CheckRequestDataTotalSize()
                {
                    Height = Hc, //10m,
                    Length = Lc, //10m,
                    Width  = Wc, //10m
                }
            };
            XmlSerializer formatter_input   = new XmlSerializer(typeof(ServiceReference1.CheckRequestData));
            MemoryStream  memoryStreamInput = new MemoryStream();

            formatter_input.Serialize(memoryStreamInput, request_send);
            textBox1.Text = StreamToString(memoryStreamInput);
            try
            {
                var rezRequest = serviceClient.Check(request_send);
                Rrc = rezRequest.Count;
                if (rezRequest.Count != 0)
                {
                    int        INPR        = 0;
                    ConnectStr ResRegionSR = new ConnectStr();
                    ResRegionSR.ConStr(1);
                    cstrU = ResRegionSR.StP;
                    MySqlConnection sqlConnectionT = new MySqlConnection(cstrU);
                    //dataGridView1.DataSource = rezRequest;//ServiceReference1.CheckResultDataList;
                    foreach (var b in rezRequest)//int i=0; i<rezRequest.Count; i++)
                    {
                        //if (b.wr)
                        this.dataGridView1.Rows.Add(b.VehicleRegNumber.ToString(),
                                                    b.Resolution.DocumentNumber.ToString(),
                                                    b.Resolution.DocumentDateSign.ToString(),
                                                    b.DateFrom.ToString(),
                                                    b.DateTo.ToString(),
                                                    b.TripCount,
                                                    b.LeftTripCount,
                                                    b.Route.ToString(),
                                                    b.Dimensions.ToString(),
                                                    DecToStr(b.AxlesLoads),
                                                    b.FullWeight
                                                    );

                        PrNal   = b.RouteCheck.Code;
                        NSR     = b.Resolution.DocumentNumber;
                        DSR     = Convert.ToString(b.Resolution.DocumentDateSign);
                        SrDSR   = Convert.ToString(b.DateTo);
                        RMarshr = b.Route;
                        RM      = b.FullWeight;
                        KRPr    = b.TripCount;
                        KOstPr  = b.LeftTripCount;
                        LSR     = b.Dimensions.Length;
                        WSR     = b.Dimensions.Width;
                        HSR     = b.Dimensions.Height;
                        //IdPrSTR = DateTime.Now.ToString("yyMMdd")+ IdPr.ToString() ;
                        // IdPr = Convert.ToDecimal(IdPrSTR.ToString());
                        INPR1   = Guid.NewGuid();
                        IdPrSTR = Convert.ToString(INPR1).Replace("-", "");

                        MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
                        cmd.CommandText = "INSERT INTO raptssprrazr "
                                          + "("
                                          + "idts, "
                                          + "dateregsr, "
                                          + "grzrasp, "
                                          + "KemVid, "
                                          + "VidPerevoz, "
                                          + "GRZSR, "
                                          + "NomSR, "
                                          + "DateVidSR, "
                                          + "SrokDeistvSR, "
                                          + "RazrMarshr, "
                                          + "RazrMassa, "
                                          + "KolRazrPr, "
                                          + "IspolzPR, "
                                          + "LengthSR, "
                                          + "WidthSR, "
                                          + "HeightSR, "
                                          + "NarushenMarshrSR, "
                                          + "DateZapr, "
                                          + "NomZapr) "
                                          + "VALUES "
                                          + "(" + IdPr + ", "
                                          + "'" + b.DateFrom.ToString("o") + "', "
                                          + "'" + GRZc + "', "
                                          + "'ГБУ Севастопольский Автодор', "
                                          + "'" + b.ShippingType + "', "
                                          + "'" + b.VehicleRegNumber + "', "
                                          + "'" + b.Resolution.DocumentNumber + "', "
                                          + "'" + b.Resolution.DocumentDateSign.ToString("o") + "', "
                                          + "'" + b.DateTo.ToString("o") + "', "
                                          + "'" + b.Route + "', "
                                          + "" + b.FullWeight + ", "
                                          + "" + b.TripCount + ", "
                                          + "" + b.LeftTripCount + ", "
                                          + "" + b.Dimensions.Length + ", "
                                          + "" + b.Dimensions.Width + ", "
                                          + "" + b.Dimensions.Height + ", "
                                          + "" + b.RouteCheck.Code + ", "
                                          + "now(), "
                                          + "'" + IdPrSTR + "');";
                        //Guid.NewGuid()
                        cmd.Connection = sqlConnectionT;
                        if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                        {
                            sqlConnectionT.Open();
                        }
                        //sqlConnectionT.Open();
                        cmd.ExecuteNonQuery();
                        /* sqlConnectionT.Close()*/
                        ;


                        //ConnectStr ResRegionSR = new ConnectStr();
                        //ResRegionSR.ConStr(1);
                        //cstrU = ResRegionSR.StP;
                        //MySqlConnection sqlConnectionT = new MySqlConnection(cstrU);

                        IInt    = new decimal[b.AxlesInvervals.Length + 1];
                        IInt[0] = 0;
                        for (int iint = 0; iint < b.AxlesInvervals.Length; iint++)
                        {
                            IInt[iint + 1] = b.AxlesInvervals[iint];
                        }
                        for (int iax = 0; iax < b.AxlesLoads.Length; iax++)
                        {
                            MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand();
                            cmd2.CommandText = "INSERT INTO rapsprazraxel( "
                                               + "IDSR, "
                                               + "NomAx, "
                                               //+ "NomGr, "
                                               + "MasAxSR, "
                                               + "IntervalAxSR, "
                                               + "SkatAxSR, "
                                               + "CountRAxSR, "
                                               + "Created, "
                                               + "NSR) "
                                               + "VALUES("
                                               + "" + IdPrSTR + ", "
                                               + "" + iax + ", "
                                               //+ "DEFAULT, "
                                               + "" + b.AxlesLoads[iax] + ", "
                                               + "" + IInt[iax] + ", "
                                               + "" + b.AxlesWeelsEx[iax] + ", "
                                               + "" + b.AxlesWheels[iax] + ", "
                                               + "now(), "
                                               + "'" + b.Resolution.DocumentNumber + "'); ";
                            cmd2.Connection = sqlConnectionT;
                            if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                            {
                                sqlConnectionT.Open();
                            }
                            //sqlConnectionT.Open();
                            cmd2.ExecuteNonQuery();
                        }
                        sqlConnectionT.Close();
                    }
                }
                else
                {
                    INPR1   = Guid.NewGuid();
                    IdPrSTR = Convert.ToString(INPR1).Replace("-", "");
                    ConnectStr ResRegionSR = new ConnectStr();
                    ResRegionSR.ConStr(1);
                    cstrU = ResRegionSR.StP;
                    MySqlConnection sqlConnectionT           = new MySqlConnection(cstrU);
                    MySql.Data.MySqlClient.MySqlCommand cmd3 = new MySql.Data.MySqlClient.MySqlCommand();
                    cmd3.CommandText = "INSERT INTO raptssprrazr "
                                       + "("
                                       + "idts, "
                                       + "grzrasp, "
                                       + "DateZapr, "
                                       + "NomZapr) "
                                       + "VALUES "
                                       + "(" + IdPr + ", "
                                       + "'" + GRZc + "', "
                                       + "now(), "
                                       + "'" + IdPrSTR + "');";
                    //Guid.NewGuid()
                    cmd3.Connection = sqlConnectionT;
                    if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                    {
                        sqlConnectionT.Open();
                    }
                    //sqlConnectionT.Open();
                    cmd3.ExecuteNonQuery();
                    /* sqlConnectionT.Close()*/
                    ;
                    sqlConnectionT.Close();
                }
            }
            catch (Exception ex) { }
        }
示例#2
0
        public void button1_Click()
        {
            DTN = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ff");
            var binding       = new BasicHttpBinding();
            var endpoint      = new EndpointAddress(new Uri(string.Format("http://10.10.10.49:5050/Service.asmx")));//"http://{0}:5050/Service.asmx", "10.10.10.49"))); // "192.168.110.39"))); //Environment.MachineName))); //"192.168.20.30")));
            var serviceClient = new ServiceReference1.RASVSRClient(binding, endpoint);

            ServiceReference1.CheckRequestData request_send = new ServiceReference1.CheckRequestData()
            {
                AxlesCount       = ACc,                                //new int[] { 1, 2, 3 },
                AxlesInvervals   = AIc,                                //new decimal[] { 1m, 2m, 3m },
                AxlesLoads       = ALc,                                //new decimal[] { 1m, 2m, 3m },
                CheckDate        = Convert.ToDateTime(DTc.ToString()), //DateTime.Now,
                CheckPointCode   = CPCc.ToString(),                    //"001",
                Direction        = Dc,
                TotalWeight      = TWc,                                //10m,
                VehicleRegNumber = GRZc,                               //"123ка77",
                TotalSize        = new ServiceReference1.CheckRequestDataTotalSize()
                {
                    Height = Hc, //10m,
                    Length = Lc, //10m,
                    Width  = Wc, //10m
                }
            };
            XmlSerializer formatter_input   = new XmlSerializer(typeof(ServiceReference1.CheckRequestData));
            MemoryStream  memoryStreamInput = new MemoryStream();

            formatter_input.Serialize(memoryStreamInput, request_send);
            try
            {
                var rezRequest = serviceClient.Check(request_send);
                Rrc = rezRequest.Count;
                if (rezRequest.Count == 1)
                {
                    //DTN = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ff");
                    int INPR = 0;
                    INPR1      = Guid.NewGuid();
                    IdPrSTR    = Convert.ToString(INPR1).Replace("-", "");
                    NZaprFalse = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd") + NZapr.ToString());
                    ConnectStr ResRegionSR = new ConnectStr();
                    ResRegionSR.ConStr(1);
                    cstrU = ResRegionSR.StP;
                    MySqlConnection sqlConnectionT = new MySqlConnection(cstrU);
                    //dataGridView1.DataSource = rezRequest;//ServiceReference1.CheckResultDataList;

                    foreach (var b in rezRequest)//int i=0; i<rezRequest.Count; i++)
                    {
                        //if (b.wr)
                        a.VehicleRegNumber = b.VehicleRegNumber.ToString();
                        a.DocumentNumber   = b.Resolution.DocumentNumber.ToString();
                        a.DocumentDateSign = b.Resolution.DocumentDateSign.ToString();
                        a.DateFrom         = b.DateFrom.ToString();
                        a.DateTo           = b.DateTo.ToString();
                        a.TripCount        = b.TripCount;
                        a.LeftTripCount    = b.LeftTripCount;
                        a.Route            = b.Route.ToString();
                        a.Dimensions       = b.Dimensions.ToString();
                        a.AxlesLoads       = b.AxlesLoads;
                        a.FullWeight       = b.FullWeight;

                        PrNal      = Convert.ToInt32(b.RouteCheck.Code);
                        NSR        = b.Resolution.DocumentNumber;
                        DSR        = Convert.ToString(b.Resolution.DocumentDateSign);
                        SrDSR      = Convert.ToString(b.DateTo);
                        RMarshr    = b.Route;
                        RM         = b.FullWeight;
                        KRPr       = b.TripCount;
                        KOstPr     = b.LeftTripCount;
                        LSR        = b.Dimensions.Length;
                        WSR        = b.Dimensions.Width;
                        HSR        = b.Dimensions.Height;
                        INPR1      = Guid.NewGuid();
                        IdPrSTR    = Convert.ToString(INPR1).Replace("-", "");
                        NZaprFalse = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd") + NZapr.ToString());

                        MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
                        cmd.CommandText = "INSERT INTO raptssprrazr "
                                          + "("
                                          + "idts, "
                                          + "dateregsr, "
                                          + "grzrasp, "
                                          + "KemVid, "
                                          + "VidPerevoz, "
                                          + "GRZSR, "
                                          + "NomSR, "
                                          + "DateVidSR, "
                                          + "SrokDeistvSR, "
                                          + "RazrMarshr, "
                                          + "RazrMassa, "
                                          + "KolRazrPr, "
                                          + "IspolzPR, "
                                          + "LengthSR, "
                                          + "WidthSR, "
                                          + "HeightSR, "
                                          + "NarushenMarshrSR, "
                                          + "DateZapr, "
                                          + "NomZapr, "
                                          + "DPR, "
                                          + "OstatPR, "
                                          + "NZFalse ) "
                                          + "VALUES "
                                          + "(" + IdPr + ", "
                                          + "'" + b.DateFrom.ToString("o") + "', "
                                          + "'" + GRZc + "', "
                                          + "'ГБУ Севастопольский Автодор', "
                                          + "'" + b.ShippingType + "', "
                                          + "'" + b.VehicleRegNumber + "', "
                                          + "'" + b.Resolution.DocumentNumber + "', "
                                          + "'" + b.Resolution.DocumentDateSign.ToString("o") + "', "
                                          + "'" + b.DateTo.ToString("o") + "', "
                                          + "'" + b.Route + "', "
                                          + "" + b.FullWeight + ", "
                                          + "" + b.TripCount + ", "
                                          + "" + (b.TripCount - b.LeftTripCount + 1) + ", "//b.LeftTripCount + ", "
                                          + "" + b.Dimensions.Length + ", "
                                          + "" + b.Dimensions.Width + ", "
                                          + "" + b.Dimensions.Height + ", "
                                          + "'" + b.RouteCheck.Code + "', "
                                          + "'" + DTN + "', "
                                          + "'" + IdPrSTR + "', "
                                          + "'" + Convert.ToDateTime(DTc.ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "', "
                                          + "" + b.LeftTripCount + ", "
                                          + "" + Convert.ToInt64(NZaprFalse) + "); ";
                        //Guid.NewGuid()
                        cmd.Connection = sqlConnectionT;
                        if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                        {
                            sqlConnectionT.Open();
                        }
                        //sqlConnectionT.Open();
                        cmd.ExecuteNonQuery();
                        ;

                        IInt    = new decimal[b.AxlesInvervals.Length + 1];
                        IInt[0] = 0;
                        for (int iint = 0; iint < b.AxlesInvervals.Length; iint++)
                        {
                            IInt[iint + 1] = b.AxlesInvervals[iint];
                        }
                        for (int iax = 0; iax < b.AxlesLoads.Length; iax++)
                        {
                            MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand();
                            cmd2.CommandText = "INSERT INTO rapsprazraxel( "
                                               + "IDSR, "
                                               + "NomAx, "
                                               //+ "NomGr, "
                                               + "MasAxSR, "
                                               + "IntervalAxSR, "
                                               + "SkatAxSR, "
                                               + "CountRAxSR, "
                                               + "Created, "
                                               + "NSR) "
                                               + "VALUES("
                                               + "'" + IdPrSTR + "', "
                                               + "" + iax + ", "
                                               //+ "DEFAULT, "
                                               + "" + b.AxlesLoads[iax] + ", "
                                               + "" + IInt[iax] + ", "
                                               + "" + b.AxlesWeelsEx[iax] + ", "
                                               + "" + b.AxlesWheels[iax] + ", "
                                               + "'" + DTN + "', "
                                               + "'" + b.Resolution.DocumentNumber + "'); ";
                            cmd2.Connection = sqlConnectionT;
                            if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                            {
                                sqlConnectionT.Open();
                            }
                            //sqlConnectionT.Open();
                            cmd2.ExecuteNonQuery();
                        }
                        sqlConnectionT.Close();
                    }
                }
                else if (rezRequest.Count == 0)
                {
                    // DTN = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ff");
                    INPR1      = Guid.NewGuid();
                    IdPrSTR    = Convert.ToString(INPR1).Replace("-", "");
                    NZaprFalse = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd") + NZapr.ToString());

                    ConnectStr ResRegionSR = new ConnectStr();
                    ResRegionSR.ConStr(1);
                    cstrU = ResRegionSR.StP;
                    MySqlConnection sqlConnectionT           = new MySqlConnection(cstrU);
                    MySql.Data.MySqlClient.MySqlCommand cmd3 = new MySql.Data.MySqlClient.MySqlCommand();
                    cmd3.CommandText = "INSERT INTO raptssprrazr "
                                       + "("
                                       + "idts, "
                                       + "grzrasp, "
                                       + "DateZapr, "
                                       + "NomZapr, "
                                       + "DPR, "
                                       + "NZFalse) "
                                       + "VALUES "
                                       + "(" + IdPr + ", "
                                       + "'" + GRZc + "', "
                                       + "'" + DTN + "', "
                                       + "'" + IdPrSTR + "', "
                                       + "'" + Convert.ToDateTime(DTc.ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "', "
                                       + "" + Convert.ToInt64(NZaprFalse) + "); ";
                    //Guid.NewGuid()
                    cmd3.Connection = sqlConnectionT;
                    if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                    {
                        sqlConnectionT.Open();
                    }
                    //sqlConnectionT.Open();
                    cmd3.ExecuteNonQuery();
                    /* sqlConnectionT.Close()*/
                    ;

                    MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand();
                    cmd2.CommandText = "delete n "
                                       + "from raptssprrazr h "
                                       + "join raptssprrazr n on n.idts = h.idts AND n.PriznNal = h.PriznNal and n.IdPor > h.IdPor;";

                    cmd2.Connection = sqlConnectionT;
                    if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                    {
                        sqlConnectionT.Open();
                    }
                    //sqlConnectionT.Open();
                    cmd2.ExecuteNonQuery();

                    sqlConnectionT.Close();



                    MySqlCommand command = new MySqlCommand();
                    ConnectStr   conStr  = new ConnectStr();
                    //Zapros zapros = new Zapros();
                    conStr.ConStr(1);

                    //zapros.ZaprObrSpRazrLoc(IDT, NamU, 1);
                    MySqlConnection connection = new MySqlConnection(conStr.StP);
                    string          z          = "UPDATE vehiclecontainer_r"
                                                 + " SET `Change` = 1,"
                                                 + " ChangeType =  1 ,"
                                                 + " DateChang = '" + DTN + "',"
                                                 + " NameUs = 'AUTO',"
                                                 + " Prim = 'Изменено Спец. Разрешение'"
                                                 + " WHERE ID = " + IdPr + " ;";
                    command.CommandText = z;
                    command.Connection  = connection;
                    try
                    {
                        command.Connection.Open();
                        command.ExecuteNonQuery();
                        command.Connection.Close();
                    }
                    catch (MySqlException ex)
                    { Console.WriteLine("Error: \r\n{0}", ex.ToString()); }
                    finally
                    { command.Connection.Close(); }
                }
                else if (rezRequest.Count > 1)
                {
                    Boolean[] flags = new Boolean[10];
                    int       INPR  = 0;
                    int       j;
                    // DTN = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ff");
                    decimal minos; decimal minosproc; decimal minosi = 0;
                    Boolean flag; Boolean flagnorm;
                    INPR1      = Guid.NewGuid();
                    IdPrSTR    = Convert.ToString(INPR1).Replace("-", "");
                    NZaprFalse = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd") + NZapr.ToString());
                    ConnectStr ResRegionSR = new ConnectStr();
                    ResRegionSR.ConStr(1);
                    cstrU = ResRegionSR.StP;
                    MySqlConnection sqlConnectionT = new MySqlConnection(cstrU);
                    //dataGridView1.DataSource = rezRequest;//ServiceReference1.CheckResultDataList;
                    minos = 10000; minosproc = 0;
                    decimal[] bufer;

                    j = 0;
                    foreach (var b in rezRequest)//int i=0; i<rezRequest.Count; i++)
                    {
                        i    = 0;
                        flag = true;

                        cc.AxlesLoads = b.AxlesLoads;
                        foreach (var c in cc.AxlesLoads)
                        {
                            if ((ALc[i] - c > 0) && (prevnar[i] > 3))
                            {
                                flag = false;
                            }
                            i = i + 1;
                        }

                        if (flag == true)
                        {
                            flags[j] = true;
                        }
                        j = j + 1;
                    }
                    j = 0;
                    // без форичей запоминаем его номер
                    foreach (var b in rezRequest)//int i=0; i<rezRequest.Count; i++)
                    {
                        i             = 0;
                        cc.AxlesLoads = b.AxlesLoads;

                        foreach (var c in cc.AxlesLoads)
                        {
                            //от парадокса избавляемся двумя циклами
                            if ((Math.Abs(ALc[i] - c) < minos) && (flags[j] == true))
                            {
                                minos = Math.Abs(ALc[i] - c); minosi = j;
                            }
                        }
                    }
                    j = 0;
                    // без форичей запоминаем его номер
                    foreach (var b in rezRequest)//int i=0; i<rezRequest.Count; i++)
                    {
                        if (j == minosi)
                        {
                            //if (b.wr)
                            a.VehicleRegNumber = b.VehicleRegNumber.ToString();
                            a.DocumentNumber   = b.Resolution.DocumentNumber.ToString();
                            a.DocumentDateSign = b.Resolution.DocumentDateSign.ToString();
                            a.DateFrom         = b.DateFrom.ToString();
                            a.DateTo           = b.DateTo.ToString();
                            a.TripCount        = b.TripCount;
                            a.LeftTripCount    = b.LeftTripCount;
                            a.Route            = b.Route.ToString();
                            a.Dimensions       = b.Dimensions.ToString();
                            a.AxlesLoads       = b.AxlesLoads;
                            a.FullWeight       = b.FullWeight;

                            PrNal   = Convert.ToInt32(b.RouteCheck.Code);
                            NSR     = b.Resolution.DocumentNumber;
                            DSR     = Convert.ToString(b.Resolution.DocumentDateSign);
                            SrDSR   = Convert.ToString(b.DateTo);
                            RMarshr = b.Route;
                            RM      = b.FullWeight;
                            KRPr    = b.TripCount;
                            KOstPr  = b.LeftTripCount;
                            LSR     = b.Dimensions.Length;
                            WSR     = b.Dimensions.Width;
                            HSR     = b.Dimensions.Height;
                            //IdPrSTR = DateTime.Now.ToString("yyMMdd")+ IdPr.ToString() ;
                            // IdPr = Convert.ToDecimal(IdPrSTR.ToString());
                            INPR1      = Guid.NewGuid();
                            IdPrSTR    = Convert.ToString(INPR1).Replace("-", "");
                            NZaprFalse = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd") + NZapr.ToString());

                            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
                            cmd.CommandText = "INSERT INTO raptssprrazr "
                                              + "("
                                              + "idts, "
                                              + "dateregsr, "
                                              + "grzrasp, "
                                              + "KemVid, "
                                              + "VidPerevoz, "
                                              + "GRZSR, "
                                              + "NomSR, "
                                              + "DateVidSR, "
                                              + "SrokDeistvSR, "
                                              + "RazrMarshr, "
                                              + "RazrMassa, "
                                              + "KolRazrPr, "
                                              + "IspolzPR, "
                                              + "LengthSR, "
                                              + "WidthSR, "
                                              + "HeightSR, "
                                              + "NarushenMarshrSR, "
                                              + "DateZapr, "
                                              + "NomZapr, "
                                              + "DPR, "
                                              + "OstatPR, "
                                              + "NZFalse ) "
                                              + "VALUES "
                                              + "(" + IdPr + ", "
                                              + "'" + b.DateFrom.ToString("o") + "', "
                                              + "'" + GRZc + "', "
                                              + "'ГБУ Севастопольский Автодор', "
                                              + "'" + b.ShippingType + "', "
                                              + "'" + b.VehicleRegNumber + "', "
                                              + "'" + b.Resolution.DocumentNumber + "', "
                                              + "'" + b.Resolution.DocumentDateSign.ToString("o") + "', "
                                              + "'" + b.DateTo.ToString("o") + "', "
                                              + "'" + b.Route + "', "
                                              + "" + b.FullWeight + ", "
                                              + "" + (b.TripCount - b.LeftTripCount + 1) + ", "//b.TripCount + ", "
                                              + "" + b.LeftTripCount + ", "
                                              + "" + b.Dimensions.Length + ", "
                                              + "" + b.Dimensions.Width + ", "
                                              + "" + b.Dimensions.Height + ", "
                                              + "'" + b.RouteCheck.Code + "', "
                                              + "'" + DTN + "', "
                                              + "'" + IdPrSTR + "', "
                                              + "'" + Convert.ToDateTime(DTc.ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "', "
                                              + "" + b.LeftTripCount + ", "
                                              + "" + Convert.ToInt64(NZaprFalse) + "); ";
                            //Guid.NewGuid()
                            cmd.Connection = sqlConnectionT;
                            if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                            {
                                sqlConnectionT.Open();
                            }
                            //sqlConnectionT.Open();
                            cmd.ExecuteNonQuery();
                            /* sqlConnectionT.Close()*/
                            ;

                            IInt    = new decimal[b.AxlesInvervals.Length + 1];
                            IInt[0] = 0;
                            for (int iint = 0; iint < b.AxlesInvervals.Length; iint++)
                            {
                                IInt[iint + 1] = b.AxlesInvervals[iint];
                            }
                            for (int iax = 0; iax < b.AxlesLoads.Length; iax++)
                            {
                                MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand();
                                cmd2.CommandText = "INSERT INTO rapsprazraxel( "
                                                   + "IDSR, "
                                                   + "NomAx, "
                                                   //+ "NomGr, "
                                                   + "MasAxSR, "
                                                   + "IntervalAxSR, "
                                                   + "SkatAxSR, "
                                                   + "CountRAxSR, "
                                                   + "Created, "
                                                   + "NSR) "
                                                   + "VALUES("
                                                   + "'" + IdPrSTR + "', "
                                                   + "" + iax + ", "
                                                   //+ "DEFAULT, "
                                                   + "" + b.AxlesLoads[iax] + ", "
                                                   + "" + IInt[iax] + ", "
                                                   + "" + b.AxlesWeelsEx[iax] + ", "
                                                   + "" + b.AxlesWheels[iax] + ", "
                                                   + "'" + DTN + "', "
                                                   + "'" + b.Resolution.DocumentNumber + "'); ";
                                cmd2.Connection = sqlConnectionT;
                                if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                                {
                                    sqlConnectionT.Open();
                                }
                                //sqlConnectionT.Open();
                                cmd2.ExecuteNonQuery();
                            }
                            a2 = a;
                        }
                        else
                        {
                            //if (b.wr)
                            a.VehicleRegNumber = b.VehicleRegNumber.ToString();
                            a.DocumentNumber   = b.Resolution.DocumentNumber.ToString();
                            a.DocumentDateSign = b.Resolution.DocumentDateSign.ToString();
                            a.DateFrom         = b.DateFrom.ToString();
                            a.DateTo           = b.DateTo.ToString();
                            a.TripCount        = b.TripCount;
                            a.LeftTripCount    = b.LeftTripCount;
                            a.Route            = b.Route.ToString();
                            a.Dimensions       = b.Dimensions.ToString();
                            a.AxlesLoads       = b.AxlesLoads;
                            a.FullWeight       = b.FullWeight;
                            PrNal   = Convert.ToInt32(b.RouteCheck.Code);
                            NSR     = b.Resolution.DocumentNumber;
                            DSR     = Convert.ToString(b.Resolution.DocumentDateSign);
                            SrDSR   = Convert.ToString(b.DateTo);
                            RMarshr = b.Route;
                            RM      = b.FullWeight;
                            KRPr    = b.TripCount;
                            KOstPr  = b.LeftTripCount;
                            LSR     = b.Dimensions.Length;
                            WSR     = b.Dimensions.Width;
                            HSR     = b.Dimensions.Height;
                            //IdPrSTR = DateTime.Now.ToString("yyMMdd")+ IdPr.ToString() ;
                            // IdPr = Convert.ToDecimal(IdPrSTR.ToString());
                            INPR1      = Guid.NewGuid();
                            IdPrSTR    = Convert.ToString(INPR1).Replace("-", "");
                            NZaprFalse = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd") + NZapr.ToString());

                            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
                            cmd.CommandText = "INSERT INTO raptssprrazr "
                                              + "("
                                              //+ "idts, "
                                              + "dateregsr, "
                                              // + "grzrasp, "
                                              + "KemVid, "
                                              + "VidPerevoz, "
                                              + "GRZSR, "
                                              + "NomSR, "
                                              + "DateVidSR, "
                                              + "SrokDeistvSR, "
                                              + "RazrMarshr, "
                                              + "RazrMassa, "
                                              + "KolRazrPr, "
                                              + "IspolzPR, "
                                              + "LengthSR, "
                                              + "WidthSR, "
                                              + "HeightSR, "
                                              + "NarushenMarshrSR, "
                                              + "DateZapr, "
                                              + "NomZapr, "
                                              + "DPR, "
                                              + "OstatPR, "
                                              + "NZFalse ) "
                                              + "VALUES ("
                                              // + "(" + IdPr + ", "
                                              + "'" + b.DateFrom.ToString("o") + "', "
                                              // + "'" + GRZc + "', "
                                              + "'ГБУ Севастопольский Автодор', "
                                              + "'" + b.ShippingType + "', "
                                              + "'" + b.VehicleRegNumber + "', "
                                              + "'" + b.Resolution.DocumentNumber + "', "
                                              + "'" + b.Resolution.DocumentDateSign.ToString("o") + "', "
                                              + "'" + b.DateTo.ToString("o") + "', "
                                              + "'" + b.Route + "', "
                                              + "" + b.FullWeight + ", "
                                              + "" + (b.TripCount - b.LeftTripCount + 1) + ", "//b.TripCount + ", "
                                              + "" + b.LeftTripCount + ", "
                                              + "" + b.Dimensions.Length + ", "
                                              + "" + b.Dimensions.Width + ", "
                                              + "" + b.Dimensions.Height + ", "
                                              + "'" + b.RouteCheck.Code + "', "
                                              + "'" + DTN + "', "
                                              + "'" + IdPrSTR + "', "
                                              + "'" + Convert.ToDateTime(DTc.ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "', "
                                              + "" + b.LeftTripCount + ", "
                                              + "" + Convert.ToInt64(NZaprFalse) + "); ";
                            //Guid.NewGuid()
                            cmd.Connection = sqlConnectionT;
                            if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                            {
                                sqlConnectionT.Open();
                            }
                            //sqlConnectionT.Open();
                            cmd.ExecuteNonQuery();
                            /* sqlConnectionT.Close()*/

                            //ConnectStr ResRegionSR = new ConnectStr();
                            //ResRegionSR.ConStr(1);
                            //cstrU = ResRegionSR.StP;
                            //MySqlConnection sqlConnectionT = new MySqlConnection(cstrU);

                            IInt    = new decimal[b.AxlesInvervals.Length + 1];
                            IInt[0] = 0;
                            for (int iint = 0; iint < b.AxlesInvervals.Length; iint++)
                            {
                                IInt[iint + 1] = b.AxlesInvervals[iint];
                            }
                            for (int iax = 0; iax < b.AxlesLoads.Length; iax++)
                            {
                                MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand();
                                cmd2.CommandText = "INSERT INTO rapsprazraxel( "
                                                   + "IDSR, "
                                                   + "NomAx, "
                                                   //+ "NomGr, "
                                                   + "MasAxSR, "
                                                   + "IntervalAxSR, "
                                                   + "SkatAxSR, "
                                                   + "CountRAxSR, "
                                                   + "Created, "
                                                   + "NSR) "
                                                   + "VALUES("
                                                   + "'" + IdPrSTR + "', "
                                                   + "" + iax + ", "
                                                   //+ "DEFAULT, "
                                                   + "" + b.AxlesLoads[iax] + ", "
                                                   + "" + IInt[iax] + ", "
                                                   + "" + b.AxlesWeelsEx[iax] + ", "
                                                   + "" + b.AxlesWheels[iax] + ", "
                                                   + "'" + DTN + "', "
                                                   + "'" + b.Resolution.DocumentNumber + "'); ";
                                cmd2.Connection = sqlConnectionT;
                                if (sqlConnectionT.State == System.Data.ConnectionState.Closed)
                                {
                                    sqlConnectionT.Open();
                                }
                                //sqlConnectionT.Open();
                                cmd2.ExecuteNonQuery();
                            }
                        }
                    }
                    sqlConnectionT.Close();

                    MySqlCommand command = new MySqlCommand();
                    ConnectStr   conStr  = new ConnectStr();
                    //Zapros zapros = new Zapros();
                    conStr.ConStr(1);
                    //zapros.ZaprObrSpRazrLoc(IDT, NamU, 1);
                    MySqlConnection connection = new MySqlConnection(conStr.StP);
                    string          z          = "UPDATE vehiclecontainer_r"
                                                 + " SET `Change` = 1,"
                                                 + " ChangeType =  1 ,"
                                                 + " DateChang = '" + DTN + "',"
                                                 + " NameUs = 'AUTO',"
                                                 + " Prim = 'Изменено Спец. Разрешение'"
                                                 + " WHERE ID = " + IdPr + " ;";
                    command.CommandText = z;
                    command.Connection  = connection;
                    try
                    {
                        command.Connection.Open();
                        command.ExecuteNonQuery();
                        command.Connection.Close();
                    }
                    catch (MySqlException ex)
                    { Console.WriteLine("Error: \r\n{0}", ex.ToString()); }
                    finally
                    { command.Connection.Close(); }
                }
            }
            catch (Exception ex)
            {
                MySqlCommand command = new MySqlCommand();
                ConnectStr   conStr  = new ConnectStr();
                //Zapros zapros = new Zapros();
                conStr.ConStr(1);

                //zapros.ZaprObrSpRazrLoc(IDT, NamU, 1);
                MySqlConnection connection = new MySqlConnection(conStr.StP);
                string          z          = "UPDATE vehiclecontainer_r"
                                             + " SET `Change` = 1,"
                                             + " ChangeType =  20 ,"
                                             + " DateChang = '" + DTN + "',"
                                             + " NameUs = 'AUTO',"
                                             + " Prim = 'Проверка не окончена (невозможно подключиться к серверу СВСР)'"
                                             + " WHERE ID = " + IdPr + " ;";
                command.CommandText = z;
                command.Connection  = connection;
                try
                {
                    command.Connection.Open();
                    command.ExecuteNonQuery();
                    command.Connection.Close();
                }
                catch (MySqlException exy)
                { Console.WriteLine("Error: \r\n{0}", exy.ToString()); }
                finally
                { command.Connection.Close(); }
            }
        }