Пример #1
0
        public int UpdateApplication(ApplicationItem item)
        {
            string queryString = "update " + tableApplication + " set "
                                 + "title=@title, "
                                 + "job_id=@job_id, "
                                 + "job_url=@job_url, "
                                 + "job_type=@job_type, "
                                 + "status=@status, "
                                 + "priority=@priority, "
                                 + "next_action=@next_action, "
                                 + "next_action_date=@next_action_date, "
                                 + "organization_id=@organization_id, "
                                 + "iso2=@iso2, "
                                 + "city=@city, "
                                 + "contact_name=@contact_name, "
                                 + "contact_phone=@contact_phone, "
                                 + "contact_email=@contact_email, "
                                 + "description=@description, "
                                 + "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("@title", item.Title);
                    dbCommand.Parameters.AddWithValue("@job_id", item.JobId);
                    dbCommand.Parameters.AddWithValue("@job_url", item.JobUrl);
                    dbCommand.Parameters.AddWithValue("@job_type", item.JobType);
                    dbCommand.Parameters.AddWithValue("@status", item.Status);
                    dbCommand.Parameters.AddWithValue("@priority", item.Priority);
                    dbCommand.Parameters.AddWithValue("@next_action", item.NextAction);
                    dbCommand.Parameters.AddWithValue("@next_action_date", item.NextActionDate);
                    dbCommand.Parameters.AddWithValue("@organization_id", item.OrganizationId);
                    dbCommand.Parameters.AddWithValue("@iso2", item.Iso2);
                    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("@description", item.Description);
                    dbCommand.Parameters.AddWithValue("@note", item.Note);

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

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

                    // Return the result.
                    return(result);
                }
        }
Пример #2
0
        public int AddApplication(ApplicationItem item)
        {
            string queryString = "insert into " + tableApplication + " values(null, @title, @job_id, @job_url, @job_type, @status, @priority, @next_action, @next_action_date, @organization, "
                                 + "@iso2, @city, @contact_name, @contact_phone, @contact_email, @description, @note)";

            using (SQLiteConnection connection = new SQLiteConnection(strConnection))
                using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection))
                {
                    // Set command parameters.
                    dbCommand.Parameters.AddWithValue("@title", item.Title);
                    dbCommand.Parameters.AddWithValue("@job_id", item.JobId);
                    dbCommand.Parameters.AddWithValue("@job_url", item.JobUrl);
                    dbCommand.Parameters.AddWithValue("@job_type", item.JobType);
                    dbCommand.Parameters.AddWithValue("@status", item.Status);
                    dbCommand.Parameters.AddWithValue("@priority", item.Priority);
                    dbCommand.Parameters.AddWithValue("@next_action", item.NextAction);
                    dbCommand.Parameters.AddWithValue("@next_action_date", item.NextActionDate);
                    dbCommand.Parameters.AddWithValue("@organization", item.OrganizationId);
                    dbCommand.Parameters.AddWithValue("@iso2", item.Iso2);
                    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("@description", item.Description);
                    dbCommand.Parameters.AddWithValue("@note", item.Note);

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

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

                    // Return the result.
                    return(result);
                }
        }
Пример #3
0
        public int DeleteApplication(ApplicationItem item)
        {
            string queryString = "delete from " + tableApplication + " 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.ApplicationModified != null)
                    {
                        this.ApplicationModified(this, null);
                    }

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