private void button2_Click(object sender, EventArgs e) { if (Rrc != 0) { int currentRow = dataGridView1.CurrentRow.Index; // номер строки, по которой кликнули VDocNum = dataGridView1[1, currentRow].Value.ToString(); //ID DDS = Convert.ToDateTime(dataGridView1[2, currentRow].Value.ToString()); ConnectStr ResRegionSR = new ConnectStr(); ResRegionSR.ConStr(1); cstrU = ResRegionSR.StP; MySqlConnection sqlConnectionT = new MySqlConnection(cstrU); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "UPDATE raptssprrazr SET PriznNal = 1 WHERE NomSR = '" + VDocNum + "' ;"; cmd.Connection = sqlConnectionT; sqlConnectionT.Open(); cmd.ExecuteNonQuery(); sqlConnectionT.Close(); var binding = new BasicHttpBinding(); var endpoint = new EndpointAddress(new Uri(string.Format("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.WriteOfTripDataRequest writeOfRequest = new ServiceReference1.WriteOfTripDataRequest() { AxlesCount = ACc, //new int[] { 1, 2, 3 }, AxlesInvervals = AIc, //new decimal[] { 1m, 2m, 3m }, AxlesLoads = ALc, //new decimal[] { 1m, 2m, 3m }, TripDate = 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, DocumentDateSign = DDS, DocumentNumber = VDocNum, TotalSize = new ServiceReference1.CheckRequestDataTotalSize() { Height = Hc, //10m, Length = Lc, //10m, Width = Wc, //10m } }; using (MemoryStream memoryStreamInput = new MemoryStream()) { XmlSerializer formatter_input = new XmlSerializer(typeof(ServiceReference1.WriteOfTripDataRequest)); formatter_input.Serialize(memoryStreamInput, writeOfRequest); textBox1.Text = StreamToString(memoryStreamInput); } try { var rezRequest = serviceClient.WriteOfTrip(writeOfRequest); using (MemoryStream memoryStreamOutput = new MemoryStream()) { XmlSerializer formatter_output = new XmlSerializer(typeof(ServiceReference1.WriteOffAnswerData)); formatter_output.Serialize(memoryStreamOutput, rezRequest); textBox1.Text += StreamToString(memoryStreamOutput); } } catch (Exception ex) { } } else { this.Close(); } }
public void button2_Click(string NZ, Int64 IDpish, string data16, string data17, string PLN, string NZCHASTY) { if (NZ != "") { ConnectStr ResRegionSR = new ConnectStr(); ResRegionSR.ConStr(1); cstrU = ResRegionSR.StP; MySqlConnection sqlConnectionT = new MySqlConnection(cstrU); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "DELETE FROM raptssprrazr WHERE NomZapr = '" + NZ + "' ;"; cmd.Connection = sqlConnectionT; sqlConnectionT.Open(); cmd.ExecuteNonQuery(); sqlConnectionT.Close(); } if (Rrc == 1) { //int currentRow = dataGridView1.CurrentRow.Index; // номер строки, по которой кликнули VDocNum = a.DocumentNumber; //dataGridView1[1, currentRow].Value.ToString(); //ID DDS = Convert.ToDateTime(a.DocumentDateSign); //Convert.ToDateTime(dataGridView1[2, currentRow].Value.ToString()); ConnectStr ResRegionSR = new ConnectStr(); ResRegionSR.ConStr(1); cstrU = ResRegionSR.StP; MySqlConnection sqlConnectionT = new MySqlConnection(cstrU); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "UPDATE raptssprrazr SET PriznNal = 1 WHERE NomSR = '" + VDocNum + "' ;"; cmd.Connection = sqlConnectionT; sqlConnectionT.Open(); cmd.ExecuteNonQuery(); sqlConnectionT.Close(); 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"))); // ;Environment.MachineName))); // "192.168.20.30"))); var serviceClient = new ServiceReference1.RASVSRClient(binding, endpoint); ServiceReference1.WriteOfTripDataRequest writeOfRequest = new ServiceReference1.WriteOfTripDataRequest() { IdTrip = Convert.ToString(IdPr), RequestID = Convert.ToString(IdPrSTR), //DelNum=NZ, AxlesCount = ACc, //new int[] { 1, 2, 3 }, AxlesInvervals = AIc, //new decimal[] { 1m, 2m, 3m }, AxlesLoads = ALc, //new decimal[] { 1m, 2m, 3m }, TripDate = Convert.ToDateTime(DTc.ToString()), //DateTime.Now, CheckPointCode = CPCc.ToString(), //"001", //////////////////////////////////+"'" + DTN + "', " ////////////////////////////////// + "'" + IdPrSTR + "', " Direction = Dc, //1, //Latitude = Convert.ToDecimal("123,5"), //Longitude = Convert.ToDecimal("127,5"), TotalWeight = TWc, //10m, DocumentDateSign = DDS, DocumentNumber = VDocNum, TotalSize = new ServiceReference1.CheckRequestDataTotalSize() { Height = Hc, //10m, Length = Lc, //10m, Width = Wc, //10m } }; using (MemoryStream memoryStreamInput = new MemoryStream()) { XmlSerializer formatter_input = new XmlSerializer(typeof(ServiceReference1.WriteOfTripDataRequest)); formatter_input.Serialize(memoryStreamInput, writeOfRequest); //textBox1.Text = StreamToString(memoryStreamInput); } try { var rezRequest = serviceClient.WriteOfTrip(writeOfRequest); using (MemoryStream memoryStreamOutput = new MemoryStream()) { XmlSerializer formatter_output = new XmlSerializer(typeof(ServiceReference1.WriteOffAnswerData)); formatter_output.Serialize(memoryStreamOutput, rezRequest); // textBox1.Text += StreamToString(memoryStreamOutput); } } catch (Exception ex) { } } else if (Rrc > 1) { //int currentRow = dataGridView1.CurrentRow.Index; // номер строки, по которой кликнули VDocNum = a2.DocumentNumber; //dataGridView1[1, currentRow].Value.ToString(); //ID DDS = Convert.ToDateTime(a2.DocumentDateSign); //Convert.ToDateTime(dataGridView1[2, currentRow].Value.ToString()); ConnectStr ResRegionSR = new ConnectStr(); ResRegionSR.ConStr(1); cstrU = ResRegionSR.StP; MySqlConnection sqlConnectionT = new MySqlConnection(cstrU); MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.CommandText = "UPDATE raptssprrazr SET PriznNal = 1 WHERE NomSR = '" + VDocNum + "' ;"; cmd.Connection = sqlConnectionT; sqlConnectionT.Open(); cmd.ExecuteNonQuery(); sqlConnectionT.Close(); 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"))); // ;Environment.MachineName))); // "192.168.20.30"))); var serviceClient = new ServiceReference1.RASVSRClient(binding, endpoint); ServiceReference1.WriteOfTripDataRequest writeOfRequest = new ServiceReference1.WriteOfTripDataRequest() { IdTrip = Convert.ToString(IdPr), RequestID = Convert.ToString(IdPrSTR), AxlesCount = ACc, //new int[] { 1, 2, 3 }, AxlesInvervals = AIc, //new decimal[] { 1m, 2m, 3m }, AxlesLoads = ALc, //new decimal[] { 1m, 2m, 3m }, TripDate = 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, DocumentDateSign = DDS, DocumentNumber = VDocNum, TotalSize = new ServiceReference1.CheckRequestDataTotalSize() { Height = Hc, //10m, Length = Lc, //10m, Width = Wc, //10m } }; using (MemoryStream memoryStreamInput = new MemoryStream()) { XmlSerializer formatter_input = new XmlSerializer(typeof(ServiceReference1.WriteOfTripDataRequest)); formatter_input.Serialize(memoryStreamInput, writeOfRequest); //textBox1.Text = StreamToString(memoryStreamInput); } try { var rezRequest = serviceClient.WriteOfTrip(writeOfRequest); using (MemoryStream memoryStreamOutput = new MemoryStream()) { XmlSerializer formatter_output = new XmlSerializer(typeof(ServiceReference1.WriteOffAnswerData)); formatter_output.Serialize(memoryStreamOutput, rezRequest); // textBox1.Text += StreamToString(memoryStreamOutput); } MySqlCommand command3 = new MySqlCommand(); ConnectStr conStr3 = new ConnectStr(); conStr3.ConStr(1); string connectionString3; connectionString3 = conStr3.StP;//"Data source=localhost;UserId=root;Password=1q2w3e$R;database=camloc;"; MySqlConnection connection3 = new MySqlConnection(connectionString3); string z3 = "INSERT INTO rap_ststus_pr(Id_pr, Date_pr, ID_Status, Name_Status, Date_Chang, NUs, PlatformID)" + "VALUES(" + IDpish + ", '" + (Convert.ToDateTime(data16 + " " + data17).ToString("yyyyMMddHHmmss")) + "', 1, 'направлен запрос СР', '" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss.ffffff") + "', 'AUTO', " + PLN + ")"; //MySqlCommand command = new MySqlCommand(z); command3.CommandText = z3;// commandString; command3.Connection = connection3; connection3.Open(); command3.ExecuteNonQuery(); command3.Connection.Close(); MySqlCommand command2 = new MySqlCommand(); ConnectStr conStr2 = new ConnectStr(); conStr2.ConStr(1); string connectionString2; connectionString2 = conStr2.StP;//"Data source=localhost;UserId=root;Password=1q2w3e$R;database=camloc;"; MySqlConnection connection2 = new MySqlConnection(connectionString3); string z2 = "INSERT INTO rap_ststus_pr(Id_pr, Date_pr, ID_Status, Name_Status, Date_Chang, NUs, PlatformID)" + "VALUES(" + IDpish + ", '" + (Convert.ToDateTime(data16 + " " + data17).ToString("yyyyMMddHHmmss")) + "', 2, 'получен ответ СР', '" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss.ffffff") + "', 'AUTO', " + PLN + ")"; //MySqlCommand command = new MySqlCommand(z); command2.CommandText = z2;// commandString; command2.Connection = connection2; connection2.Open(); command2.ExecuteNonQuery(); command2.Connection.Close(); //if (StatAng > 0 && (data1.a[241] != data1.a[244])) //{ a.button2_Click(Nzapr); } //else { a.button2_Click(""); } } catch (Exception ex) { } } else if (Rrc != 0) { } }