private void thêmMớiToolStripMenuItem_Click(object sender, EventArgs e) { SQLDatabase.AddDM_QuocGia(new DM_QuocGia() { ma = "", name = "", isAct = true, OrderId = ConvertType.ToInt(SQLDatabase.ExcDataTable("select max(OrderId) from DM_QuocGia").Rows[0][0]) + 1 }); BindNhom(txtSeachQuocGia.Text); }
private void lấyDữLiệuTừDataLoadToolStripMenuItem_Click(object sender, EventArgs e) { try { DataTable model = SQLDatabase.ExcDataTable(";WITH cte AS(select locale from FbFollow group by locale union select locale from FbFriend group by locale ) SELECT* FROM cte WHERE locale not in(select ma from DM_QuocGia) order by locale"); foreach (DataRow item in model.Rows) { SQLDatabase.AddDM_QuocGia(new DM_QuocGia() { isAct = true, ma = item[0].ToString(), OrderId = ConvertType.ToInt(SQLDatabase.ExcDataTable("select max(OrderId) from DM_QuocGia").Rows[0][0]) + 1 }); } BindNhom(txtSeachQuocGia.Text); MessageBox.Show("Hoàn thành lấy dữ liệu từ database", "Thông Báo"); } catch (Exception ex) { MessageBox.Show(ex.Message, "lấyDữLiệuTừDataLoadToolStripMenuItem_Click"); } }