private void button2_Click_1(object sender, EventArgs e) { PleaseWait objPleaseWait = new PleaseWait(); try { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount == 0) return; string tenbang = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells["TABLE_NAME"].Value.ToString(); if (MessageBox.Show(string.Format("Bạn có chắc là muốn khôi phục '{0}' dữ liệu này không", tenbang), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } objPleaseWait.Show(); Application.DoEvents(); if (SQLDatabase.ExcNonQuery(string.Format("drop table [{0}]", tenbang))) { dataGridView1.DataSource = SQLDatabase.ExcDataTable("[spLoadData]"); } objPleaseWait.Close(); } catch (Exception ex) { objPleaseWait.Close(); throw; } }
private void backup() { PleaseWait objPleaseWait = new PleaseWait(); objPleaseWait.Show(); Application.DoEvents(); if (SQLDatabase.ExcNonQuery("[spBackup]")) { dataGridView1.DataSource = SQLDatabase.ExcDataTable("[spLoadData]"); } objPleaseWait.Close(); }
/// <summary> /// Function get data for Gridview paging /// </summary> /// <param name="rowIndex"></param> public void UpdateCachedData(long rowIndex) { DataTable table1; DataTable table2; long lastIndex, minIndex, maxIndex; string sqlCommand; try { if (commandToGetCount == "") { return; } lastIndex = rowIndex - (rowIndex % pageSize); if (lastIndex == lastRowIndex) { return; } if (lastRowIndex == -1) { table1 = SQLDatabase.ExcDataTable(commandToGetCount); if (table1 != null && table1.Rows.Count > 0) { totalRowCount = long.Parse(table1.Rows[0][0].ToString()); } else { totalRowCount = 0; } } lastRowIndex = lastIndex; minIndex = lastRowIndex + 1; maxIndex = lastRowIndex + pageSize; sqlCommand = commandToGetData; sqlCommand += " RowNumber Between " + minIndex.ToString() + " and "; sqlCommand += maxIndex.ToString(); sqlCommand += " order by didong ASC"; cachedTable = SQLDatabase.ExcDataTable(sqlCommand); } catch (Exception ex) { MessageBox.Show(ex.Message, "GetCachedData"); } }
private void GetValueTextbox() { try { if (dataGridView1.CurrentRow != null && dataGridView1.CurrentRow.IsNewRow == false) { string NameOld = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); frmChange4 frm = new frmChange4(); frm.Name = NameOld; if (frm.ShowDialog() == DialogResult.OK) { dataGridView1.DataSource = SQLDatabase.ExcDataTable("[spLoadData]"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "GetValueTextbox", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmBackup_Load(object sender, EventArgs e) { dataGridView1.DataSource = SQLDatabase.ExcDataTable("[spLoadData]"); }
private void button5_Click(object sender, EventArgs e) { dataGridView1.DataSource = SQLDatabase.ExcDataTable("[spLoadData]"); }