public bool Insert(childTrfHistBLL u) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstrng); try { String sql = @"INSERT INTO tbl_child_trf_hist (child_trf_hist_id, child_trf_hist_code, child_trf_hist_from, child_trf_hist_to, child_trf_hist_qty, child_trf_hist_unit, child_trf_hist_result) VALUES (@child_trf_hist_id, @child_trf_hist_code, @child_trf_hist_from, @child_trf_hist_to, @child_trf_hist_qty, @child_trf_hist_unit, @child_trf_hist_result)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@child_trf_hist_id", u.child_trf_hist_id); cmd.Parameters.AddWithValue("@child_trf_hist_code", u.child_trf_hist_code); cmd.Parameters.AddWithValue("@child_trf_hist_from", u.child_trf_hist_from); cmd.Parameters.AddWithValue("@child_trf_hist_to", u.child_trf_hist_to); cmd.Parameters.AddWithValue("@child_trf_hist_qty", u.child_trf_hist_qty); cmd.Parameters.AddWithValue("@child_trf_hist_unit", u.child_trf_hist_unit); cmd.Parameters.AddWithValue("@child_trf_hist_result", u.child_trf_hist_result); conn.Open(); int rows = cmd.ExecuteNonQuery(); //if the query is executed successfully then the rows' value = 0 if (rows > 0) { //query successful isSuccess = true; } else { //Query falled isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }
public bool Delete(childTrfHistBLL u) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstrng); try { String sql = "DELETE FROM tbl_child_trf_hist WHERE child_trf_hist_id=@child_trf_hist_id AND child_trf_hist_code=@child_trf_hist_code"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@child_trf_hist_id", u.child_trf_hist_id); cmd.Parameters.AddWithValue("@child_trf_hist_code", u.child_trf_hist_code); conn.Open(); int rows = cmd.ExecuteNonQuery(); //if the query is executed successfully then the rows' value = 0 if (rows > 0) { //query successful isSuccess = true; } else { //Query falled isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }