//ADD USER public void addUser(string un, string pass) { string insertQuery = @"INSERT INTO tbl_user VALUES ('" + un + "','" + pass + "')"; SqlCommand cmd = new SqlCommand(insertQuery, ConnectionDB.connection()); cmd.ExecuteNonQuery(); }
private void txtChildEdu_TextChanged(object sender, EventArgs e) { try { if (LoadBtnCheck == true) { if (txtChildEdu.Text != "") { string query = string.Empty; foreach (string s in checkedListBox1.CheckedItems) { query += s + ","; } query = query.Remove(query.Length - 1, 1); string sql = string.Format("SELECT {0} FROM tbl_cbrdata", query); if (ConnectionDB.connection().State == ConnectionState.Closed) { ConnectionDB.connection().Open(); } SqlCommand cmd = new SqlCommand(sql, ConnectionDB.connection()) { CommandType = CommandType.Text }; SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); dgvDataList.DataSource = dt; DataView dv = new DataView(dt); dv.RowFilter = "child_in_edu LIKE '%" + txtChildEdu.Text + "%'"; dgvDataList.DataSource = dv; ConnectionDB.connection().Close();//Close DB Connection } else { checkedDataLoad(); } } else { SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM tbl_cbrdata", ConnectionDB.connection()); DT = new DataTable(); da.Fill(DT); BindingSource bnsue = new BindingSource(); bnsue.DataSource = DT; dgvDataList.DataSource = bnsue; da.Update(DT); DataView dv = new DataView(DT); dv.RowFilter = "child_in_edu LIKE '%" + txtChildEdu.Text + "%'"; dgvDataList.DataSource = dv; ConnectionDB.connection().Close();//Close DB Connection } } catch (Exception ex) { MessageBox.Show("Thlis column is not selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtChildEdu.Clear(); } }
public void checkedDataLoad() { try { string query = string.Empty; foreach (string s in checkedListBox1.CheckedItems) { query += s + ","; } query = query.Remove(query.Length - 1, 1); string sql = string.Format("SELECT {0} FROM tbl_cbrdata", query); if (ConnectionDB.connection().State == ConnectionState.Closed) { ConnectionDB.connection().Open(); } SqlCommand cmd = new SqlCommand(sql, ConnectionDB.connection()) { CommandType = CommandType.Text }; SqlDataAdapter sda = new SqlDataAdapter(cmd); using (DataTable dt = new DataTable("tbl_cbrdata")) { sda.Fill(dt); dgvDataList.DataSource = dt; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRefresh_Click(object sender, EventArgs e) { try { LoadBtnCheck = false; SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM tbl_cbrdata", ConnectionDB.connection()); DataTable dt2 = new DataTable(); da.Fill(dt2); BindingSource bnsue = new BindingSource(); bnsue.DataSource = dt2; dgvDataList.DataSource = bnsue; da.Update(dt2); ConnectionDB.connection().Close(); txtChildEdu.Clear(); txtDisabilities.Clear(); //DateTime_Birthday.Value = DateTime.Now; cbx_House.Text = null; txtRehabilitation.Clear(); txtSanitation.Clear(); txtDonation_Gov.Clear(); txtDonation_NGO.Clear(); foreach (int i in checkedListBox1.CheckedIndices) { checkedListBox1.SetItemCheckState(i, CheckState.Unchecked); } } catch (Exception ex) { MessageBox.Show(ex.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//LOGIN USERNAME AND PASSWORD public SqlDataReader loginUser(string uName, string pass) { string selectQuery = "SELECT * FROM tbl_user WHERE userName='******' AND password='******'"; SqlCommand cmd = new SqlCommand(selectQuery, ConnectionDB.connection()); SqlDataReader dr = cmd.ExecuteReader(); return(dr); }
/*-------------------------------------------------------- * LOGIN USER QUERY SECTION * --------------------------------------------------------*/ //SELECT USER public SqlDataReader selectUser(string uName) { string selectQuery = "SELECT userName FROM tbl_user WHERE userName='******'"; SqlCommand cmd = new SqlCommand(selectQuery, ConnectionDB.connection()); SqlDataReader dr = cmd.ExecuteReader(); return(dr); }
public string getChildNo() { string MaxChildNo = "SELECT MAX(child_no) FROM tbl_cbrdata"; SqlCommand com = new SqlCommand(MaxChildNo, ConnectionDB.connection()); SqlDataReader dr = com.ExecuteReader(); while (dr.Read() == true) { child_no = dr[0].ToString(); } return(child_no); }
private void frmMain_Load(object sender, EventArgs e) { LoadBtnCheck = false; SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM tbl_cbrdata", ConnectionDB.connection()); DataTable dt2 = new DataTable(); da.Fill(dt2); BindingSource bnsue = new BindingSource(); bnsue.DataSource = dt2; dgvDataList.DataSource = bnsue; da.Update(dt2); ConnectionDB.connection().Close(); }
//ADD NEW CHILD public void NewChildRegister ( int _chilNo, string _childName, int _age, string _gender, string _address, string _gnDivision, string _motherName, string _motherEdu, string _fatherName, string _fatherEdu, decimal _income, string _childInEdu, int _contactNo, string _disabilities, DateTime _birthday, string _rehabilitationAct, string _house, string _sanitationFacilities, string _donationGOV, string _donation_NGO ) { SqlCommand cmd = new SqlCommand(@"INSERT INTO tbl_cbrdata VALUES('" + _chilNo + "','" + _childName + "','" + _age + "','" + _gender + "','" + _address + "','" + _gnDivision + "','" + _motherName + "','" + _motherEdu + "','" + _fatherName + "','" + _fatherEdu + "','" + _income + "','" + _childInEdu + "','" + _contactNo + "','" + _disabilities + "','" + _birthday + "','" + _rehabilitationAct + "','" + _house + "','" + _sanitationFacilities + "','" + _donationGOV + "','" + _donation_NGO + "')", ConnectionDB.connection()); cmd.ExecuteNonQuery(); }
//CHANGE LOGIN PASSWORD public void ChangePassword(string user, string pass) { SqlCommand cmd = new SqlCommand("UPDATE tbl_user SET password='******' WHERE userName='******'", ConnectionDB.connection()); cmd.ExecuteNonQuery(); }
public void UpdateChild ( int _childNo, string _childName, int _age, string _gender, string _address, string _gnDivision, string _motherName, string _motherEdu, string _fatherName, string _fatherEdu, decimal _income, string _childInEdu, int _contactNo, string _disabilities, DateTime _birthday, string _rehabilitationAct, string _house, string _sanitationFacilities, string _donationGOV, string _donation_NGO ) { SqlCommand cmd = new SqlCommand("UPDATE tbl_cbrdata SET child_name='" + _childName + "', age='" + _age + "', gender='" + _gender + "', address='" + _address + "', gn_division='" + _gnDivision + "', mother_name='" + _motherName + "', mother_edu='" + _motherEdu + "', father_name='" + _fatherName + "', father_edu='" + _fatherEdu + "', income='" + _income + "', child_in_edu='" + _childInEdu + "', contact_no='" + _contactNo + "', disabilities='" + _disabilities + "' , birthday='" + _birthday + "' , rehabilitation_act='" + _rehabilitationAct + "' , house='" + _house + "' , sanitation_facilities='" + _sanitationFacilities + "' , donation_gov='" + _donationGOV + "' , donation_ngo='" + _donation_NGO + "' WHERE child_no='" + _childNo + "'", ConnectionDB.connection()); cmd.ExecuteNonQuery(); }