private void SO_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelOrder s1 = selectOrder.SelectedItem as SelOrder; // MessageBox.Show(s1.物流单号); System.Diagnostics.Process.Start(@"https://www.kuaidi100.com/chaxun?com=" + s1.物流公司 + @"&nu=" + s1.物流单号); }
private void SO_SelectionChanged(object sender, SelectionChangedEventArgs e) { temp = selectOrder.SelectedItem as SelOrder; update_mail_id = temp.订单编号; update_courier_company = temp.物流公司; update_org_name = temp.发件人; update_org_address = temp.发货地址; update_send_name = temp.收件人; update_send_address = temp.收件地址; update_send_contact = temp.收件人电话; update_stats = temp.状态; update_remarks = temp.备注; }
//失去焦点之后调用这个函数进行更新 private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { string newValue = (e.EditingElement as TextBox).Text; // MessageBox.Show(e.Column.Header.ToString()); temp = e.Row.Item as SelOrder; string newItem = e.Column.Header.ToString(); temp.toValue(e.Column.Header.ToString(), newValue); update_mail_id = temp.物流单号; update_courier_company = temp.物流公司; update_org_name = temp.发件人; update_org_address = temp.发货地址; update_send_name = temp.收件人; update_send_address = temp.收件地址; update_send_contact = temp.收件人电话; update_stats = temp.状态; update_remarks = temp.备注; // MessageBox.Show(temp.物流单号); if (e.Column.Header.ToString() == "物流单号") { Login.m1.ShowMessageAsync("请勿更改物流单号", "如需更改,可删除后添加"); // e.Column = preValue; return; } //如果修改后的值和修改前的值不一样 if (preValue != newValue) { try { connect.MySqlConnection.Open(); connect.ConnectIndex = true; String str_sql = "update fact_mail_status set courier_company = '" + update_courier_company + "', org_name = '" + update_org_name + "' , org_address = '" + update_org_address + "' , send_name = '" + update_send_name + "' , send_address = '" + update_send_address + "', send_contact = '" + update_send_contact + "', stats = '" + update_stats + "' , remarks = '" + update_remarks + "' where mail_id = '" + update_mail_id + "'"; // MessageBox.Show(update_org_name); // MessageBox.Show(str_sql); Console.WriteLine(str_sql); MySqlCommand mysql_cmd = new MySqlCommand(str_sql, connect.MySqlConnection); int result = mysql_cmd.ExecuteNonQuery(); if (result > 0) { // MessageBox.Show("更新成功"); } else { Login.m1.ShowMessageAsync("更新失败", "请查看数据库连接"); } } catch (MySqlException ex) { Console.WriteLine(ex.Message); } }