private void LoadData() { DataTable table = new DataTable(); string query = "select f_category as category, f_staff as staff, f_name as name, f_path as spath, f_description as description, f_lastaccess as lastaccess from TB_APPLICATION order by f_staff"; SqlDataAdapter sda = new SqlDataAdapter(query, DataServiceMyCloud.GetInstance().Connection); sda.Fill(table); dgvApplication.DataSource = table; }
private void tsbtnDelete_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvApplication.SelectedRows) { string staff = row.Cells[1].Value.ToString().Trim(); string path = row.Cells[3].Value.ToString().Trim(); string query = string.Format("delete from TB_APPLICATION where f_staff = N'{0}' and f_path = N'{1}'", staff, path); DataServiceMyCloud.GetInstance().ExecuteNonQuery(query); } this.LoadData(); }
private void btnSave_Click(object sender, EventArgs e) { string category = rbtnApplication.Checked? "Application" :rbtnTools.Checked?"Tools" :rbtnForms.Checked?"Forms":"Others"; string directory = txtDirectory.Text.Trim(); string name = txtName.Text.Trim(); string description = txtDesc.Text.Trim(); string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); foreach (string item in lbStaff.Items) { string staff = item.Trim(); string query = string.Format("insert into TB_APPLICATION (f_category, f_staff, f_name, f_path, f_description, f_lastaccess) values" + " ('{0}', N'{1}', N'{2}', N'{3}', N'{4}', '{5}')", category, staff, name, directory, description, now); DataServiceMyCloud.GetInstance().ExecuteNonQuery(query); } }