private void BtnAdd_Click(object sender, EventArgs e) { if (TxbCategory.Text != "") { sql = "select * from tbcategory where category='" + TxbCategory.Text; dt = DBClass.Get_DataTable(sql); if (dt.Rows.Count != 0) { MessageBox.Show("This category already existed!"); return; } else { sql = "insert into tbcategory values('" + TxbCategory.Text + "')"; if (DBClass.Run_SQL(sql) > 0) { CleanControls(); BindDgvCate(); MessageBox.Show("record has been inserted!"); } else { MessageBox.Show("failed!"); } } } else { MessageBox.Show("Fill txb first!"); return; } }
private void BtnUpdate_Click(object sender, EventArgs e) { if (TxbCID.Text != "" && TxbCID.Text != null) { sql = "update tbcategory set category='" + TxbCategory.Text + "' where cid=" + TxbCID.Text; if (DBClass.Run_SQL(sql) > 0) { CleanControls(); BindDgvCate(); MessageBox.Show("record has been updated!"); } else { MessageBox.Show("failed!"); } } else { MessageBox.Show("select record first!"); return; } }
private void BtnFUpdate_Click(object sender, EventArgs e) { if (TxbFID.Text != "" && TxbFID.Text != null) { sql = "update tbfile set filename='" + TxbFName.Text + "',filepath='" + TxbFPath.Text + "' where fid=" + TxbFID.Text; if (DBClass.Run_SQL(sql) > 0) { CleanControls(); BindDgvFile(); MessageBox.Show("record has been updated!"); } else { MessageBox.Show("failed!"); } } else { MessageBox.Show("select record first!"); return; } }
private void BtnDelete_Click(object sender, EventArgs e) { if (TxbCID.Text != "" && TxbCID.Text != null) { if (MessageBox.Show("delete double check", "info", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { sql = "delete from tbcategory where cid=" + TxbCID.Text; if (DBClass.Run_SQL(sql) > 0) { CleanControls(); BindDgvCate(); MessageBox.Show("record has been deleted!"); } else { MessageBox.Show("failed!"); } } } else { MessageBox.Show("select record first!"); } }