1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| dgv_rit.Sort(dgv_rit.Columns["order1"], ListSortDirection.Ascending);
dgv_rit.Columns["order1"].SortMode = DataGridViewColumnSortMode.NotSortable;
int newOrder=1;
for (int i = 0; i < dgv_rit.Rows.Count; i++)
{
if (dgv_rit.Rows[i].Cells["X"].Value == null) break;
DataRowView drv = (DataRowView)dgv_rit.Rows[i].DataBoundItem;
DataRow dr = drv.Row;
if ((int)dr["order1"] != newOrder)
{
dr["order1"] = newOrder;
}
newOrder++;
}
MySqlCommand cmd;
string xCmd;
DataTable dtr = dsRit.Tables[0];
for (int i = 0; i < dtr.Rows.Count; i++)
{
DataRow dr=dtr.Rows[i];
xCmd = "UPDATE tours SET order1=" + dr["order1"].ToString() + " WHERE id=" + dr["id"].ToString();
cmd=new MySqlCommand(xCmd, MyConn.conn);
int nUpd = cmd.ExecuteNonQuery();
}
/*
adaRit.UpdateCommand = new MySqlCommand("UPDATE tours SET order1=?order1 WHERE id=?id", MyConn.conn);
adaRit.UpdateCommand.Parameters.Add("?order1", MySqlDbType.Int32, 11, "order1").SourceVersion = DataRowVersion.Original;
adaRit.UpdateCommand.Parameters.Add("?id", MySqlDbType.Int32, 11, "id").SourceVersion = DataRowVersion.Original;
Step = adaRit.Update(dsRit);
*/ |
Partager