Exemplo n.º 1
0
        public int AddOrganization(OrganizationItem item)
        {
            string queryString = "insert into " + tableOrganization + " values(null, @organization, "
                                 + "@division, @iso2, @city, @contact_name, @contact_phone, @contact_email, @jobs_url, @url, "
                                 + "@note)";

            using (SQLiteConnection connection = new SQLiteConnection(strConnection))
                using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection))
                {
                    // Set command parameters.
                    dbCommand.Parameters.AddWithValue("@organization", item.Organization);
                    dbCommand.Parameters.AddWithValue("@division", item.Division);
                    dbCommand.Parameters.AddWithValue("@iso2", item.Iso2Code);
                    dbCommand.Parameters.AddWithValue("@city", item.City);
                    dbCommand.Parameters.AddWithValue("@contact_name", item.ContactName);
                    dbCommand.Parameters.AddWithValue("@contact_phone", item.ContactPhone);
                    dbCommand.Parameters.AddWithValue("@contact_email", item.ContactEmail);
                    dbCommand.Parameters.AddWithValue("@url", item.Url);
                    dbCommand.Parameters.AddWithValue("@jobs_url", item.JobsUrl);
                    dbCommand.Parameters.AddWithValue("@note", item.Note);

                    // Add new organization to table.
                    connection.Open();
                    int result = dbCommand.ExecuteNonQuery();

                    // Notify changes.
                    if (this.OrganizationModified != null)
                    {
                        this.OrganizationModified(this, null);
                    }

                    // Return the result.
                    return(result);
                }
        }
Exemplo n.º 2
0
        public int UpdateOrganization(OrganizationItem item)
        {
            string queryString = "update " + tableOrganization + " set "
                                 + "organization=@organization, "
                                 + "division=@division, "
                                 + "iso2=@iso2, "
                                 + "city=@city, "
                                 + "contact_name=@contact_name, "
                                 + "contact_phone=@contact_phone, "
                                 + "contact_email=@contact_email, "
                                 + "organization_url=@url, "
                                 + "jobs_url=@jobs_url, "
                                 + "note=@note where id=@id";

            using (SQLiteConnection connection = new SQLiteConnection(strConnection))
                using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection))
                {
                    // Set command parameters.
                    dbCommand.Parameters.AddWithValue("@id", item.Id);
                    dbCommand.Parameters.AddWithValue("@organization", item.Organization);
                    dbCommand.Parameters.AddWithValue("@division", item.Division);
                    dbCommand.Parameters.AddWithValue("@iso2", item.Iso2Code);
                    dbCommand.Parameters.AddWithValue("@city", item.City);
                    dbCommand.Parameters.AddWithValue("@contact_name", item.ContactName);
                    dbCommand.Parameters.AddWithValue("@contact_phone", item.ContactPhone);
                    dbCommand.Parameters.AddWithValue("@contact_email", item.ContactEmail);
                    dbCommand.Parameters.AddWithValue("@url", item.Url);
                    dbCommand.Parameters.AddWithValue("@jobs_url", item.JobsUrl);
                    dbCommand.Parameters.AddWithValue("@note", item.Note);

                    // Update organization in table.
                    connection.Open();
                    int result = dbCommand.ExecuteNonQuery();

                    // Notify changes.
                    if (this.OrganizationModified != null)
                    {
                        this.OrganizationModified(this, null);
                    }

                    // Return the result.
                    return(result);
                }
        }
Exemplo n.º 3
0
        public int DeleteOrganization(OrganizationItem item)
        {
            string queryString = "delete from " + tableOrganization + " where id=@id";

            using (SQLiteConnection connection = new SQLiteConnection(strConnection))
                using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection))
                {
                    // Set command parameters.
                    dbCommand.Parameters.AddWithValue("@id", item.Id);

                    // Delete organization from table.
                    connection.Open();
                    int result = dbCommand.ExecuteNonQuery();

                    // Notify changes.
                    if (this.OrganizationModified != null)
                    {
                        this.OrganizationModified(this, null);
                    }

                    // Return the result.
                    return(result);
                }
        }